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

Skip to content

Commit bf43475

Browse files
committed
C++: Unroll recursion in inStaticInitializer
This gets rid of some slow recursive magic. On Wireshark, this improves the timing of the involved predicates from m#Variable::runtimeExprInStaticInitializer#b ..................... 3.1s (executed 86 times) Variable::runtimeExprInStaticInitializer#b#antijoin_rhs .......... 1.6s Variable::runtimeExprInStaticInitializer#b ....................... 985ms (executed 6 times) Variable::runtimeExprInStaticInitializer#b#loop_invariant_prefix . 845ms #Expr::Expr::getParent_dispred#fbPlus ............................ 3.6s (executed 86 times) #Expr::Expr::getParent_dispred#fbPlus_10#join_rhs ................ 988ms to Variable::runtimeExprInStaticInitializer#f#antijoin_rhs . 1.8s Variable::runtimeExprInStaticInitializer#f .............. 1.1s (executed 6 times) Variable::inStaticInitializer#f ......................... 3.2s (executed 86 times)
1 parent 5e01b4b commit bf43475

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,9 @@ private predicate runtimeExprInStaticInitializer(Expr e) {
404404

405405
/** Holds if `e` is part of the initializer of a `StaticStorageDurationVariable`. */
406406
private predicate inStaticInitializer(Expr e) {
407-
exists(StaticStorageDurationVariable var | e.getParent+() = var.getInitializer())
407+
exists(StaticStorageDurationVariable var | e = var.getInitializer().getExpr())
408+
or
409+
inStaticInitializer(e.getParent())
408410
}
409411

410412
/**

0 commit comments

Comments
 (0)