CPP: Exclude template code from ExprHasNoEffect.ql#430
Conversation
| not accessInInitOfForStmt(peivc) and | ||
| not peivc.isCompilerGenerated() and | ||
| not exists(Macro m | peivc = m.getAnInvocation().getAnExpandedElement()) and | ||
| not peivc.isFromTemplateInstantiation(_) and |
There was a problem hiding this comment.
Why remove the macro check? Is it redundant because parent.isInMacroExpansion() is checked below?
There was a problem hiding this comment.
Hmm, I didn't really intend to remove it. I was curious whether that line affected any of the tests, and it didn't, but that doesn't necessarily mean it's truly doing nothing. I'll add some test cases for the relationship between this and parent.isInMacroExpansion() and probably reinstate it.
There was a problem hiding this comment.
I've added a test case for macros and reinstated the macro check. I now think it's actually the other macro clause that might be redundant - but with no explanatory comments or test cases, and few real world results that care, I'm not confident.
|
The test failed. I wonder why the Azure tests didn't run on this PR. |
|
The Azure tests did run (and caught the failure): https://semmle.visualstudio.com/QL/_build/results?buildId=680&view=logs |
|
It appears we have some additional query tests hiding in |
Exclude expressions inside template instantiations from ExprHasNoEffect.ql. These are usually false positives due to the expression in question having an effect in other instantiations (real or hypothetical).