Skip to content

Commit 2f793f6

Browse files
committed
C/C++: reduce predicate scope
1 parent 8cfa0a3 commit 2f793f6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,16 @@ private predicate ignoreConstantValue(Operation op) {
6262
op instanceof BitwiseXorExpr
6363
}
6464

65-
/** Holds if `expr` contains an address-of expression that EDG may have constant-folded. */
65+
/**
66+
* Holds if `expr` contains an address-of expression that EDG may have constant-folded.
67+
* We don't recurse into `sizeof` or `alignof` since they don't evaluate their operands,
68+
* so any address-of inside them doesn't affect actual execution.
69+
*/
6670
private predicate containsAddressOf(Expr expr) {
6771
expr instanceof AddressOfExpr
6872
or
73+
not expr instanceof SizeofOperator and
74+
not expr instanceof AlignofOperator and
6975
containsAddressOf(expr.getAChild())
7076
}
7177

0 commit comments

Comments
 (0)