mirror of
https://github.com/github/codeql.git
synced 2025-12-22 11:46:32 +01:00
C++: More principled macro exclusion
We no longer exclude macros based on their name, which means we can now find results inside arguments to the `likely` macro in Linux (except that Linux is compiled with `-fno-strict-overflow`).
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
|
||||
import cpp
|
||||
private import semmle.code.cpp.valuenumbering.GlobalValueNumbering
|
||||
private import semmle.code.cpp.commons.Exclusions
|
||||
|
||||
from RelationalOperation ro, PointerAddExpr add, Expr expr1, Expr expr2
|
||||
where
|
||||
@@ -19,13 +20,8 @@ where
|
||||
add.getAnOperand() = expr1 and
|
||||
ro.getAnOperand() = expr2 and
|
||||
globalValueNumber(expr1) = globalValueNumber(expr2) and
|
||||
// Exclude macros except for assert macros.
|
||||
// TODO: port that location-based macro check we have in another query. Then
|
||||
// we don't need to special-case on names.
|
||||
not exists(MacroInvocation mi |
|
||||
mi.getAnAffectedElement() = add and
|
||||
not mi.getMacroName().toLowerCase().matches("%assert%")
|
||||
) and
|
||||
// Exclude macros but not their arguments
|
||||
not isFromMacroDefinition(ro) and
|
||||
// There must be a compilation of this file without a flag that makes pointer
|
||||
// overflow well defined.
|
||||
exists(Compilation c | c.getAFileCompiled() = ro.getFile() |
|
||||
|
||||
Reference in New Issue
Block a user