Skip to content

Commit 4939db1

Browse files
authored
Merge pull request #411 from adityasharad/cpp/constant-exprs-fn-value-performance
C++: Improve performance of `ExprEvaluator::getFunctionValue`.
2 parents 19f238a + bfa4c30 commit 4939db1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

cpp/ql/src/semmle/code/cpp/controlflow/internal/ConstantExprs.qll

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,12 +419,17 @@ library class ExprEvaluator extends int {
419419
)
420420
}
421421

422+
/** Holds if the function `f` is considered by the analysis and may return `ret`. */
423+
pragma[noinline]
424+
private predicate interestingReturnValue(Function f, Expr ret) {
425+
interestingFunction(_, f) and
426+
returnStmt(f, ret)
427+
}
428+
422429
private int getFunctionValue(Function f) {
423-
interestingFunction(_, f)
424-
and
425430
// All returns must have the same int value
426431
// And it must have at least one return
427-
forex(Expr ret | returnStmt(f, ret) | result = getValueInternalNonSubExpr(ret))
432+
forex(Expr ret | interestingReturnValue(f, ret) | result = getValueInternalNonSubExpr(ret))
428433
}
429434

430435
/**

0 commit comments

Comments
 (0)