Skip to content

Commit 0e4ed1c

Browse files
committed
C++: Prevent cached stages from being re-evaluated
Before this change, evaluating `cpp/constant-comparison` followed by `cpp/signed-overflow-check` would result in re-evaluation of almost all the cached stages they share: CFG, basic blocks, SSA, and range analysis. The same effect could be seen on `cpp/bad-strncpy-size`, which also uses the GVN library.
1 parent 53709de commit 0e4ed1c

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

cpp/ql/src/semmle/code/cpp/Enclosing.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ Element stmtEnclosingElement(Stmt s) {
1313
/**
1414
* Gets the enclosing element of expression `e`.
1515
*/
16+
// The `pragma[nomagic]` is a workaround to prevent this cached stage (and all
17+
// subsequent stages) from being evaluated twice. See QL-888. It has the effect
18+
// of making the `Conversion` class predicate get the same optimization in all
19+
// queries.
20+
pragma[nomagic]
1621
cached
1722
Element exprEnclosingElement(Expr e) {
1823
result = exprEnclosingElement(e.getParent())

0 commit comments

Comments
 (0)