Skip to content

Commit a974cb1

Browse files
committed
C++: Add another test with an _actual_ throw.
1 parent 5fa9681 commit a974cb1

File tree

5 files changed

+582
-0
lines changed

5 files changed

+582
-0
lines changed

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

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14970,3 +14970,200 @@ try_except.c:
1497014970
# 40| Type = [IntType] int
1497114971
# 40| ValueCategory = prvalue(load)
1497214972
# 42| getStmt(2): [ReturnStmt] return ...
14973+
try_except.cpp:
14974+
# 3| [TopLevelFunction] void ProbeFunction()
14975+
# 3| <params>:
14976+
# 4| [TopLevelFunction] void sink()
14977+
# 4| <params>:
14978+
# 6| [TopLevelFunction] void f_cpp()
14979+
# 6| <params>:
14980+
# 6| getEntryPoint(): [BlockStmt] { ... }
14981+
# 7| getStmt(0): [DeclStmt] declaration
14982+
# 7| getDeclarationEntry(0): [VariableDeclarationEntry] definition of x
14983+
# 7| Type = [IntType] int
14984+
# 7| getDeclarationEntry(1): [VariableDeclarationEntry] definition of y
14985+
# 7| Type = [IntType] int
14986+
# 7| getVariable().getInitializer(): [Initializer] initializer for y
14987+
# 7| getExpr(): [Literal] 0
14988+
# 7| Type = [IntType] int
14989+
# 7| Value = [Literal] 0
14990+
# 7| ValueCategory = prvalue
14991+
# 8| getStmt(1): [MicrosoftTryExceptStmt] __try { ... } __except( ... ) { ... }
14992+
# 8| getStmt(): [BlockStmt] { ... }
14993+
# 9| getStmt(0): [ExprStmt] ExprStmt
14994+
# 9| getExpr(): [FunctionCall] call to ProbeFunction
14995+
# 9| Type = [VoidType] void
14996+
# 9| ValueCategory = prvalue
14997+
# 9| getArgument(0): [Literal] 0
14998+
# 9| Type = [IntType] int
14999+
# 9| Value = [Literal] 0
15000+
# 9| ValueCategory = prvalue
15001+
# 10| getStmt(1): [ExprStmt] ExprStmt
15002+
# 10| getExpr(): [AssignExpr] ... = ...
15003+
# 10| Type = [IntType] int
15004+
# 10| ValueCategory = lvalue
15005+
# 10| getLValue(): [VariableAccess] x
15006+
# 10| Type = [IntType] int
15007+
# 10| ValueCategory = lvalue
15008+
# 10| getRValue(): [VariableAccess] y
15009+
# 10| Type = [IntType] int
15010+
# 10| ValueCategory = prvalue(load)
15011+
# 11| getStmt(2): [ExprStmt] ExprStmt
15012+
# 11| getExpr(): [FunctionCall] call to ProbeFunction
15013+
# 11| Type = [VoidType] void
15014+
# 11| ValueCategory = prvalue
15015+
# 11| getArgument(0): [Literal] 0
15016+
# 11| Type = [IntType] int
15017+
# 11| Value = [Literal] 0
15018+
# 11| ValueCategory = prvalue
15019+
# 13| getCondition(): [Literal] 0
15020+
# 13| Type = [IntType] int
15021+
# 13| Value = [Literal] 0
15022+
# 13| ValueCategory = prvalue
15023+
# 13| getExcept(): [BlockStmt] { ... }
15024+
# 14| getStmt(0): [ExprStmt] ExprStmt
15025+
# 14| getExpr(): [FunctionCall] call to sink
15026+
# 14| Type = [VoidType] void
15027+
# 14| ValueCategory = prvalue
15028+
# 14| getArgument(0): [VariableAccess] x
15029+
# 14| Type = [IntType] int
15030+
# 14| ValueCategory = prvalue(load)
15031+
# 16| getStmt(2): [ReturnStmt] return ...
15032+
# 18| [TopLevelFunction] void g_cpp()
15033+
# 18| <params>:
15034+
# 18| getEntryPoint(): [BlockStmt] { ... }
15035+
# 19| getStmt(0): [DeclStmt] declaration
15036+
# 19| getDeclarationEntry(0): [VariableDeclarationEntry] definition of x
15037+
# 19| Type = [IntType] int
15038+
# 19| getDeclarationEntry(1): [VariableDeclarationEntry] definition of y
15039+
# 19| Type = [IntType] int
15040+
# 19| getVariable().getInitializer(): [Initializer] initializer for y
15041+
# 19| getExpr(): [Literal] 0
15042+
# 19| Type = [IntType] int
15043+
# 19| Value = [Literal] 0
15044+
# 19| ValueCategory = prvalue
15045+
# 20| getStmt(1): [MicrosoftTryFinallyStmt] __try { ... } __finally { ... }
15046+
# 20| getStmt(): [BlockStmt] { ... }
15047+
# 21| getStmt(0): [ExprStmt] ExprStmt
15048+
# 21| getExpr(): [FunctionCall] call to ProbeFunction
15049+
# 21| Type = [VoidType] void
15050+
# 21| ValueCategory = prvalue
15051+
# 21| getArgument(0): [Literal] 0
15052+
# 21| Type = [IntType] int
15053+
# 21| Value = [Literal] 0
15054+
# 21| ValueCategory = prvalue
15055+
# 22| getStmt(1): [ExprStmt] ExprStmt
15056+
# 22| getExpr(): [AssignExpr] ... = ...
15057+
# 22| Type = [IntType] int
15058+
# 22| ValueCategory = lvalue
15059+
# 22| getLValue(): [VariableAccess] x
15060+
# 22| Type = [IntType] int
15061+
# 22| ValueCategory = lvalue
15062+
# 22| getRValue(): [VariableAccess] y
15063+
# 22| Type = [IntType] int
15064+
# 22| ValueCategory = prvalue(load)
15065+
# 23| getStmt(2): [ExprStmt] ExprStmt
15066+
# 23| getExpr(): [FunctionCall] call to ProbeFunction
15067+
# 23| Type = [VoidType] void
15068+
# 23| ValueCategory = prvalue
15069+
# 23| getArgument(0): [Literal] 0
15070+
# 23| Type = [IntType] int
15071+
# 23| Value = [Literal] 0
15072+
# 23| ValueCategory = prvalue
15073+
# 25| getFinally(): [BlockStmt] { ... }
15074+
# 26| getStmt(0): [ExprStmt] ExprStmt
15075+
# 26| getExpr(): [FunctionCall] call to sink
15076+
# 26| Type = [VoidType] void
15077+
# 26| ValueCategory = prvalue
15078+
# 26| getArgument(0): [VariableAccess] x
15079+
# 26| Type = [IntType] int
15080+
# 26| ValueCategory = prvalue(load)
15081+
# 28| getStmt(2): [ReturnStmt] return ...
15082+
# 30| [TopLevelFunction] void AfxThrowMemoryException()
15083+
# 30| <params>:
15084+
# 32| [TopLevelFunction] void h_cpp(int)
15085+
# 32| <params>:
15086+
# 32| getParameter(0): [Parameter] b
15087+
# 32| Type = [IntType] int
15088+
# 32| getEntryPoint(): [BlockStmt] { ... }
15089+
# 33| getStmt(0): [DeclStmt] declaration
15090+
# 33| getDeclarationEntry(0): [VariableDeclarationEntry] definition of x
15091+
# 33| Type = [IntType] int
15092+
# 33| getVariable().getInitializer(): [Initializer] initializer for x
15093+
# 33| getExpr(): [Literal] 0
15094+
# 33| Type = [IntType] int
15095+
# 33| Value = [Literal] 0
15096+
# 33| ValueCategory = prvalue
15097+
# 34| getStmt(1): [MicrosoftTryExceptStmt] __try { ... } __except( ... ) { ... }
15098+
# 34| getStmt(): [BlockStmt] { ... }
15099+
# 35| getStmt(0): [IfStmt] if (...) ...
15100+
# 35| getCondition(): [VariableAccess] b
15101+
# 35| Type = [IntType] int
15102+
# 35| ValueCategory = prvalue(load)
15103+
# 35| getThen(): [BlockStmt] { ... }
15104+
# 36| getStmt(0): [ExprStmt] ExprStmt
15105+
# 36| getExpr(): [FunctionCall] call to AfxThrowMemoryException
15106+
# 36| Type = [VoidType] void
15107+
# 36| ValueCategory = prvalue
15108+
# 35| getCondition().getFullyConverted(): [CStyleCast] (bool)...
15109+
# 35| Conversion = [BoolConversion] conversion to bool
15110+
# 35| Type = [BoolType] bool
15111+
# 35| ValueCategory = prvalue
15112+
# 39| getCondition(): [Literal] 1
15113+
# 39| Type = [IntType] int
15114+
# 39| Value = [Literal] 1
15115+
# 39| ValueCategory = prvalue
15116+
# 39| getExcept(): [BlockStmt] { ... }
15117+
# 40| getStmt(0): [ExprStmt] ExprStmt
15118+
# 40| getExpr(): [FunctionCall] call to sink
15119+
# 40| Type = [VoidType] void
15120+
# 40| ValueCategory = prvalue
15121+
# 40| getArgument(0): [VariableAccess] x
15122+
# 40| Type = [IntType] int
15123+
# 40| ValueCategory = prvalue(load)
15124+
# 42| getStmt(2): [ReturnStmt] return ...
15125+
# 44| [TopLevelFunction] void throw_cpp(int)
15126+
# 44| <params>:
15127+
# 44| getParameter(0): [Parameter] b
15128+
# 44| Type = [IntType] int
15129+
# 44| getEntryPoint(): [BlockStmt] { ... }
15130+
# 45| getStmt(0): [DeclStmt] declaration
15131+
# 45| getDeclarationEntry(0): [VariableDeclarationEntry] definition of x
15132+
# 45| Type = [IntType] int
15133+
# 45| getVariable().getInitializer(): [Initializer] initializer for x
15134+
# 45| getExpr(): [Literal] 0
15135+
# 45| Type = [IntType] int
15136+
# 45| Value = [Literal] 0
15137+
# 45| ValueCategory = prvalue
15138+
# 46| getStmt(1): [MicrosoftTryExceptStmt] __try { ... } __except( ... ) { ... }
15139+
# 46| getStmt(): [BlockStmt] { ... }
15140+
# 47| getStmt(0): [IfStmt] if (...) ...
15141+
# 47| getCondition(): [VariableAccess] b
15142+
# 47| Type = [IntType] int
15143+
# 47| ValueCategory = prvalue(load)
15144+
# 47| getThen(): [BlockStmt] { ... }
15145+
# 48| getStmt(0): [ExprStmt] ExprStmt
15146+
# 48| getExpr(): [ThrowExpr] throw ...
15147+
# 48| Type = [IntType] int
15148+
# 48| ValueCategory = prvalue
15149+
# 48| getExpr(): [Literal] 1
15150+
# 48| Type = [IntType] int
15151+
# 48| Value = [Literal] 1
15152+
# 48| ValueCategory = prvalue
15153+
# 47| getCondition().getFullyConverted(): [CStyleCast] (bool)...
15154+
# 47| Conversion = [BoolConversion] conversion to bool
15155+
# 47| Type = [BoolType] bool
15156+
# 47| ValueCategory = prvalue
15157+
# 51| getCondition(): [Literal] 1
15158+
# 51| Type = [IntType] int
15159+
# 51| Value = [Literal] 1
15160+
# 51| ValueCategory = prvalue
15161+
# 51| getExcept(): [BlockStmt] { ... }
15162+
# 52| getStmt(0): [ExprStmt] ExprStmt
15163+
# 52| getExpr(): [FunctionCall] call to sink
15164+
# 52| Type = [VoidType] void
15165+
# 52| ValueCategory = prvalue
15166+
# 52| getArgument(0): [VariableAccess] x
15167+
# 52| Type = [IntType] int
15168+
# 52| ValueCategory = prvalue(load)
15169+
# 54| getStmt(2): [ReturnStmt] return ...

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

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9202,3 +9202,100 @@
92029202
| try_except.c:36:13:36:35 | SideEffect | ~m32_4 |
92039203
| try_except.c:42:1:42:1 | Phi | from 0:~m32_4 |
92049204
| try_except.c:42:1:42:1 | Phi | from 1:~m36_4 |
9205+
| try_except.cpp:6:6:6:10 | ChiPartial | partial:m6_3 |
9206+
| try_except.cpp:6:6:6:10 | ChiTotal | total:m6_2 |
9207+
| try_except.cpp:6:6:6:10 | SideEffect | ~m11_5 |
9208+
| try_except.cpp:7:7:7:7 | Address | &:r7_1 |
9209+
| try_except.cpp:7:10:7:10 | Address | &:r7_3 |
9210+
| try_except.cpp:7:13:7:14 | StoreValue | r7_4 |
9211+
| try_except.cpp:9:5:9:17 | CallTarget | func:r9_1 |
9212+
| try_except.cpp:9:5:9:17 | ChiPartial | partial:m9_4 |
9213+
| try_except.cpp:9:5:9:17 | ChiTotal | total:m6_4 |
9214+
| try_except.cpp:9:5:9:17 | SideEffect | ~m6_4 |
9215+
| try_except.cpp:9:19:9:19 | Arg(0) | 0:r9_2 |
9216+
| try_except.cpp:10:5:10:5 | Address | &:r10_3 |
9217+
| try_except.cpp:10:9:10:9 | Address | &:r10_1 |
9218+
| try_except.cpp:10:9:10:9 | Load | m7_5 |
9219+
| try_except.cpp:10:9:10:9 | StoreValue | r10_2 |
9220+
| try_except.cpp:11:5:11:17 | CallTarget | func:r11_1 |
9221+
| try_except.cpp:11:5:11:17 | ChiPartial | partial:m11_4 |
9222+
| try_except.cpp:11:5:11:17 | ChiTotal | total:m9_5 |
9223+
| try_except.cpp:11:5:11:17 | SideEffect | ~m9_5 |
9224+
| try_except.cpp:11:19:11:19 | Arg(0) | 0:r11_2 |
9225+
| try_except.cpp:18:6:18:10 | ChiPartial | partial:m18_3 |
9226+
| try_except.cpp:18:6:18:10 | ChiTotal | total:m18_2 |
9227+
| try_except.cpp:18:6:18:10 | SideEffect | ~m26_6 |
9228+
| try_except.cpp:19:7:19:7 | Address | &:r19_1 |
9229+
| try_except.cpp:19:10:19:10 | Address | &:r19_3 |
9230+
| try_except.cpp:19:13:19:14 | StoreValue | r19_4 |
9231+
| try_except.cpp:21:5:21:17 | CallTarget | func:r21_1 |
9232+
| try_except.cpp:21:5:21:17 | ChiPartial | partial:m21_4 |
9233+
| try_except.cpp:21:5:21:17 | ChiTotal | total:m18_4 |
9234+
| try_except.cpp:21:5:21:17 | SideEffect | ~m18_4 |
9235+
| try_except.cpp:21:19:21:19 | Arg(0) | 0:r21_2 |
9236+
| try_except.cpp:22:5:22:5 | Address | &:r22_3 |
9237+
| try_except.cpp:22:9:22:9 | Address | &:r22_1 |
9238+
| try_except.cpp:22:9:22:9 | Load | m19_5 |
9239+
| try_except.cpp:22:9:22:9 | StoreValue | r22_2 |
9240+
| try_except.cpp:23:5:23:17 | CallTarget | func:r23_1 |
9241+
| try_except.cpp:23:5:23:17 | ChiPartial | partial:m23_4 |
9242+
| try_except.cpp:23:5:23:17 | ChiTotal | total:m21_5 |
9243+
| try_except.cpp:23:5:23:17 | SideEffect | ~m21_5 |
9244+
| try_except.cpp:23:19:23:19 | Arg(0) | 0:r23_2 |
9245+
| try_except.cpp:26:5:26:8 | CallTarget | func:r26_1 |
9246+
| try_except.cpp:26:5:26:8 | ChiPartial | partial:m26_5 |
9247+
| try_except.cpp:26:5:26:8 | ChiTotal | total:m23_5 |
9248+
| try_except.cpp:26:5:26:8 | SideEffect | ~m23_5 |
9249+
| try_except.cpp:26:10:26:10 | Address | &:r26_2 |
9250+
| try_except.cpp:26:10:26:10 | Arg(0) | 0:r26_3 |
9251+
| try_except.cpp:26:10:26:10 | Load | m22_4 |
9252+
| try_except.cpp:32:6:32:10 | ChiPartial | partial:m32_3 |
9253+
| try_except.cpp:32:6:32:10 | ChiTotal | total:m32_2 |
9254+
| try_except.cpp:32:6:32:10 | SideEffect | ~m42_1 |
9255+
| try_except.cpp:32:16:32:16 | Address | &:r32_5 |
9256+
| try_except.cpp:33:7:33:7 | Address | &:r33_1 |
9257+
| try_except.cpp:33:10:33:11 | StoreValue | r33_2 |
9258+
| try_except.cpp:35:13:35:13 | Address | &:r35_1 |
9259+
| try_except.cpp:35:13:35:13 | Condition | r35_4 |
9260+
| try_except.cpp:35:13:35:13 | Left | r35_2 |
9261+
| try_except.cpp:35:13:35:13 | Load | m32_6 |
9262+
| try_except.cpp:35:13:35:13 | Right | r35_3 |
9263+
| try_except.cpp:36:13:36:35 | CallTarget | func:r36_1 |
9264+
| try_except.cpp:36:13:36:35 | ChiPartial | partial:m36_3 |
9265+
| try_except.cpp:36:13:36:35 | ChiTotal | total:m32_4 |
9266+
| try_except.cpp:36:13:36:35 | SideEffect | ~m32_4 |
9267+
| try_except.cpp:42:1:42:1 | Phi | from 0:~m32_4 |
9268+
| try_except.cpp:42:1:42:1 | Phi | from 1:~m36_4 |
9269+
| try_except.cpp:44:6:44:14 | ChiPartial | partial:m44_3 |
9270+
| try_except.cpp:44:6:44:14 | ChiTotal | total:m44_2 |
9271+
| try_except.cpp:44:6:44:14 | SideEffect | ~m54_1 |
9272+
| try_except.cpp:44:20:44:20 | Address | &:r44_5 |
9273+
| try_except.cpp:45:7:45:7 | Address | &:r45_1 |
9274+
| try_except.cpp:45:10:45:11 | StoreValue | r45_2 |
9275+
| try_except.cpp:47:13:47:13 | Address | &:r47_1 |
9276+
| try_except.cpp:47:13:47:13 | Condition | r47_4 |
9277+
| try_except.cpp:47:13:47:13 | Left | r47_2 |
9278+
| try_except.cpp:47:13:47:13 | Load | m44_6 |
9279+
| try_except.cpp:47:13:47:13 | Right | r47_3 |
9280+
| try_except.cpp:48:13:48:19 | Address | &:r48_1 |
9281+
| try_except.cpp:48:13:48:19 | Address | &:r48_1 |
9282+
| try_except.cpp:48:13:48:19 | Load | m48_3 |
9283+
| try_except.cpp:48:19:48:19 | StoreValue | r48_2 |
9284+
| try_except.cpp:51:15:51:15 | Left | r51_7 |
9285+
| try_except.cpp:51:15:51:15 | Left | r51_7 |
9286+
| try_except.cpp:51:15:51:15 | Left | r51_7 |
9287+
| try_except.cpp:51:18:53:5 | Condition | r51_2 |
9288+
| try_except.cpp:51:18:53:5 | Condition | r51_5 |
9289+
| try_except.cpp:51:18:53:5 | Condition | r51_9 |
9290+
| try_except.cpp:51:18:53:5 | Right | r51_1 |
9291+
| try_except.cpp:51:18:53:5 | Right | r51_4 |
9292+
| try_except.cpp:51:18:53:5 | Right | r51_8 |
9293+
| try_except.cpp:52:9:52:12 | CallTarget | func:r52_1 |
9294+
| try_except.cpp:52:9:52:12 | ChiPartial | partial:m52_5 |
9295+
| try_except.cpp:52:9:52:12 | ChiTotal | total:m44_4 |
9296+
| try_except.cpp:52:9:52:12 | SideEffect | ~m44_4 |
9297+
| try_except.cpp:52:14:52:14 | Address | &:r52_2 |
9298+
| try_except.cpp:52:14:52:14 | Arg(0) | 0:r52_3 |
9299+
| try_except.cpp:52:14:52:14 | Load | m45_3 |
9300+
| try_except.cpp:54:1:54:1 | Phi | from 0:~m44_4 |
9301+
| try_except.cpp:54:1:54:1 | Phi | from 5:~m52_6 |

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ useNotDominatedByDefinition
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() |
2424
| 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) |
2525
| 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) |
26+
| try_except.cpp:13:13:13:13 | Left | Operand 'Left' is not dominated by its definition in function '$@'. | try_except.cpp:6:6:6:10 | void f_cpp() | void f_cpp() |
27+
| try_except.cpp:13:13:13:13 | Left | Operand 'Left' is not dominated by its definition in function '$@'. | try_except.cpp:6:6:6:10 | void f_cpp() | void f_cpp() |
28+
| try_except.cpp:39:15:39:15 | Left | Operand 'Left' is not dominated by its definition in function '$@'. | try_except.cpp:32:6:32:10 | void h_cpp(int) | void h_cpp(int) |
29+
| try_except.cpp:39:15:39:15 | Left | Operand 'Left' is not dominated by its definition in function '$@'. | try_except.cpp:32:6:32:10 | void h_cpp(int) | void h_cpp(int) |
2630
switchInstructionWithoutDefaultEdge
2731
notMarkedAsConflated
2832
wronglyMarkedAsConflated

0 commit comments

Comments
 (0)