Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 676e8a2

Browse files
authored
Merge pull request #2399 from jbj/ExprHasNoEffect-templates
C++: Suppress ExprHasNoEffect on template code
2 parents 8cca9b0 + b325427 commit 676e8a2

3 files changed

Lines changed: 3 additions & 4 deletions

File tree

cpp/ql/src/Likely Bugs/Likely Typos/ExprHasNoEffect.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ where
8484
not peivc.getEnclosingFunction().isDefaulted() and
8585
not exists(Macro m | peivc = m.getAnInvocation().getAnExpandedElement()) and
8686
not peivc.isFromTemplateInstantiation(_) and
87+
not peivc.isFromUninstantiatedTemplate(_) and
8788
parent = peivc.getParent() and
8889
not parent.isInMacroExpansion() and
8990
not peivc.isUnevaluated() and

cpp/ql/test/query-tests/Likely Bugs/Likely Typos/ExprHasNoEffect/ExprHasNoEffect.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
| test.c:25:5:25:16 | ... ? ... : ... | This expression has no effect. | test.c:25:5:25:16 | ... ? ... : ... | |
2626
| test.c:26:15:26:16 | 32 | This expression has no effect. | test.c:26:15:26:16 | 32 | |
2727
| test.c:27:9:27:10 | 33 | This expression has no effect. | test.c:27:9:27:10 | 33 | |
28-
| test.cpp:24:3:24:3 | call to operator++ | This expression has no effect (because $@ has no external side effects). | test.cpp:9:14:9:23 | operator++ | operator++ |
29-
| test.cpp:25:3:25:3 | call to operator++ | This expression has no effect (because $@ has no external side effects). | test.cpp:9:14:9:23 | operator++ | operator++ |
3028
| test.cpp:62:5:62:5 | call to operator= | This expression has no effect (because $@ has no external side effects). | test.cpp:47:14:47:22 | operator= | operator= |
3129
| test.cpp:65:5:65:5 | call to operator= | This expression has no effect (because $@ has no external side effects). | test.cpp:55:7:55:7 | operator= | operator= |
3230
| volatile.c:9:5:9:5 | c | This expression has no effect. | volatile.c:9:5:9:5 | c | |

cpp/ql/test/query-tests/Likely Bugs/Likely Typos/ExprHasNoEffect/test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class MyTemplateClass
2121
MyIterator arg1, arg2;
2222
_It arg3;
2323

24-
++arg1; // pure, does nothing
25-
++arg2; // pure, does nothing
24+
++arg1; // pure, does nothing [NOT DETECTED]
25+
++arg2; // pure, does nothing [NOT DETECTED]
2626
++arg3; // not pure in all cases (when _It is int this has a side-effect)
2727

2828
return arg2;

0 commit comments

Comments
 (0)