Skip to content

Commit 892f97c

Browse files
committed
C++: Add testcase with invalid IR from constructing a 'RoutineType'.
1 parent 0335a4f commit 892f97c

10 files changed

+65
-0
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18076,6 +18076,25 @@ ir.cpp:
1807618076
# 2317| getQualifier(): [VariableAccess] s
1807718077
# 2317| Type = [Struct] String
1807818078
# 2317| ValueCategory = lvalue
18079+
# 2320| [CopyAssignmentOperator] return_routine_type::HasVoidToIntFunc& return_routine_type::HasVoidToIntFunc::operator=(return_routine_type::HasVoidToIntFunc const&)
18080+
# 2320| <params>:
18081+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
18082+
#-----| Type = [LValueReferenceType] const HasVoidToIntFunc &
18083+
# 2320| [MoveAssignmentOperator] return_routine_type::HasVoidToIntFunc& return_routine_type::HasVoidToIntFunc::operator=(return_routine_type::HasVoidToIntFunc&&)
18084+
# 2320| <params>:
18085+
#-----| getParameter(0): [Parameter] (unnamed parameter 0)
18086+
#-----| Type = [RValueReferenceType] HasVoidToIntFunc &&
18087+
# 2322| [MemberFunction] void return_routine_type::HasVoidToIntFunc::VoidToInt(int)
18088+
# 2322| <params>:
18089+
# 2322| getParameter(0): [Parameter] (unnamed parameter 0)
18090+
# 2322| Type = [IntType] int
18091+
# 2327| [TopLevelFunction] return_routine_type::VoidToIntMemberFunc return_routine_type::GetVoidToIntFunc()
18092+
# 2327| <params>:
18093+
# 2328| getEntryPoint(): [BlockStmt] { ... }
18094+
# 2329| getStmt(0): [ReturnStmt] return ...
18095+
# 2329| getExpr(): [FunctionAccess] VoidToInt
18096+
# 2329| Type = [RoutineType] ..()(..)
18097+
# 2329| ValueCategory = prvalue
1807918098
perf-regression.cpp:
1808018099
# 4| [CopyAssignmentOperator] Big& Big::operator=(Big const&)
1808118100
# 4| <params>:

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14579,6 +14579,14 @@ ir.cpp:
1457914579
# 2314| v2314_6(void) = AliasedUse : ~m2317_5
1458014580
# 2314| v2314_7(void) = ExitFunction :
1458114581

14582+
# 2327| return_routine_type::VoidToIntMemberFunc return_routine_type::GetVoidToIntFunc()
14583+
# 2327| Block 0
14584+
# 2327| v2327_1(void) = EnterFunction :
14585+
# 2327| m2327_2(unknown) = AliasedDefinition :
14586+
# 2327| m2327_3(unknown) = InitializeNonLocal :
14587+
# 2327| m2327_4(unknown) = Chi : total:m2327_2, partial:m2327_3
14588+
# 2329| r2329_1(glval<..:: *>) = VariableAddress[#return] :
14589+
1458214590
perf-regression.cpp:
1458314591
# 6| void Big::Big()
1458414592
# 6| Block 0

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ missingOperandType
66
duplicateChiOperand
77
sideEffectWithoutPrimary
88
instructionWithoutSuccessor
9+
| ir.cpp:2329:9:2329:44 | VariableAddress: return ... | Instruction 'VariableAddress: return ...' has no successors in function '$@'. | ir.cpp:2327:32:2327:47 | return_routine_type::VoidToIntMemberFunc return_routine_type::GetVoidToIntFunc() | return_routine_type::VoidToIntMemberFunc return_routine_type::GetVoidToIntFunc() |
910
ambiguousSuccessors
1011
unexplainedLoop
1112
unnecessaryPhiInstruction

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ missingOperandType
66
duplicateChiOperand
77
sideEffectWithoutPrimary
88
instructionWithoutSuccessor
9+
| ir.cpp:2329:9:2329:44 | VariableAddress: return ... | Instruction 'VariableAddress: return ...' has no successors in function '$@'. | ir.cpp:2327:32:2327:47 | return_routine_type::VoidToIntMemberFunc return_routine_type::GetVoidToIntFunc() | return_routine_type::VoidToIntMemberFunc return_routine_type::GetVoidToIntFunc() |
910
ambiguousSuccessors
1011
unexplainedLoop
1112
unnecessaryPhiInstruction

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2316,4 +2316,19 @@ void VoidReturnDestructors() {
23162316
return VoidFunc();
23172317
}
23182318

2319+
namespace return_routine_type {
2320+
struct HasVoidToIntFunc
2321+
{
2322+
void VoidToInt(int);
2323+
};
2324+
2325+
typedef void (HasVoidToIntFunc::*VoidToIntMemberFunc)(int);
2326+
2327+
static VoidToIntMemberFunc GetVoidToIntFunc()
2328+
{
2329+
return &HasVoidToIntFunc::VoidToInt;
2330+
}
2331+
2332+
}
2333+
23192334
// semmle-extractor-options: -std=c++20 --clang

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12029,6 +12029,8 @@
1202912029
| ir.cpp:2317:1:2317:1 | ChiTotal | total:m2316_4 |
1203012030
| ir.cpp:2317:1:2317:1 | SideEffect | m2315_8 |
1203112031
| ir.cpp:2317:1:2317:1 | SideEffect | ~m2316_4 |
12032+
| ir.cpp:2327:32:2327:47 | ChiPartial | partial:m2327_3 |
12033+
| ir.cpp:2327:32:2327:47 | ChiTotal | total:m2327_2 |
1203212034
| perf-regression.cpp:6:3:6:5 | Address | &:r6_5 |
1203312035
| perf-regression.cpp:6:3:6:5 | Address | &:r6_5 |
1203412036
| perf-regression.cpp:6:3:6:5 | Address | &:r6_7 |

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,11 +1,13 @@
11
missingOperand
2+
| ir.cpp:2329:16:2329:43 | Store: VoidToInt | Instruction 'Store' is missing an expected operand with tag 'StoreValue' in function '$@'. | ir.cpp:2327:32:2327:47 | return_routine_type::VoidToIntMemberFunc return_routine_type::GetVoidToIntFunc() | return_routine_type::VoidToIntMemberFunc return_routine_type::GetVoidToIntFunc() |
23
unexpectedOperand
34
duplicateOperand
45
missingPhiOperand
56
missingOperandType
67
duplicateChiOperand
78
sideEffectWithoutPrimary
89
instructionWithoutSuccessor
10+
| ir.cpp:2329:9:2329:44 | VariableAddress: return ... | Instruction 'VariableAddress: return ...' has no successors in function '$@'. | ir.cpp:2327:32:2327:47 | return_routine_type::VoidToIntMemberFunc return_routine_type::GetVoidToIntFunc() | return_routine_type::VoidToIntMemberFunc return_routine_type::GetVoidToIntFunc() |
911
ambiguousSuccessors
1012
unexplainedLoop
1113
unnecessaryPhiInstruction
@@ -21,6 +23,7 @@ lostReachability
2123
backEdgeCountMismatch
2224
useNotDominatedByDefinition
2325
| ir.cpp:1488:8:1488:8 | Unary | Operand 'Unary' is not dominated by its definition in function '$@'. | ir.cpp:1488:8:1488:8 | void StructuredBindingDataMemberStruct::StructuredBindingDataMemberStruct() | void StructuredBindingDataMemberStruct::StructuredBindingDataMemberStruct() |
26+
| ir.cpp:2329:9:2329:44 | Address | Operand 'Address' is not dominated by its definition in function '$@'. | ir.cpp:2327:32:2327:47 | return_routine_type::VoidToIntMemberFunc return_routine_type::GetVoidToIntFunc() | return_routine_type::VoidToIntMemberFunc return_routine_type::GetVoidToIntFunc() |
2427
| try_except.c:13:13:13:13 | Left | Operand 'Left' is not dominated by its definition in function '$@'. | try_except.c:6:6:6:6 | void f() | void f() |
2528
| try_except.c:13:13:13:13 | Left | Operand 'Left' is not dominated by its definition in function '$@'. | try_except.c:6:6:6:6 | void f() | void f() |
2629
| try_except.c:39:15:39:15 | Left | Operand 'Left' is not dominated by its definition in function '$@'. | try_except.c:32:6:32:6 | void h(int) | void h(int) |

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13510,6 +13510,20 @@ ir.cpp:
1351013510
# 2314| v2314_5(void) = AliasedUse : ~m?
1351113511
# 2314| v2314_6(void) = ExitFunction :
1351213512

13513+
# 2327| return_routine_type::VoidToIntMemberFunc return_routine_type::GetVoidToIntFunc()
13514+
# 2327| Block 0
13515+
# 2327| v2327_1(void) = EnterFunction :
13516+
# 2327| mu2327_2(unknown) = AliasedDefinition :
13517+
# 2327| mu2327_3(unknown) = InitializeNonLocal :
13518+
# 2329| r2329_1(glval<..:: *>) = VariableAddress[#return] :
13519+
13520+
# 2329| Block 1
13521+
# 2329| mu2329_2(..:: *) = Store[#return] : &:r2329_1
13522+
# 2327| r2327_4(glval<..:: *>) = VariableAddress[#return] :
13523+
# 2327| v2327_5(void) = ReturnValue : &:r2327_4, ~m?
13524+
# 2327| v2327_6(void) = AliasedUse : ~m?
13525+
# 2327| v2327_7(void) = ExitFunction :
13526+
1351313527
perf-regression.cpp:
1351413528
# 6| void Big::Big()
1351513529
# 6| Block 0

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ missingOperandType
66
duplicateChiOperand
77
sideEffectWithoutPrimary
88
instructionWithoutSuccessor
9+
| ir.cpp:2329:9:2329:44 | VariableAddress: return ... | Instruction 'VariableAddress: return ...' has no successors in function '$@'. | ir.cpp:2327:32:2327:47 | return_routine_type::VoidToIntMemberFunc return_routine_type::GetVoidToIntFunc() | return_routine_type::VoidToIntMemberFunc return_routine_type::GetVoidToIntFunc() |
910
ambiguousSuccessors
1011
unexplainedLoop
1112
unnecessaryPhiInstruction

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ missingOperandType
66
duplicateChiOperand
77
sideEffectWithoutPrimary
88
instructionWithoutSuccessor
9+
| ir.cpp:2329:9:2329:44 | VariableAddress: return ... | Instruction 'VariableAddress: return ...' has no successors in function '$@'. | ir.cpp:2327:32:2327:47 | return_routine_type::VoidToIntMemberFunc return_routine_type::GetVoidToIntFunc() | return_routine_type::VoidToIntMemberFunc return_routine_type::GetVoidToIntFunc() |
910
ambiguousSuccessors
1011
unexplainedLoop
1112
unnecessaryPhiInstruction

0 commit comments

Comments
 (0)