Skip to content

Commit b18e096

Browse files
committed
C++: Fix missing result for 'getFunction' and accept test changes.
1 parent 1dcac76 commit b18e096

File tree

5 files changed

+6
-8
lines changed

5 files changed

+6
-8
lines changed

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedCondition.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ abstract class TranslatedCondition extends TranslatedElement {
2828

2929
final Expr getExpr() { result = expr }
3030

31-
final override Function getFunction() { result = getEnclosingFunction(expr) }
31+
final override Declaration getFunction() {
32+
result = getEnclosingFunction(expr) or
33+
result = getEnclosingVariable(expr).(GlobalOrNamespaceVariable) or
34+
result = getEnclosingVariable(expr).(StaticInitializedStaticLocalVariable)
35+
}
3236

3337
final Type getResultType() { result = expr.getUnspecifiedType() }
3438
}

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedInitialization.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ class TranslatedConstructorBareInit extends TranslatedElement, TTranslatedConstr
993993

994994
override TranslatedElement getChild(int id) { none() }
995995

996-
override Function getFunction() { result = getParent().getFunction() }
996+
override Declaration getFunction() { result = getParent().getFunction() }
997997

998998
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) { none() }
999999

cpp/ql/test/library-tests/syntax-zoo/aliased_ssa_consistency.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ unexplainedLoop
2020
unnecessaryPhiInstruction
2121
memoryOperandDefinitionIsUnmodeled
2222
operandAcrossFunctions
23-
| 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 | <Missing IRFunction> | <Missing IRFunction> | test.c:245:24:245:24 | const void *[] a | const void *[] a |
2423
instructionWithoutUniqueBlock
2524
containsLoopOfForwardEdges
2625
lostReachability
@@ -31,7 +30,6 @@ notMarkedAsConflated
3130
wronglyMarkedAsConflated
3231
invalidOverlap
3332
nonUniqueEnclosingIRFunction
34-
| test.c:245:31:245:31 | ConditionalBranch: 0 | Instruction 'ConditionalBranch: 0' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> |
3533
fieldAddressOnNonPointer
3634
thisArgumentIsNonPointer
3735
| 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() |

cpp/ql/test/library-tests/syntax-zoo/raw_consistency.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ unexplainedLoop
3333
unnecessaryPhiInstruction
3434
memoryOperandDefinitionIsUnmodeled
3535
operandAcrossFunctions
36-
| 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 | <Missing IRFunction> | <Missing IRFunction> | test.c:245:24:245:24 | const void *[] a | const void *[] a |
3736
instructionWithoutUniqueBlock
3837
containsLoopOfForwardEdges
3938
lostReachability
@@ -53,7 +52,6 @@ notMarkedAsConflated
5352
wronglyMarkedAsConflated
5453
invalidOverlap
5554
nonUniqueEnclosingIRFunction
56-
| test.c:245:31:245:31 | ConditionalBranch: 0 | Instruction 'ConditionalBranch: 0' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> |
5755
fieldAddressOnNonPointer
5856
thisArgumentIsNonPointer
5957
| 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() |

cpp/ql/test/library-tests/syntax-zoo/unaliased_ssa_consistency.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ unexplainedLoop
2020
unnecessaryPhiInstruction
2121
memoryOperandDefinitionIsUnmodeled
2222
operandAcrossFunctions
23-
| 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 | <Missing IRFunction> | <Missing IRFunction> | test.c:245:24:245:24 | const void *[] a | const void *[] a |
2423
instructionWithoutUniqueBlock
2524
containsLoopOfForwardEdges
2625
lostReachability
@@ -31,7 +30,6 @@ notMarkedAsConflated
3130
wronglyMarkedAsConflated
3231
invalidOverlap
3332
nonUniqueEnclosingIRFunction
34-
| test.c:245:31:245:31 | ConditionalBranch: 0 | Instruction 'ConditionalBranch: 0' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> |
3533
fieldAddressOnNonPointer
3634
thisArgumentIsNonPointer
3735
| 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() |

0 commit comments

Comments
 (0)