Skip to content

Commit 82499b0

Browse files
committed
C++: Use isFromMacroDefinition for exclusion
The `SignedOverflowCheck.ql` query was very slow on certain snapshots (jluttine/suitesparse and Chromium) due to bad magic in `MacroInvocation::getAnAffectedElement_dispred#fb`. This commit doesn't fix the bad magic but changes the exclusion mechanism to use a predicate where we can better control the magic and optimization. The query should also give more good results due to this new exclusion mechanism, which is the same one used in its sibling, `PointerOverflow.ql`.
1 parent 53709de commit 82499b0

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

cpp/ql/src/Likely Bugs/Arithmetic/SignedOverflowCheck.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import cpp
1515
private import semmle.code.cpp.valuenumbering.GlobalValueNumbering
1616
private import semmle.code.cpp.rangeanalysis.SimpleRangeAnalysis
17+
private import semmle.code.cpp.commons.Exclusions
1718

1819
from RelationalOperation ro, AddExpr add, Expr expr1, Expr expr2
1920
where
@@ -22,7 +23,7 @@ where
2223
ro.getAnOperand() = expr2 and
2324
globalValueNumber(expr1) = globalValueNumber(expr2) and
2425
add.getUnspecifiedType().(IntegralType).isSigned() and
25-
not exists(MacroInvocation mi | mi.getAnAffectedElement() = add) and
26+
not isFromMacroDefinition(add) and
2627
exprMightOverflowPositively(add) and
2728
exists(Compilation c | c.getAFileCompiled() = ro.getFile() |
2829
not c.getAnArgument() = "-fwrapv" and

0 commit comments

Comments
 (0)