File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
cpp/ql/src/semmle/code/cpp Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -397,16 +397,21 @@ class StaticStorageDurationVariable extends Variable {
397
397
*/
398
398
private predicate runtimeExprInStaticInitializer ( Expr e ) {
399
399
inStaticInitializer ( e ) and
400
- if e instanceof AggregateLiteral
400
+ if e instanceof AggregateLiteral // in sync with the cast in `inStaticInitializer`
401
401
then runtimeExprInStaticInitializer ( e .getAChild ( ) )
402
402
else not e .getFullyConverted ( ) .isConstant ( )
403
403
}
404
404
405
- /** Holds if `e` is part of the initializer of a `StaticStorageDurationVariable`. */
405
+ /**
406
+ * Holds if `e` is the initializer of a `StaticStorageDurationVariable`, either
407
+ * directly or below some top-level `AggregateLiteral`s.
408
+ */
406
409
private predicate inStaticInitializer ( Expr e ) {
407
410
exists ( StaticStorageDurationVariable var | e = var .getInitializer ( ) .getExpr ( ) )
408
411
or
409
- inStaticInitializer ( e .getParent ( ) )
412
+ // The cast to `AggregateLiteral` ensures we only compute what'll later be
413
+ // needed by `runtimeExprInStaticInitializer`.
414
+ inStaticInitializer ( e .getParent ( ) .( AggregateLiteral ) )
410
415
}
411
416
412
417
/**
You can’t perform that action at this time.
0 commit comments