diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedCondition.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedCondition.qll index 516e27c6675..29b931e0ab6 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedCondition.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedCondition.qll @@ -28,7 +28,11 @@ abstract class TranslatedCondition extends TranslatedElement { final Expr getExpr() { result = expr } - final override Function getFunction() { result = getEnclosingFunction(expr) } + final override Declaration getFunction() { + result = getEnclosingFunction(expr) or + result = getEnclosingVariable(expr).(GlobalOrNamespaceVariable) or + result = getEnclosingVariable(expr).(StaticInitializedStaticLocalVariable) + } final Type getResultType() { result = expr.getUnspecifiedType() } } diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedInitialization.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedInitialization.qll index 855c0edd0cb..f530322aa95 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedInitialization.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedInitialization.qll @@ -993,7 +993,7 @@ class TranslatedConstructorBareInit extends TranslatedElement, TTranslatedConstr override TranslatedElement getChild(int id) { none() } - override Function getFunction() { result = getParent().getFunction() } + override Declaration getFunction() { result = getParent().getFunction() } override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) { none() } diff --git a/cpp/ql/test/library-tests/syntax-zoo/aliased_ssa_consistency.expected b/cpp/ql/test/library-tests/syntax-zoo/aliased_ssa_consistency.expected index 6c6fc920670..d94b3df0bb3 100644 --- a/cpp/ql/test/library-tests/syntax-zoo/aliased_ssa_consistency.expected +++ b/cpp/ql/test/library-tests/syntax-zoo/aliased_ssa_consistency.expected @@ -20,7 +20,6 @@ unexplainedLoop unnecessaryPhiInstruction memoryOperandDefinitionIsUnmodeled operandAcrossFunctions -| test.c:245:31:245:31 | Condition | Operand 'Condition' is used on instruction 'ConditionalBranch: 0' in function '$@', but is defined on instruction 'Constant: 0' in function '$@'. | file://:0:0:0:0 | | | test.c:245:24:245:24 | const void *[] a | const void *[] a | instructionWithoutUniqueBlock containsLoopOfForwardEdges lostReachability @@ -31,7 +30,6 @@ notMarkedAsConflated wronglyMarkedAsConflated invalidOverlap nonUniqueEnclosingIRFunction -| test.c:245:31:245:31 | ConditionalBranch: 0 | Instruction 'ConditionalBranch: 0' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | | | fieldAddressOnNonPointer thisArgumentIsNonPointer | pmcallexpr.cpp:10:2:10:15 | Call: call to expression | Call instruction 'Call: call to expression' has a `this` argument operand that is not an address, in function '$@'. | pmcallexpr.cpp:8:13:8:13 | void f() | void f() | diff --git a/cpp/ql/test/library-tests/syntax-zoo/raw_consistency.expected b/cpp/ql/test/library-tests/syntax-zoo/raw_consistency.expected index cac15e43069..6fa6c863aeb 100644 --- a/cpp/ql/test/library-tests/syntax-zoo/raw_consistency.expected +++ b/cpp/ql/test/library-tests/syntax-zoo/raw_consistency.expected @@ -33,7 +33,6 @@ unexplainedLoop unnecessaryPhiInstruction memoryOperandDefinitionIsUnmodeled operandAcrossFunctions -| test.c:245:31:245:31 | Condition | Operand 'Condition' is used on instruction 'ConditionalBranch: 0' in function '$@', but is defined on instruction 'Constant: 0' in function '$@'. | file://:0:0:0:0 | | | test.c:245:24:245:24 | const void *[] a | const void *[] a | instructionWithoutUniqueBlock containsLoopOfForwardEdges lostReachability @@ -53,7 +52,6 @@ notMarkedAsConflated wronglyMarkedAsConflated invalidOverlap nonUniqueEnclosingIRFunction -| test.c:245:31:245:31 | ConditionalBranch: 0 | Instruction 'ConditionalBranch: 0' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | | | fieldAddressOnNonPointer thisArgumentIsNonPointer | pmcallexpr.cpp:10:2:10:15 | Call: call to expression | Call instruction 'Call: call to expression' has a `this` argument operand that is not an address, in function '$@'. | pmcallexpr.cpp:8:13:8:13 | void f() | void f() | diff --git a/cpp/ql/test/library-tests/syntax-zoo/unaliased_ssa_consistency.expected b/cpp/ql/test/library-tests/syntax-zoo/unaliased_ssa_consistency.expected index 17e865e3c23..6706c66c0a2 100644 --- a/cpp/ql/test/library-tests/syntax-zoo/unaliased_ssa_consistency.expected +++ b/cpp/ql/test/library-tests/syntax-zoo/unaliased_ssa_consistency.expected @@ -20,7 +20,6 @@ unexplainedLoop unnecessaryPhiInstruction memoryOperandDefinitionIsUnmodeled operandAcrossFunctions -| test.c:245:31:245:31 | Condition | Operand 'Condition' is used on instruction 'ConditionalBranch: 0' in function '$@', but is defined on instruction 'Constant: 0' in function '$@'. | file://:0:0:0:0 | | | test.c:245:24:245:24 | const void *[] a | const void *[] a | instructionWithoutUniqueBlock containsLoopOfForwardEdges lostReachability @@ -31,7 +30,6 @@ notMarkedAsConflated wronglyMarkedAsConflated invalidOverlap nonUniqueEnclosingIRFunction -| test.c:245:31:245:31 | ConditionalBranch: 0 | Instruction 'ConditionalBranch: 0' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | | | fieldAddressOnNonPointer thisArgumentIsNonPointer | pmcallexpr.cpp:10:2:10:15 | Call: call to expression | Call instruction 'Call: call to expression' has a `this` argument operand that is not an address, in function '$@'. | pmcallexpr.cpp:8:13:8:13 | void f() | void f() |