Skip to content

Commit bfa4c30

Browse files
committed
C++: Improve performance of ExprEvaluator::getFunctionValue.
Changes the `forex` range to join on both `this` (the current `ExprEvaluator`) and `ret` (the expected function return value), so that we look at the relevant return values rather than all interesting functions.
1 parent 19f238a commit bfa4c30

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)