File tree Expand file tree Collapse file tree 3 files changed +10
-2
lines changed
src/Likely Bugs/Arithmetic
test/query-tests/Likely Bugs/Arithmetic/BadAdditionOverflowCheck Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -18,5 +18,12 @@ from ComparisonOperation cmp
1818where pointlessSelfComparison ( cmp )
1919 and not nanTest ( cmp )
2020 and not overflowTest ( cmp )
21- and not cmp .isInMacroExpansion ( )
21+ and not exists ( MacroInvocation mi |
22+ // cmp is in mi
23+ mi .getAnExpandedElement ( ) = cmp and
24+
25+ // and cmp was apparently not passed in as a macro parameter
26+ cmp .getLocation ( ) .getStartLine ( ) = mi .getLocation ( ) .getStartLine ( ) and
27+ cmp .getLocation ( ) .getStartColumn ( ) = mi .getLocation ( ) .getStartColumn ( )
28+ )
2229select cmp , "Self comparison."
Original file line number Diff line number Diff line change 33| test.cpp:83:10:83:15 | ... == ... | Self comparison. |
44| test.cpp:90:10:90:15 | ... == ... | Self comparison. |
55| test.cpp:118:7:118:32 | ... != ... | Self comparison. |
6+ | test.cpp:151:11:151:16 | ... == ... | Self comparison. |
Original file line number Diff line number Diff line change @@ -148,5 +148,5 @@ void useMarkRange(int offs) {
148148#define MY_MACRO (x ) (x)
149149
150150void myMacroTest (int x) {
151- MY_MACRO (x == x); // BAD [NOT DETECTED]
151+ MY_MACRO (x == x); // BAD
152152}
You can’t perform that action at this time.
0 commit comments