From a23077af115d0a877eb56abfff25e09fdaaf7063 Mon Sep 17 00:00:00 2001 From: Jonas Jensen Date: Wed, 18 Mar 2020 14:11:37 +0100 Subject: [PATCH] C++: Comments for future maintainers --- cpp/ql/src/semmle/code/cpp/Variable.qll | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cpp/ql/src/semmle/code/cpp/Variable.qll b/cpp/ql/src/semmle/code/cpp/Variable.qll index 041cf9e084c..a4bbbdbb9ab 100644 --- a/cpp/ql/src/semmle/code/cpp/Variable.qll +++ b/cpp/ql/src/semmle/code/cpp/Variable.qll @@ -397,7 +397,7 @@ class StaticStorageDurationVariable extends Variable { */ private predicate runtimeExprInStaticInitializer(Expr e) { inStaticInitializer(e) and - if e instanceof AggregateLiteral + if e instanceof AggregateLiteral // in sync with the cast in `inStaticInitializer` then runtimeExprInStaticInitializer(e.getAChild()) else not e.getFullyConverted().isConstant() } @@ -409,6 +409,8 @@ private predicate runtimeExprInStaticInitializer(Expr e) { private predicate inStaticInitializer(Expr e) { exists(StaticStorageDurationVariable var | e = var.getInitializer().getExpr()) or + // The cast to `AggregateLiteral` ensures we only compute what'll later be + // needed by `runtimeExprInStaticInitializer`. inStaticInitializer(e.getParent().(AggregateLiteral)) }