mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
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`.
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
import cpp
|
||||
private import semmle.code.cpp.valuenumbering.GlobalValueNumbering
|
||||
private import semmle.code.cpp.rangeanalysis.SimpleRangeAnalysis
|
||||
private import semmle.code.cpp.commons.Exclusions
|
||||
|
||||
from RelationalOperation ro, AddExpr add, Expr expr1, Expr expr2
|
||||
where
|
||||
@@ -22,7 +23,7 @@ where
|
||||
ro.getAnOperand() = expr2 and
|
||||
globalValueNumber(expr1) = globalValueNumber(expr2) and
|
||||
add.getUnspecifiedType().(IntegralType).isSigned() and
|
||||
not exists(MacroInvocation mi | mi.getAnAffectedElement() = add) and
|
||||
not isFromMacroDefinition(add) and
|
||||
exprMightOverflowPositively(add) and
|
||||
exists(Compilation c | c.getAFileCompiled() = ro.getFile() |
|
||||
not c.getAnArgument() = "-fwrapv" and
|
||||
|
||||
Reference in New Issue
Block a user