Skip to content

Commit 9d4aac6

Browse files
author
Robert Marsh
committed
C++: add IR tests for global var with constructor
1 parent 417b0b5 commit 9d4aac6

8 files changed

+71
-0
lines changed

cpp/ql/test/library-tests/ir/ir/aliased_ssa_consistency.expected

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ unexplainedLoop
1313
unnecessaryPhiInstruction
1414
memoryOperandDefinitionIsUnmodeled
1515
operandAcrossFunctions
16+
| ir.cpp:1705:18:1705:25 | Address | Operand 'Address' is used on instruction 'IndirectMayWriteSideEffect: call to constructor_only' in function '$@', but is defined on instruction 'VariableAddress: global_4' in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> | ir.cpp:1705:18:1705:25 | constructor_only global_4 | constructor_only global_4 |
17+
| ir.cpp:1707:18:1707:25 | Address | Operand 'Address' is used on instruction 'IndirectMayWriteSideEffect: call to constructor_only' in function '$@', but is defined on instruction 'VariableAddress: global_5' in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> | ir.cpp:1707:18:1707:25 | constructor_only global_5 | constructor_only global_5 |
1618
instructionWithoutUniqueBlock
1719
containsLoopOfForwardEdges
1820
lostReachability
@@ -23,6 +25,10 @@ notMarkedAsConflated
2325
wronglyMarkedAsConflated
2426
invalidOverlap
2527
nonUniqueEnclosingIRFunction
28+
| ir.cpp:1705:27:1705:28 | CallSideEffect: call to constructor_only | Instruction 'CallSideEffect: call to constructor_only' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> |
29+
| ir.cpp:1705:27:1705:28 | IndirectMayWriteSideEffect: call to constructor_only | Instruction 'IndirectMayWriteSideEffect: call to constructor_only' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> |
30+
| ir.cpp:1707:28:1707:47 | CallSideEffect: call to constructor_only | Instruction 'CallSideEffect: call to constructor_only' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> |
31+
| ir.cpp:1707:28:1707:47 | IndirectMayWriteSideEffect: call to constructor_only | Instruction 'IndirectMayWriteSideEffect: call to constructor_only' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> |
2632
fieldAddressOnNonPointer
2733
thisArgumentIsNonPointer
2834
missingCanonicalLanguageType

cpp/ql/test/library-tests/ir/ir/aliased_ssa_consistency_unsound.expected

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ unexplainedLoop
1313
unnecessaryPhiInstruction
1414
memoryOperandDefinitionIsUnmodeled
1515
operandAcrossFunctions
16+
| ir.cpp:1705:18:1705:25 | Address | Operand 'Address' is used on instruction 'IndirectMayWriteSideEffect: call to constructor_only' in function '$@', but is defined on instruction 'VariableAddress: global_4' in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> | ir.cpp:1705:18:1705:25 | constructor_only global_4 | constructor_only global_4 |
17+
| ir.cpp:1707:18:1707:25 | Address | Operand 'Address' is used on instruction 'IndirectMayWriteSideEffect: call to constructor_only' in function '$@', but is defined on instruction 'VariableAddress: global_5' in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> | ir.cpp:1707:18:1707:25 | constructor_only global_5 | constructor_only global_5 |
1618
instructionWithoutUniqueBlock
1719
containsLoopOfForwardEdges
1820
lostReachability
@@ -23,6 +25,10 @@ notMarkedAsConflated
2325
wronglyMarkedAsConflated
2426
invalidOverlap
2527
nonUniqueEnclosingIRFunction
28+
| ir.cpp:1705:27:1705:28 | CallSideEffect: call to constructor_only | Instruction 'CallSideEffect: call to constructor_only' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> |
29+
| ir.cpp:1705:27:1705:28 | IndirectMayWriteSideEffect: call to constructor_only | Instruction 'IndirectMayWriteSideEffect: call to constructor_only' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> |
30+
| ir.cpp:1707:28:1707:47 | CallSideEffect: call to constructor_only | Instruction 'CallSideEffect: call to constructor_only' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> |
31+
| ir.cpp:1707:28:1707:47 | IndirectMayWriteSideEffect: call to constructor_only | Instruction 'IndirectMayWriteSideEffect: call to constructor_only' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> |
2632
fieldAddressOnNonPointer
2733
thisArgumentIsNonPointer
2834
missingCanonicalLanguageType

cpp/ql/test/library-tests/ir/ir/ir.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,4 +1701,9 @@ int global_1;
17011701
int global_2 = 1;
17021702

17031703
const int global_3 = 2;
1704+
1705+
constructor_only global_4(1);
1706+
1707+
constructor_only global_5 = constructor_only(2);
1708+
17041709
// semmle-extractor-options: -std=c++17 --clang

cpp/ql/test/library-tests/ir/ir/operand_locations.expected

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7733,6 +7733,18 @@
77337733
| ir.cpp:1703:22:1703:22 | ChiPartial | partial:m1703_5 |
77347734
| ir.cpp:1703:22:1703:22 | ChiTotal | total:m1703_2 |
77357735
| ir.cpp:1703:22:1703:22 | StoreValue | r1703_4 |
7736+
| ir.cpp:1705:18:1705:25 | Address | &:r1705_3 |
7737+
| ir.cpp:1705:18:1705:25 | Arg(this) | this:r1705_3 |
7738+
| ir.cpp:1705:18:1705:25 | SideEffect | ~m1705_2 |
7739+
| ir.cpp:1705:27:1705:27 | Arg(0) | 0:r1705_5 |
7740+
| ir.cpp:1705:27:1705:28 | CallTarget | func:r1705_4 |
7741+
| ir.cpp:1705:27:1705:28 | SideEffect | ~m? |
7742+
| ir.cpp:1707:18:1707:25 | Address | &:r1707_3 |
7743+
| ir.cpp:1707:18:1707:25 | Arg(this) | this:r1707_3 |
7744+
| ir.cpp:1707:18:1707:25 | SideEffect | ~m1707_2 |
7745+
| ir.cpp:1707:28:1707:47 | CallTarget | func:r1707_4 |
7746+
| ir.cpp:1707:28:1707:47 | SideEffect | ~m? |
7747+
| ir.cpp:1707:46:1707:46 | Arg(0) | 0:r1707_5 |
77367748
| perf-regression.cpp:6:3:6:5 | Address | &:r6_5 |
77377749
| perf-regression.cpp:6:3:6:5 | Address | &:r6_5 |
77387750
| perf-regression.cpp:6:3:6:5 | Address | &:r6_7 |

cpp/ql/test/library-tests/ir/ir/raw_consistency.expected

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ unexplainedLoop
2020
unnecessaryPhiInstruction
2121
memoryOperandDefinitionIsUnmodeled
2222
operandAcrossFunctions
23+
| ir.cpp:1705:18:1705:25 | Address | Operand 'Address' is used on instruction 'IndirectMayWriteSideEffect: call to constructor_only' in function '$@', but is defined on instruction 'VariableAddress: global_4' in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> | ir.cpp:1705:18:1705:25 | constructor_only global_4 | constructor_only global_4 |
24+
| ir.cpp:1707:18:1707:25 | Address | Operand 'Address' is used on instruction 'IndirectMayWriteSideEffect: call to constructor_only' in function '$@', but is defined on instruction 'VariableAddress: global_5' in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> | ir.cpp:1707:18:1707:25 | constructor_only global_5 | constructor_only global_5 |
2325
instructionWithoutUniqueBlock
2426
containsLoopOfForwardEdges
2527
lostReachability
@@ -50,6 +52,10 @@ notMarkedAsConflated
5052
wronglyMarkedAsConflated
5153
invalidOverlap
5254
nonUniqueEnclosingIRFunction
55+
| ir.cpp:1705:27:1705:28 | CallSideEffect: call to constructor_only | Instruction 'CallSideEffect: call to constructor_only' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> |
56+
| ir.cpp:1705:27:1705:28 | IndirectMayWriteSideEffect: call to constructor_only | Instruction 'IndirectMayWriteSideEffect: call to constructor_only' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> |
57+
| ir.cpp:1707:28:1707:47 | CallSideEffect: call to constructor_only | Instruction 'CallSideEffect: call to constructor_only' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> |
58+
| ir.cpp:1707:28:1707:47 | IndirectMayWriteSideEffect: call to constructor_only | Instruction 'IndirectMayWriteSideEffect: call to constructor_only' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> |
5359
fieldAddressOnNonPointer
5460
thisArgumentIsNonPointer
5561
missingCanonicalLanguageType

cpp/ql/test/library-tests/ir/ir/raw_ir.expected

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9040,6 +9040,30 @@ ir.cpp:
90409040
# 1703| v1703_7(void) = AliasedUse : ~m?
90419041
# 1703| v1703_8(void) = ExitFunction :
90429042

9043+
# 1705| constructor_only global_4
9044+
# 1705| Block 0
9045+
# 1705| v1705_1(void) = EnterFunction :
9046+
# 1705| mu1705_2(unknown) = AliasedDefinition :
9047+
# 1705| r1705_3(glval<constructor_only>) = VariableAddress :
9048+
# 1705| r1705_4(glval<unknown>) = FunctionAddress[constructor_only] :
9049+
# 1705| r1705_5(int) = Constant[1] :
9050+
# 1705| v1705_6(void) = Call[constructor_only] : func:r1705_4, this:r1705_3, 0:r1705_5
9051+
# 1705| v1705_7(void) = ReturnVoid :
9052+
# 1705| v1705_8(void) = AliasedUse : ~m?
9053+
# 1705| v1705_9(void) = ExitFunction :
9054+
9055+
# 1707| constructor_only global_5
9056+
# 1707| Block 0
9057+
# 1707| v1707_1(void) = EnterFunction :
9058+
# 1707| mu1707_2(unknown) = AliasedDefinition :
9059+
# 1707| r1707_3(glval<constructor_only>) = VariableAddress :
9060+
# 1707| r1707_4(glval<unknown>) = FunctionAddress[constructor_only] :
9061+
# 1707| r1707_5(int) = Constant[2] :
9062+
# 1707| v1707_6(void) = Call[constructor_only] : func:r1707_4, this:r1707_3, 0:r1707_5
9063+
# 1707| v1707_7(void) = ReturnVoid :
9064+
# 1707| v1707_8(void) = AliasedUse : ~m?
9065+
# 1707| v1707_9(void) = ExitFunction :
9066+
90439067
perf-regression.cpp:
90449068
# 6| void Big::Big()
90459069
# 6| Block 0

cpp/ql/test/library-tests/ir/ir/unaliased_ssa_consistency.expected

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ unexplainedLoop
1313
unnecessaryPhiInstruction
1414
memoryOperandDefinitionIsUnmodeled
1515
operandAcrossFunctions
16+
| ir.cpp:1705:18:1705:25 | Address | Operand 'Address' is used on instruction 'IndirectMayWriteSideEffect: call to constructor_only' in function '$@', but is defined on instruction 'VariableAddress: global_4' in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> | ir.cpp:1705:18:1705:25 | constructor_only global_4 | constructor_only global_4 |
17+
| ir.cpp:1707:18:1707:25 | Address | Operand 'Address' is used on instruction 'IndirectMayWriteSideEffect: call to constructor_only' in function '$@', but is defined on instruction 'VariableAddress: global_5' in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> | ir.cpp:1707:18:1707:25 | constructor_only global_5 | constructor_only global_5 |
1618
instructionWithoutUniqueBlock
1719
containsLoopOfForwardEdges
1820
lostReachability
@@ -23,6 +25,10 @@ notMarkedAsConflated
2325
wronglyMarkedAsConflated
2426
invalidOverlap
2527
nonUniqueEnclosingIRFunction
28+
| ir.cpp:1705:27:1705:28 | CallSideEffect: call to constructor_only | Instruction 'CallSideEffect: call to constructor_only' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> |
29+
| ir.cpp:1705:27:1705:28 | IndirectMayWriteSideEffect: call to constructor_only | Instruction 'IndirectMayWriteSideEffect: call to constructor_only' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> |
30+
| ir.cpp:1707:28:1707:47 | CallSideEffect: call to constructor_only | Instruction 'CallSideEffect: call to constructor_only' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> |
31+
| ir.cpp:1707:28:1707:47 | IndirectMayWriteSideEffect: call to constructor_only | Instruction 'IndirectMayWriteSideEffect: call to constructor_only' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> |
2632
fieldAddressOnNonPointer
2733
thisArgumentIsNonPointer
2834
missingCanonicalLanguageType

cpp/ql/test/library-tests/ir/ir/unaliased_ssa_consistency_unsound.expected

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ unexplainedLoop
1313
unnecessaryPhiInstruction
1414
memoryOperandDefinitionIsUnmodeled
1515
operandAcrossFunctions
16+
| ir.cpp:1705:18:1705:25 | Address | Operand 'Address' is used on instruction 'IndirectMayWriteSideEffect: call to constructor_only' in function '$@', but is defined on instruction 'VariableAddress: global_4' in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> | ir.cpp:1705:18:1705:25 | constructor_only global_4 | constructor_only global_4 |
17+
| ir.cpp:1707:18:1707:25 | Address | Operand 'Address' is used on instruction 'IndirectMayWriteSideEffect: call to constructor_only' in function '$@', but is defined on instruction 'VariableAddress: global_5' in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> | ir.cpp:1707:18:1707:25 | constructor_only global_5 | constructor_only global_5 |
1618
instructionWithoutUniqueBlock
1719
containsLoopOfForwardEdges
1820
lostReachability
@@ -23,6 +25,10 @@ notMarkedAsConflated
2325
wronglyMarkedAsConflated
2426
invalidOverlap
2527
nonUniqueEnclosingIRFunction
28+
| ir.cpp:1705:27:1705:28 | CallSideEffect: call to constructor_only | Instruction 'CallSideEffect: call to constructor_only' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> |
29+
| ir.cpp:1705:27:1705:28 | IndirectMayWriteSideEffect: call to constructor_only | Instruction 'IndirectMayWriteSideEffect: call to constructor_only' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> |
30+
| ir.cpp:1707:28:1707:47 | CallSideEffect: call to constructor_only | Instruction 'CallSideEffect: call to constructor_only' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> |
31+
| ir.cpp:1707:28:1707:47 | IndirectMayWriteSideEffect: call to constructor_only | Instruction 'IndirectMayWriteSideEffect: call to constructor_only' has 0 results for `getEnclosingIRFunction()` in function '$@'. | file://:0:0:0:0 | <Missing IRFunction> | <Missing IRFunction> |
2632
fieldAddressOnNonPointer
2733
thisArgumentIsNonPointer
2834
missingCanonicalLanguageType

0 commit comments

Comments
 (0)