Merge pull request #405 from geoffw0/selfcompare

CPP: Fix false positives in PointlessSelfComparison.ql
This commit is contained in:
Jonas Jensen
2018-11-20 09:25:10 +01:00
committed by GitHub
4 changed files with 37 additions and 0 deletions

View File

@@ -18,4 +18,12 @@ from ComparisonOperation cmp
where pointlessSelfComparison(cmp)
and not nanTest(cmp)
and not overflowTest(cmp)
and not exists(MacroInvocation mi |
// cmp is in mi
mi.getAnExpandedElement() = cmp and
// and cmp was apparently not passed in as a macro parameter
cmp.getLocation().getStartLine() = mi.getLocation().getStartLine() and
cmp.getLocation().getStartColumn() = mi.getLocation().getStartColumn()
)
select cmp, "Self comparison."