Skip to content

Commit c00a114

Browse files
committed
C++: Add a test with invalid IR.
1 parent b5bd7a4 commit c00a114

9 files changed

Lines changed: 113 additions & 0 deletions

‎cpp/ql/test/library-tests/ir/ir/PrintAST.expected‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25804,6 +25804,30 @@ ir.cpp:
2580425804
# 2919| Conversion = [FloatingPointToIntegralConversion] floating point to integral conversion
2580525805
# 2919| Type = [IntType] int
2580625806
# 2919| ValueCategory = prvalue
25807+
# 2921| [CopyAssignmentOperator] PointerWrapper& PointerWrapper::operator=(PointerWrapper const&)
25808+
# 2921| <params>:
25809+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
25810+
#-----| Type = [LValueReferenceType] const PointerWrapper &
25811+
# 2921| [MoveAssignmentOperator] PointerWrapper& PointerWrapper::operator=(PointerWrapper&&)
25812+
# 2921| <params>:
25813+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
25814+
#-----| Type = [RValueReferenceType] PointerWrapper &&
25815+
# 2925| [TopLevelFunction] PointerWrapper get_wrapper()
25816+
# 2925| <params>:
25817+
# 2927| [TopLevelFunction] void test()
25818+
# 2927| <params>:
25819+
# 2927| getEntryPoint(): [BlockStmt] { ... }
25820+
# 2928| getStmt(0): [ExprStmt] ExprStmt
25821+
# 2928| getExpr(): [ValueFieldAccess] x
25822+
# 2928| Type = [IntType] int
25823+
# 2928| ValueCategory = prvalue
25824+
# 2928| getQualifier(): [ValueFieldAccess] point
25825+
# 2928| Type = [Struct] Point
25826+
# 2928| ValueCategory = prvalue
25827+
# 2928| getQualifier(): [FunctionCall] call to get_wrapper
25828+
# 2928| Type = [Struct] PointerWrapper
25829+
# 2928| ValueCategory = prvalue
25830+
# 2929| getStmt(1): [ReturnStmt] return ...
2580725831
ir23.cpp:
2580825832
# 1| [TopLevelFunction] bool consteval_1()
2580925833
# 1| <params>:

‎cpp/ql/test/library-tests/ir/ir/aliased_ir.expected‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21772,6 +21772,39 @@ ir.cpp:
2177221772
# 2919| v2919_13(void) = AliasedUse : ~m2919_11
2177321773
# 2919| v2919_14(void) = ExitFunction :
2177421774

21775+
# 2927| void test()
21776+
# 2927| Block 0
21777+
# 2927| v2927_1(void) = EnterFunction :
21778+
# 2927| m2927_2(unknown) = AliasedDefinition :
21779+
# 2927| m2927_3(unknown) = InitializeNonLocal :
21780+
# 2927| m2927_4(unknown) = Chi : total:m2927_2, partial:m2927_3
21781+
# 2928| r2928_1(glval<unknown>) = FunctionAddress[get_wrapper] :
21782+
# 2928| r2928_2(PointerWrapper) = Call[get_wrapper] : func:r2928_1
21783+
# 2928| m2928_3(unknown) = ^CallSideEffect : ~m2927_4
21784+
# 2928| m2928_4(unknown) = Chi : total:m2927_4, partial:m2928_3
21785+
# 2928| r2928_5(glval<PointerWrapper>) = VariableAddress[#temp2928:3] :
21786+
# 2928| m2928_6(PointerWrapper) = Store[#temp2928:3] : &:r2928_5, r2928_2
21787+
# 2928| r2928_7(glval<Point>) = FieldAddress[point] : r2928_5
21788+
#-----| Goto -> Block 3
21789+
#-----| Goto -> Block 2
21790+
21791+
# 2928| Block 1
21792+
# 2928| r2928_8(glval<int>) = FieldAddress[x] :
21793+
# 2928| r2928_9(int) = Load[?] : &:r2928_8, ~m2928_4
21794+
# 2929| v2929_1(void) = NoOp :
21795+
# 2927| v2927_5(void) = ReturnVoid :
21796+
# 2927| v2927_6(void) = AliasedUse : ~m2928_4
21797+
# 2927| v2927_7(void) = ExitFunction :
21798+
21799+
# 2928| Block 2
21800+
# 2928| r2928_10(glval<Point>) = VariableAddress[#temp2928:17] :
21801+
# 2928| m2928_11(Point) = Store[#temp2928:17] : &:r2928_10, r2928_7
21802+
#-----| Goto -> Block 1
21803+
21804+
# 2928| Block 3
21805+
# 2928| r2928_12(Point) = Load[?] : &:r2928_7, ~m2928_6
21806+
#-----| Goto -> Block 1
21807+
2177521808
ir23.cpp:
2177621809
# 1| bool consteval_1()
2177721810
# 1| Block 0

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
missingOperand
2+
| ir.cpp:2928:23:2928:23 | FieldAddress: x | Instruction 'FieldAddress' is missing an expected operand with tag 'Unary' in function '$@'. | ir.cpp:2927:6:2927:9 | void test() | void test() |
23
unexpectedOperand
34
duplicateOperand
45
missingPhiOperand
@@ -7,6 +8,7 @@ duplicateChiOperand
78
sideEffectWithoutPrimary
89
instructionWithoutSuccessor
910
ambiguousSuccessors
11+
| ir.cpp:2928:17:2928:21 | FieldAddress: point | Instruction 'FieldAddress: point' has 2 successors of kind 'Goto' in function '$@'. | ir.cpp:2927:6:2927:9 | void test() | void test() |
1012
unexplainedLoop
1113
unnecessaryPhiInstruction
1214
memoryOperandDefinitionIsUnmodeled
@@ -26,6 +28,7 @@ wronglyMarkedAsConflated
2628
invalidOverlap
2729
nonUniqueEnclosingIRFunction
2830
fieldAddressOnNonPointer
31+
| ir.cpp:2928:23:2928:23 | FieldAddress: x | FieldAddress instruction 'FieldAddress: x' has an object address operand that is not an address, in function '$@'. | ir.cpp:2927:6:2927:9 | void test() | void test() |
2932
thisArgumentIsNonPointer
3033
| ir.cpp:2548:34:2548:34 | Call: call to operator bool | Call instruction 'Call: call to operator bool' has a `this` argument operand that is not an address, in function '$@'. | ir.cpp:2547:6:2547:23 | void this_inconsistency(bool) | void this_inconsistency(bool) |
3134
nonUniqueIRVariable

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
missingOperand
2+
| ir.cpp:2928:23:2928:23 | FieldAddress: x | Instruction 'FieldAddress' is missing an expected operand with tag 'Unary' in function '$@'. | ir.cpp:2927:6:2927:9 | void test() | void test() |
23
unexpectedOperand
34
duplicateOperand
45
missingPhiOperand
@@ -7,6 +8,7 @@ duplicateChiOperand
78
sideEffectWithoutPrimary
89
instructionWithoutSuccessor
910
ambiguousSuccessors
11+
| ir.cpp:2928:17:2928:21 | FieldAddress: point | Instruction 'FieldAddress: point' has 2 successors of kind 'Goto' in function '$@'. | ir.cpp:2927:6:2927:9 | void test() | void test() |
1012
unexplainedLoop
1113
unnecessaryPhiInstruction
1214
memoryOperandDefinitionIsUnmodeled
@@ -26,6 +28,7 @@ wronglyMarkedAsConflated
2628
invalidOverlap
2729
nonUniqueEnclosingIRFunction
2830
fieldAddressOnNonPointer
31+
| ir.cpp:2928:23:2928:23 | FieldAddress: x | FieldAddress instruction 'FieldAddress: x' has an object address operand that is not an address, in function '$@'. | ir.cpp:2927:6:2927:9 | void test() | void test() |
2932
thisArgumentIsNonPointer
3033
| ir.cpp:2548:34:2548:34 | Call: call to operator bool | Call instruction 'Call: call to operator bool' has a `this` argument operand that is not an address, in function '$@'. | ir.cpp:2547:6:2547:23 | void this_inconsistency(bool) | void this_inconsistency(bool) |
3134
nonUniqueIRVariable

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2918,4 +2918,14 @@ T VariableTemplateFunc(T x) {
29182918

29192919
int VariableTemplateFuncUse = VariableTemplateFunc(2.3);
29202920

2921+
struct PointerWrapper {
2922+
Point point;
2923+
};
2924+
2925+
PointerWrapper get_wrapper();
2926+
2927+
void test() {
2928+
get_wrapper().point.x;
2929+
}
2930+
29212931
// semmle-extractor-options: -std=c++20 --clang

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
missingOperand
2+
| ir.cpp:2928:23:2928:23 | FieldAddress: x | Instruction 'FieldAddress' is missing an expected operand with tag 'Unary' in function '$@'. | ir.cpp:2927:6:2927:9 | void test() | void test() |
23
unexpectedOperand
34
duplicateOperand
45
missingPhiOperand
@@ -7,6 +8,7 @@ duplicateChiOperand
78
sideEffectWithoutPrimary
89
instructionWithoutSuccessor
910
ambiguousSuccessors
11+
| ir.cpp:2928:17:2928:21 | FieldAddress: point | Instruction 'FieldAddress: point' has 2 successors of kind 'Goto' in function '$@'. | ir.cpp:2927:6:2927:9 | void test() | void test() |
1012
unexplainedLoop
1113
unnecessaryPhiInstruction
1214
memoryOperandDefinitionIsUnmodeled
@@ -26,6 +28,7 @@ wronglyMarkedAsConflated
2628
invalidOverlap
2729
nonUniqueEnclosingIRFunction
2830
fieldAddressOnNonPointer
31+
| ir.cpp:2928:23:2928:23 | FieldAddress: x | FieldAddress instruction 'FieldAddress: x' has an object address operand that is not an address, in function '$@'. | ir.cpp:2927:6:2927:9 | void test() | void test() |
2932
thisArgumentIsNonPointer
3033
| ir.cpp:2548:34:2548:34 | Call: call to operator bool | Call instruction 'Call: call to operator bool' has a `this` argument operand that is not an address, in function '$@'. | ir.cpp:2547:6:2547:23 | void this_inconsistency(bool) | void this_inconsistency(bool) |
3134
nonUniqueIRVariable

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19777,6 +19777,37 @@ ir.cpp:
1977719777
# 2919| v2919_11(void) = AliasedUse : ~m?
1977819778
# 2919| v2919_12(void) = ExitFunction :
1977919779

19780+
# 2927| void test()
19781+
# 2927| Block 0
19782+
# 2927| v2927_1(void) = EnterFunction :
19783+
# 2927| mu2927_2(unknown) = AliasedDefinition :
19784+
# 2927| mu2927_3(unknown) = InitializeNonLocal :
19785+
# 2928| r2928_1(glval<unknown>) = FunctionAddress[get_wrapper] :
19786+
# 2928| r2928_2(PointerWrapper) = Call[get_wrapper] : func:r2928_1
19787+
# 2928| mu2928_3(unknown) = ^CallSideEffect : ~m?
19788+
# 2928| r2928_4(glval<PointerWrapper>) = VariableAddress[#temp2928:3] :
19789+
# 2928| mu2928_5(PointerWrapper) = Store[#temp2928:3] : &:r2928_4, r2928_2
19790+
# 2928| r2928_6(glval<Point>) = FieldAddress[point] : r2928_4
19791+
#-----| Goto -> Block 3
19792+
#-----| Goto -> Block 2
19793+
19794+
# 2928| Block 1
19795+
# 2928| r2928_7(glval<int>) = FieldAddress[x] :
19796+
# 2928| r2928_8(int) = Load[?] : &:r2928_7, ~m?
19797+
# 2929| v2929_1(void) = NoOp :
19798+
# 2927| v2927_4(void) = ReturnVoid :
19799+
# 2927| v2927_5(void) = AliasedUse : ~m?
19800+
# 2927| v2927_6(void) = ExitFunction :
19801+
19802+
# 2928| Block 2
19803+
# 2928| r2928_9(glval<Point>) = VariableAddress[#temp2928:17] :
19804+
# 2928| mu2928_10(Point) = Store[#temp2928:17] : &:r2928_9, r2928_6
19805+
#-----| Goto -> Block 1
19806+
19807+
# 2928| Block 3
19808+
# 2928| r2928_11(Point) = Load[?] : &:r2928_6, ~m?
19809+
#-----| Goto -> Block 1
19810+
1978019811
ir23.cpp:
1978119812
# 1| bool consteval_1()
1978219813
# 1| Block 0

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
missingOperand
2+
| ir.cpp:2928:23:2928:23 | FieldAddress: x | Instruction 'FieldAddress' is missing an expected operand with tag 'Unary' in function '$@'. | ir.cpp:2927:6:2927:9 | void test() | void test() |
23
unexpectedOperand
34
duplicateOperand
45
missingPhiOperand
@@ -7,6 +8,7 @@ duplicateChiOperand
78
sideEffectWithoutPrimary
89
instructionWithoutSuccessor
910
ambiguousSuccessors
11+
| ir.cpp:2928:17:2928:21 | FieldAddress: point | Instruction 'FieldAddress: point' has 2 successors of kind 'Goto' in function '$@'. | ir.cpp:2927:6:2927:9 | void test() | void test() |
1012
unexplainedLoop
1113
unnecessaryPhiInstruction
1214
memoryOperandDefinitionIsUnmodeled
@@ -26,6 +28,7 @@ wronglyMarkedAsConflated
2628
invalidOverlap
2729
nonUniqueEnclosingIRFunction
2830
fieldAddressOnNonPointer
31+
| ir.cpp:2928:23:2928:23 | FieldAddress: x | FieldAddress instruction 'FieldAddress: x' has an object address operand that is not an address, in function '$@'. | ir.cpp:2927:6:2927:9 | void test() | void test() |
2932
thisArgumentIsNonPointer
3033
| ir.cpp:2548:34:2548:34 | Call: call to operator bool | Call instruction 'Call: call to operator bool' has a `this` argument operand that is not an address, in function '$@'. | ir.cpp:2547:6:2547:23 | void this_inconsistency(bool) | void this_inconsistency(bool) |
3134
nonUniqueIRVariable

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
missingOperand
2+
| ir.cpp:2928:23:2928:23 | FieldAddress: x | Instruction 'FieldAddress' is missing an expected operand with tag 'Unary' in function '$@'. | ir.cpp:2927:6:2927:9 | void test() | void test() |
23
unexpectedOperand
34
duplicateOperand
45
missingPhiOperand
@@ -7,6 +8,7 @@ duplicateChiOperand
78
sideEffectWithoutPrimary
89
instructionWithoutSuccessor
910
ambiguousSuccessors
11+
| ir.cpp:2928:17:2928:21 | FieldAddress: point | Instruction 'FieldAddress: point' has 2 successors of kind 'Goto' in function '$@'. | ir.cpp:2927:6:2927:9 | void test() | void test() |
1012
unexplainedLoop
1113
unnecessaryPhiInstruction
1214
memoryOperandDefinitionIsUnmodeled
@@ -26,6 +28,7 @@ wronglyMarkedAsConflated
2628
invalidOverlap
2729
nonUniqueEnclosingIRFunction
2830
fieldAddressOnNonPointer
31+
| ir.cpp:2928:23:2928:23 | FieldAddress: x | FieldAddress instruction 'FieldAddress: x' has an object address operand that is not an address, in function '$@'. | ir.cpp:2927:6:2927:9 | void test() | void test() |
2932
thisArgumentIsNonPointer
3033
| ir.cpp:2548:34:2548:34 | Call: call to operator bool | Call instruction 'Call: call to operator bool' has a `this` argument operand that is not an address, in function '$@'. | ir.cpp:2547:6:2547:23 | void this_inconsistency(bool) | void this_inconsistency(bool) |
3134
nonUniqueIRVariable

0 commit comments

Comments
 (0)