Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1b849db

Browse files
committed
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`).
1 parent db33053 commit 1b849db

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

cpp/ql/src/Likely Bugs/Memory Management/PointerOverflow.ql

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,16 @@
1212

1313
import cpp
1414
private import semmle.code.cpp.valuenumbering.GlobalValueNumbering
15+
private import semmle.code.cpp.commons.Exclusions
1516

1617
from RelationalOperation ro, PointerAddExpr add, Expr expr1, Expr expr2
1718
where
1819
ro.getAnOperand() = add and
1920
add.getAnOperand() = expr1 and
2021
ro.getAnOperand() = expr2 and
2122
globalValueNumber(expr1) = globalValueNumber(expr2) and
22-
// Exclude macros except for assert macros.
23-
// TODO: port that location-based macro check we have in another query. Then
24-
// we don't need to special-case on names.
25-
not exists(MacroInvocation mi |
26-
mi.getAnAffectedElement() = add and
27-
not mi.getMacroName().toLowerCase().matches("%assert%")
28-
) and
23+
// Exclude macros but not their arguments
24+
not isFromMacroDefinition(ro) and
2925
// There must be a compilation of this file without a flag that makes pointer
3026
// overflow well defined.
3127
exists(Compilation c | c.getAFileCompiled() = ro.getFile() |

0 commit comments

Comments
 (0)