1/// Remove unneeded conversion to bool
2///
3//# Relational and logical operators evaluate to bool,
4//# explicit conversion is overly verbose and unneeded.
5//
6// Copyright: (C) 2016 Andrew F. Davis <afd@ti.com> GPLv2.
7
8virtual patch
9virtual context
10virtual org
11virtual report
12
13//----------------------------------------------------------
14//  For patch mode
15//----------------------------------------------------------
16
17@depends on patch@
18expression A, B;
19symbol true, false;
20@@
21
22(
23  A == B
24|
25  A != B
26|
27  A > B
28|
29  A < B
30|
31  A >= B
32|
33  A <= B
34|
35  A && B
36|
37  A || B
38)
39- ? true : false
40
41//----------------------------------------------------------
42//  For context mode
43//----------------------------------------------------------
44
45@r depends on !patch@
46expression A, B;
47symbol true, false;
48position p;
49@@
50
51(
52  A == B
53|
54  A != B
55|
56  A > B
57|
58  A < B
59|
60  A >= B
61|
62  A <= B
63|
64  A && B
65|
66  A || B
67)
68* ? true : false@p
69
70//----------------------------------------------------------
71//  For org mode
72//----------------------------------------------------------
73
74@script:python depends on r&&org@
75p << r.p;
76@@
77
78msg = "WARNING: conversion to bool not needed here"
79coccilib.org.print_todo(p[0], msg)
80
81//----------------------------------------------------------
82//  For report mode
83//----------------------------------------------------------
84
85@script:python depends on r&&report@
86p << r.p;
87@@
88
89msg = "WARNING: conversion to bool not needed here"
90coccilib.report.print_report(p[0], msg)
91