Skip to content

Commit 5fa9681

Browse files
committed
C++: Add another test case with a throw.
1 parent bbf0ec8 commit 5fa9681

File tree

5 files changed

+131
-0
lines changed

5 files changed

+131
-0
lines changed

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14931,3 +14931,42 @@ try_except.c:
1493114931
# 26| Type = [IntType] int
1493214932
# 26| ValueCategory = prvalue(load)
1493314933
# 28| getStmt(2): [ReturnStmt] return ...
14934+
# 30| [TopLevelFunction] void AfxThrowMemoryException()
14935+
# 30| <params>:
14936+
# 32| [TopLevelFunction] void h(int)
14937+
# 32| <params>:
14938+
# 32| getParameter(0): [Parameter] b
14939+
# 32| Type = [IntType] int
14940+
# 32| getEntryPoint(): [BlockStmt] { ... }
14941+
# 33| getStmt(0): [DeclStmt] declaration
14942+
# 33| getDeclarationEntry(0): [VariableDeclarationEntry] definition of x
14943+
# 33| Type = [IntType] int
14944+
# 33| getVariable().getInitializer(): [Initializer] initializer for x
14945+
# 33| getExpr(): [Literal] 0
14946+
# 33| Type = [IntType] int
14947+
# 33| Value = [Literal] 0
14948+
# 33| ValueCategory = prvalue
14949+
# 34| getStmt(1): [MicrosoftTryExceptStmt] __try { ... } __except( ... ) { ... }
14950+
# 34| getStmt(): [BlockStmt] { ... }
14951+
# 35| getStmt(0): [IfStmt] if (...) ...
14952+
# 35| getCondition(): [VariableAccess] b
14953+
# 35| Type = [IntType] int
14954+
# 35| ValueCategory = prvalue(load)
14955+
# 35| getThen(): [BlockStmt] { ... }
14956+
# 36| getStmt(0): [ExprStmt] ExprStmt
14957+
# 36| getExpr(): [FunctionCall] call to AfxThrowMemoryException
14958+
# 36| Type = [VoidType] void
14959+
# 36| ValueCategory = prvalue
14960+
# 39| getCondition(): [Literal] 1
14961+
# 39| Type = [IntType] int
14962+
# 39| Value = [Literal] 1
14963+
# 39| ValueCategory = prvalue
14964+
# 39| getExcept(): [BlockStmt] { ... }
14965+
# 40| getStmt(0): [ExprStmt] ExprStmt
14966+
# 40| getExpr(): [FunctionCall] call to sink
14967+
# 40| Type = [VoidType] void
14968+
# 40| ValueCategory = prvalue
14969+
# 40| getArgument(0): [VariableAccess] x
14970+
# 40| Type = [IntType] int
14971+
# 40| ValueCategory = prvalue(load)
14972+
# 42| getStmt(2): [ReturnStmt] return ...

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9187,3 +9187,18 @@
91879187
| try_except.c:26:10:26:10 | Address | &:r26_2 |
91889188
| try_except.c:26:10:26:10 | Arg(0) | 0:r26_3 |
91899189
| try_except.c:26:10:26:10 | Load | m22_4 |
9190+
| try_except.c:32:6:32:6 | ChiPartial | partial:m32_3 |
9191+
| try_except.c:32:6:32:6 | ChiTotal | total:m32_2 |
9192+
| try_except.c:32:6:32:6 | SideEffect | ~m42_1 |
9193+
| try_except.c:32:12:32:12 | Address | &:r32_5 |
9194+
| try_except.c:33:7:33:7 | Address | &:r33_1 |
9195+
| try_except.c:33:10:33:11 | StoreValue | r33_2 |
9196+
| try_except.c:35:13:35:13 | Address | &:r35_1 |
9197+
| try_except.c:35:13:35:13 | Condition | r35_2 |
9198+
| try_except.c:35:13:35:13 | Load | m32_6 |
9199+
| try_except.c:36:13:36:35 | CallTarget | func:r36_1 |
9200+
| try_except.c:36:13:36:35 | ChiPartial | partial:m36_3 |
9201+
| try_except.c:36:13:36:35 | ChiTotal | total:m32_4 |
9202+
| try_except.c:36:13:36:35 | SideEffect | ~m32_4 |
9203+
| try_except.c:42:1:42:1 | Phi | from 0:~m32_4 |
9204+
| try_except.c:42:1:42:1 | Phi | from 1:~m36_4 |

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ useNotDominatedByDefinition
2121
| ir.cpp:1752:48:1752:48 | Address | Operand 'Address' is not dominated by its definition in function '$@'. | ir.cpp:1750:5:1750:34 | int implicit_copy_constructor_test(CopyConstructorTestNonVirtualClass const&, CopyConstructorTestVirtualClass const&) | int implicit_copy_constructor_test(CopyConstructorTestNonVirtualClass const&, CopyConstructorTestVirtualClass const&) |
2222
| 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() |
2323
| 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() |
24+
| 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) |
25+
| 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) |
2426
switchInstructionWithoutDefaultEdge
2527
notMarkedAsConflated
2628
wronglyMarkedAsConflated

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

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10506,3 +10506,64 @@ try_except.c:
1050610506
# 18| v18_4(void) = ReturnVoid :
1050710507
# 18| v18_5(void) = AliasedUse : ~m?
1050810508
# 18| v18_6(void) = ExitFunction :
10509+
10510+
# 32| void h(int)
10511+
# 32| Block 0
10512+
# 32| v32_1(void) = EnterFunction :
10513+
# 32| mu32_2(unknown) = AliasedDefinition :
10514+
# 32| mu32_3(unknown) = InitializeNonLocal :
10515+
# 32| r32_4(glval<int>) = VariableAddress[b] :
10516+
# 32| mu32_5(int) = InitializeParameter[b] : &:r32_4
10517+
# 33| r33_1(glval<int>) = VariableAddress[x] :
10518+
# 33| r33_2(int) = Constant[0] :
10519+
# 33| mu33_3(int) = Store[x] : &:r33_1, r33_2
10520+
# 35| r35_1(glval<int>) = VariableAddress[b] :
10521+
# 35| r35_2(int) = Load[b] : &:r35_1, ~m?
10522+
# 35| v35_3(void) = ConditionalBranch : r35_2
10523+
#-----| False -> Block 7
10524+
#-----| True -> Block 1
10525+
10526+
# 36| Block 1
10527+
# 36| r36_1(glval<unknown>) = FunctionAddress[AfxThrowMemoryException] :
10528+
# 36| v36_2(void) = Call[AfxThrowMemoryException] : func:r36_1
10529+
# 36| mu36_3(unknown) = ^CallSideEffect : ~m?
10530+
#-----| Goto -> Block 7
10531+
10532+
# 39| Block 2
10533+
# 39| r39_1(int) = Constant[0] :
10534+
# 39| r39_2(bool) = CompareEQ : r39_8, r39_1
10535+
# 39| v39_3(void) = ConditionalBranch : r39_2
10536+
#-----| False -> Block 3
10537+
#-----| True -> Block 4
10538+
10539+
# 39| Block 3
10540+
# 39| r39_4(int) = Constant[1] :
10541+
# 39| r39_5(bool) = CompareEQ : r39_8, r39_4
10542+
# 39| v39_6(void) = ConditionalBranch : r39_5
10543+
#-----| True -> Block 6
10544+
10545+
# 39| Block 4
10546+
# 39| v39_7(void) = Unwind :
10547+
#-----| Goto -> Block 7
10548+
10549+
# 39| Block 5
10550+
# 39| r39_8(int) = Constant[1] :
10551+
# 39| r39_9(int) = Constant[-1] :
10552+
# 39| r39_10(bool) = CompareEQ : r39_8, r39_9
10553+
# 39| v39_11(void) = ConditionalBranch : r39_10
10554+
#-----| False -> Block 2
10555+
#-----| True -> Block 4
10556+
10557+
# 40| Block 6
10558+
# 40| r40_1(glval<unknown>) = FunctionAddress[sink] :
10559+
# 40| r40_2(glval<int>) = VariableAddress[x] :
10560+
# 40| r40_3(int) = Load[x] : &:r40_2, ~m?
10561+
# 40| v40_4(void) = Call[sink] : func:r40_1, 0:r40_3
10562+
# 40| mu40_5(unknown) = ^CallSideEffect : ~m?
10563+
#-----| Goto -> Block 7
10564+
10565+
# 42| Block 7
10566+
# 42| v42_1(void) = NoOp :
10567+
# 32| v32_6(void) = ReturnVoid :
10568+
# 32| v32_7(void) = AliasedUse : ~m?
10569+
# 32| v32_8(void) = ExitFunction :

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,18 @@ void g() {
2525
__finally {
2626
sink(x);
2727
}
28+
}
29+
30+
void AfxThrowMemoryException();
31+
32+
void h(int b) {
33+
int x = 0;
34+
__try {
35+
if (b) {
36+
AfxThrowMemoryException();
37+
}
38+
}
39+
__except (1) {
40+
sink(x);
41+
}
2842
}

0 commit comments

Comments
 (0)