@@ -62,15 +62,6 @@ private predicate ignoreExprAndDescendants(Expr expr) {
6262 // constant value.
6363 isIRConstant ( getRealParent ( expr ) )
6464 or
65- // Only translate the initializer of a static local if it uses run-time data.
66- // Otherwise the initializer does not run in function scope.
67- exists ( Initializer init , StaticStorageDurationVariable var |
68- init = var .getInitializer ( ) and
69- not var .hasDynamicInitialization ( ) and
70- expr = init .getExpr ( ) .getFullyConverted ( ) and
71- not var instanceof GlobalOrNamespaceVariable
72- )
73- or
7465 // Ignore descendants of `__assume` expressions, since we translated these to `NoOp`.
7566 getRealParent ( expr ) instanceof AssumeExpr
7667 or
@@ -438,6 +429,17 @@ predicate hasTranslatedSyntheticTemporaryObject(Expr expr) {
438429 not expr .hasLValueToRValueConversion ( )
439430}
440431
432+ class StaticInitializedStaticLocalVariable extends StaticLocalVariable {
433+ StaticInitializedStaticLocalVariable ( ) {
434+ this .hasInitializer ( ) and
435+ not this .hasDynamicInitialization ( )
436+ }
437+ }
438+
439+ class RuntimeInitializedStaticLocalVariable extends StaticLocalVariable {
440+ RuntimeInitializedStaticLocalVariable ( ) { this .hasDynamicInitialization ( ) }
441+ }
442+
441443/**
442444 * Holds if the specified `DeclarationEntry` needs an IR translation. An IR translation is only
443445 * necessary for automatic local variables, or for static local variables with dynamic
@@ -453,7 +455,7 @@ private predicate translateDeclarationEntry(IRDeclarationEntry entry) {
453455 not var .isStatic ( )
454456 or
455457 // Ignore static variables unless they have a dynamic initializer.
456- var . ( StaticLocalVariable ) . hasDynamicInitialization ( )
458+ var instanceof RuntimeInitializedStaticLocalVariable
457459 )
458460 )
459461}
@@ -755,7 +757,7 @@ newtype TTranslatedElement =
755757 } or
756758 // The side effect that initializes newly-allocated memory.
757759 TTranslatedAllocationSideEffect ( AllocationExpr expr ) { not ignoreSideEffects ( expr ) } or
758- TTranslatedGlobalOrNamespaceVarInit ( GlobalOrNamespaceVariable var ) { Raw:: varHasIRFunc ( var ) }
760+ TTranslatedStaticStorageDurationVarInit ( Variable var ) { Raw:: varHasIRFunc ( var ) }
759761
760762/**
761763 * Gets the index of the first explicitly initialized element in `initList`
@@ -1043,6 +1045,6 @@ abstract class TranslatedRootElement extends TranslatedElement {
10431045 TranslatedRootElement ( ) {
10441046 this instanceof TTranslatedFunction
10451047 or
1046- this instanceof TTranslatedGlobalOrNamespaceVarInit
1048+ this instanceof TTranslatedStaticStorageDurationVarInit
10471049 }
10481050}
0 commit comments