Skip to content

Commit 67d623f

Browse files
committed
C++: Add __try with load test case
Fix some formatting while here.
1 parent 30ab9b7 commit 67d623f

File tree

6 files changed

+257
-1
lines changed

6 files changed

+257
-1
lines changed

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

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49689,6 +49689,78 @@ try_except.c:
4968949689
# 52| Type = [IntType] int
4969049690
# 52| ValueCategory = prvalue(load)
4969149691
# 54| getStmt(2): [ReturnStmt] return ...
49692+
# 56| [TopLevelFunction] void k(int*, int*, int*, int*, int*)
49693+
# 56| <params>:
49694+
# 56| getParameter(0): [Parameter] b
49695+
# 56| Type = [IntPointerType] int *
49696+
# 56| getParameter(1): [Parameter] c
49697+
# 56| Type = [IntPointerType] int *
49698+
# 56| getParameter(2): [Parameter] d
49699+
# 56| Type = [IntPointerType] int *
49700+
# 56| getParameter(3): [Parameter] e
49701+
# 56| Type = [IntPointerType] int *
49702+
# 56| getParameter(4): [Parameter] f
49703+
# 56| Type = [IntPointerType] int *
49704+
# 56| getEntryPoint(): [BlockStmt] { ... }
49705+
# 57| getStmt(0): [DeclStmt] declaration
49706+
# 57| getDeclarationEntry(0): [VariableDeclarationEntry] definition of x
49707+
# 57| Type = [IntType] int
49708+
# 57| getVariable().getInitializer(): [Initializer] initializer for x
49709+
# 57| getExpr(): [Literal] 0
49710+
# 57| Type = [IntType] int
49711+
# 57| Value = [Literal] 0
49712+
# 57| ValueCategory = prvalue
49713+
# 58| getStmt(1): [MicrosoftTryExceptStmt] __try { ... } __except( ... ) { ... }
49714+
# 58| getStmt(): [BlockStmt] { ... }
49715+
# 59| getStmt(0): [ExprStmt] ExprStmt
49716+
# 59| getExpr(): [AssignExpr] ... = ...
49717+
# 59| Type = [IntType] int
49718+
# 59| ValueCategory = prvalue
49719+
# 59| getLValue(): [VariableAccess] x
49720+
# 59| Type = [IntType] int
49721+
# 59| ValueCategory = lvalue
49722+
# 59| getRValue(): [PointerDereferenceExpr] * ...
49723+
# 59| Type = [IntType] int
49724+
# 59| ValueCategory = prvalue(load)
49725+
# 59| getOperand(): [VariableAccess] b
49726+
# 59| Type = [IntPointerType] int *
49727+
# 59| ValueCategory = prvalue(load)
49728+
# 60| getStmt(1): [ExprStmt] ExprStmt
49729+
# 60| getExpr(): [AssignExpr] ... = ...
49730+
# 60| Type = [IntType] int
49731+
# 60| ValueCategory = prvalue
49732+
# 60| getLValue(): [PointerDereferenceExpr] * ...
49733+
# 60| Type = [IntType] int
49734+
# 60| ValueCategory = lvalue
49735+
# 60| getOperand(): [VariableAccess] c
49736+
# 60| Type = [IntPointerType] int *
49737+
# 60| ValueCategory = prvalue(load)
49738+
# 60| getRValue(): [VariableAccess] x
49739+
# 60| Type = [IntType] int
49740+
# 60| ValueCategory = prvalue(load)
49741+
# 61| getStmt(2): [DeclStmt] declaration
49742+
# 61| getDeclarationEntry(0): [VariableDeclarationEntry] definition of y
49743+
# 61| Type = [IntType] int
49744+
# 61| getVariable().getInitializer(): [Initializer] initializer for y
49745+
# 61| getExpr(): [PointerDereferenceExpr] * ...
49746+
# 61| Type = [IntType] int
49747+
# 61| ValueCategory = prvalue(load)
49748+
# 61| getOperand(): [VariableAccess] d
49749+
# 61| Type = [IntPointerType] int *
49750+
# 61| ValueCategory = prvalue(load)
49751+
# 63| getCondition(): [Literal] 1
49752+
# 63| Type = [IntType] int
49753+
# 63| Value = [Literal] 1
49754+
# 63| ValueCategory = prvalue
49755+
# 63| getExcept(): [BlockStmt] { ... }
49756+
# 64| getStmt(0): [ExprStmt] ExprStmt
49757+
# 64| getExpr(): [FunctionCall] call to sink
49758+
# 64| Type = [VoidType] void
49759+
# 64| ValueCategory = prvalue
49760+
# 64| getArgument(0): [VariableAccess] x
49761+
# 64| Type = [IntType] int
49762+
# 64| ValueCategory = prvalue(load)
49763+
# 66| getStmt(2): [ReturnStmt] return ...
4969249764
try_except.cpp:
4969349765
# 3| [TopLevelFunction] void ProbeFunction()
4969449766
# 3| <params>:

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

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39194,6 +39194,7 @@ try_except.c:
3919439194
# 32| Block 7
3919539195
# 32| v32_10(void) = Unreached :
3919639196

39197+
<<<<<<< HEAD
3919739198
# 46| void j(int)
3919839199
# 46| Block 0
3919939200
# 46| v46_1(void) = EnterFunction :
@@ -39257,6 +39258,82 @@ try_except.c:
3925739258

3925839259
# 46| Block 7
3925939260
# 46| v46_10(void) = Unreached :
39261+
=======
39262+
# 44| void i(int*, int*, int*, int*, int*)
39263+
# 44| Block 0
39264+
# 44| v44_1(void) = EnterFunction :
39265+
# 44| m44_2(unknown) = AliasedDefinition :
39266+
# 44| m44_3(unknown) = InitializeNonLocal :
39267+
# 44| m44_4(unknown) = Chi : total:m44_2, partial:m44_3
39268+
# 44| r44_5(glval<int *>) = VariableAddress[b] :
39269+
# 44| m44_6(int *) = InitializeParameter[b] : &:r44_5
39270+
# 44| r44_7(int *) = Load[b] : &:r44_5, m44_6
39271+
# 44| m44_8(unknown) = InitializeIndirection[b] : &:r44_7
39272+
# 44| r44_9(glval<int *>) = VariableAddress[c] :
39273+
# 44| m44_10(int *) = InitializeParameter[c] : &:r44_9
39274+
# 44| r44_11(int *) = Load[c] : &:r44_9, m44_10
39275+
# 44| m44_12(unknown) = InitializeIndirection[c] : &:r44_11
39276+
# 44| r44_13(glval<int *>) = VariableAddress[d] :
39277+
# 44| m44_14(int *) = InitializeParameter[d] : &:r44_13
39278+
# 44| r44_15(int *) = Load[d] : &:r44_13, m44_14
39279+
# 44| m44_16(unknown) = InitializeIndirection[d] : &:r44_15
39280+
# 44| r44_17(glval<int *>) = VariableAddress[e] :
39281+
# 44| m44_18(int *) = InitializeParameter[e] : &:r44_17
39282+
# 44| r44_19(int *) = Load[e] : &:r44_17, m44_18
39283+
# 44| m44_20(unknown) = InitializeIndirection[e] : &:r44_19
39284+
# 44| r44_21(glval<int *>) = VariableAddress[f] :
39285+
# 44| m44_22(int *) = InitializeParameter[f] : &:r44_21
39286+
# 44| r44_23(int *) = Load[f] : &:r44_21, m44_22
39287+
# 44| m44_24(unknown) = InitializeIndirection[f] : &:r44_23
39288+
# 45| r45_1(glval<int>) = VariableAddress[x] :
39289+
# 45| r45_2(int) = Constant[0] :
39290+
# 45| m45_3(int) = Store[x] : &:r45_1, r45_2
39291+
# 47| r47_1(glval<int *>) = VariableAddress[b] :
39292+
# 47| r47_2(int *) = Load[b] : &:r47_1, m44_6
39293+
# 47| r47_3(int) = Load[?] : &:r47_2, ~m44_8
39294+
# 47| r47_4(glval<int>) = VariableAddress[x] :
39295+
# 47| m47_5(int) = Store[x] : &:r47_4, r47_3
39296+
# 48| r48_1(glval<int>) = VariableAddress[x] :
39297+
# 48| r48_2(int) = Load[x] : &:r48_1, m47_5
39298+
# 48| r48_3(glval<int *>) = VariableAddress[c] :
39299+
# 48| r48_4(int *) = Load[c] : &:r48_3, m44_10
39300+
# 48| r48_5(glval<int>) = CopyValue : r48_4
39301+
# 48| m48_6(int) = Store[?] : &:r48_5, r48_2
39302+
# 48| m48_7(unknown) = Chi : total:m44_12, partial:m48_6
39303+
# 49| r49_1(glval<int>) = VariableAddress[y] :
39304+
# 49| r49_2(glval<int *>) = VariableAddress[d] :
39305+
# 49| r49_3(int *) = Load[d] : &:r49_2, m44_14
39306+
# 49| r49_4(int) = Load[?] : &:r49_3, ~m44_16
39307+
# 49| m49_5(int) = Store[y] : &:r49_1, r49_4
39308+
# 50| r50_1(glval<int[2]>) = VariableAddress[x] :
39309+
# 50| m50_2(int[2]) = Uninitialized[x] : &:r50_1
39310+
# 50| r50_3(int) = Constant[0] :
39311+
# 50| r50_4(glval<int>) = PointerAdd[4] : r50_1, r50_3
39312+
# 50| r50_5(glval<int *>) = VariableAddress[e] :
39313+
# 50| r50_6(int *) = Load[e] : &:r50_5, m44_18
39314+
# 50| r50_7(int) = Load[?] : &:r50_6, ~m44_20
39315+
# 50| m50_8(int) = Store[?] : &:r50_4, r50_7
39316+
# 50| m50_9(int[2]) = Chi : total:m50_2, partial:m50_8
39317+
# 50| r50_10(int) = Constant[1] :
39318+
# 50| r50_11(glval<int>) = PointerAdd[4] : r50_1, r50_10
39319+
# 50| r50_12(glval<int *>) = VariableAddress[f] :
39320+
# 50| r50_13(int *) = Load[f] : &:r50_12, m44_22
39321+
# 50| r50_14(int) = Load[?] : &:r50_13, ~m44_24
39322+
# 50| m50_15(int) = Store[?] : &:r50_11, r50_14
39323+
# 50| m50_16(int[2]) = Chi : total:m50_9, partial:m50_15
39324+
# 55| v55_1(void) = NoOp :
39325+
# 44| v44_25(void) = ReturnIndirection[b] : &:r44_7, m44_8
39326+
# 44| v44_26(void) = ReturnIndirection[c] : &:r44_11, m48_7
39327+
# 44| v44_27(void) = ReturnIndirection[d] : &:r44_15, m44_16
39328+
# 44| v44_28(void) = ReturnIndirection[e] : &:r44_19, m44_20
39329+
# 44| v44_29(void) = ReturnIndirection[f] : &:r44_23, m44_24
39330+
# 44| v44_30(void) = ReturnVoid :
39331+
# 44| v44_31(void) = AliasedUse : m44_3
39332+
# 44| v44_32(void) = ExitFunction :
39333+
39334+
# 44| Block 1
39335+
# 44| v44_33(void) = Unreached :
39336+
>>>>>>> ad6e7a0f0f8 (C++: Add `__try` with load test case)
3926039337

3926139338
try_except.cpp:
3926239339
# 6| void f_cpp()

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 @@ lostReachability
2121
backEdgeCountMismatch
2222
useNotDominatedByDefinition
2323
| ir.cpp:1535:8:1535:8 | Unary | Operand 'Unary' is not dominated by its definition in function '$@'. | ir.cpp:1535:8:1535:8 | void StructuredBindingDataMemberStruct::StructuredBindingDataMemberStruct() | void StructuredBindingDataMemberStruct::StructuredBindingDataMemberStruct() |
24+
| try_except.c:63:13:63:13 | Left | Operand 'Left' is not dominated by its definition in function '$@'. | try_except.c:56:6:56:6 | void k(int*, int*, int*, int*, int*) | void k(int*, int*, int*, int*, int*) |
25+
| try_except.c:63:13:63:13 | Left | Operand 'Left' is not dominated by its definition in function '$@'. | try_except.c:56:6:56:6 | void k(int*, int*, int*, int*, int*) | void k(int*, int*, int*, int*, int*) |
2426
switchInstructionWithoutDefaultEdge
2527
notMarkedAsConflated
2628
wronglyMarkedAsConflated

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

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37533,6 +37533,99 @@ try_except.c:
3753337533
# 46| v46_9(void) = ReturnVoid :
3753437534
#-----| Goto -> Block 1
3753537535

37536+
# 56| void k(int*, int*, int*, int*, int*)
37537+
# 56| Block 0
37538+
# 56| v56_1(void) = EnterFunction :
37539+
# 56| mu56_2(unknown) = AliasedDefinition :
37540+
# 56| mu56_3(unknown) = InitializeNonLocal :
37541+
# 56| r56_4(glval<int *>) = VariableAddress[b] :
37542+
# 56| mu56_5(int *) = InitializeParameter[b] : &:r56_4
37543+
# 56| r56_6(int *) = Load[b] : &:r56_4, ~m?
37544+
# 56| mu56_7(unknown) = InitializeIndirection[b] : &:r56_6
37545+
# 56| r56_8(glval<int *>) = VariableAddress[c] :
37546+
# 56| mu56_9(int *) = InitializeParameter[c] : &:r56_8
37547+
# 56| r56_10(int *) = Load[c] : &:r56_8, ~m?
37548+
# 56| mu56_11(unknown) = InitializeIndirection[c] : &:r56_10
37549+
# 56| r56_12(glval<int *>) = VariableAddress[d] :
37550+
# 56| mu56_13(int *) = InitializeParameter[d] : &:r56_12
37551+
# 56| r56_14(int *) = Load[d] : &:r56_12, ~m?
37552+
# 56| mu56_15(unknown) = InitializeIndirection[d] : &:r56_14
37553+
# 56| r56_16(glval<int *>) = VariableAddress[e] :
37554+
# 56| mu56_17(int *) = InitializeParameter[e] : &:r56_16
37555+
# 56| r56_18(int *) = Load[e] : &:r56_16, ~m?
37556+
# 56| mu56_19(unknown) = InitializeIndirection[e] : &:r56_18
37557+
# 56| r56_20(glval<int *>) = VariableAddress[f] :
37558+
# 56| mu56_21(int *) = InitializeParameter[f] : &:r56_20
37559+
# 56| r56_22(int *) = Load[f] : &:r56_20, ~m?
37560+
# 56| mu56_23(unknown) = InitializeIndirection[f] : &:r56_22
37561+
# 57| r57_1(glval<int>) = VariableAddress[x] :
37562+
# 57| r57_2(int) = Constant[0] :
37563+
# 57| mu57_3(int) = Store[x] : &:r57_1, r57_2
37564+
# 59| r59_1(glval<int *>) = VariableAddress[b] :
37565+
# 59| r59_2(int *) = Load[b] : &:r59_1, ~m?
37566+
# 59| r59_3(int) = Load[?] : &:r59_2, ~m?
37567+
# 59| r59_4(glval<int>) = VariableAddress[x] :
37568+
# 59| mu59_5(int) = Store[x] : &:r59_4, r59_3
37569+
# 60| r60_1(glval<int>) = VariableAddress[x] :
37570+
# 60| r60_2(int) = Load[x] : &:r60_1, ~m?
37571+
# 60| r60_3(glval<int *>) = VariableAddress[c] :
37572+
# 60| r60_4(int *) = Load[c] : &:r60_3, ~m?
37573+
# 60| r60_5(glval<int>) = CopyValue : r60_4
37574+
# 60| mu60_6(int) = Store[?] : &:r60_5, r60_2
37575+
# 61| r61_1(glval<int>) = VariableAddress[y] :
37576+
# 61| r61_2(glval<int *>) = VariableAddress[d] :
37577+
# 61| r61_3(int *) = Load[d] : &:r61_2, ~m?
37578+
# 61| r61_4(int) = Load[?] : &:r61_3, ~m?
37579+
# 61| mu61_5(int) = Store[y] : &:r61_1, r61_4
37580+
#-----| Goto -> Block 7
37581+
37582+
# 56| Block 1
37583+
# 56| v56_24(void) = AliasedUse : ~m?
37584+
# 56| v56_25(void) = ExitFunction :
37585+
37586+
# 56| Block 2
37587+
# 56| v56_26(void) = Unwind :
37588+
#-----| Goto -> Block 1
37589+
37590+
# 63| Block 3
37591+
# 63| r63_1(int) = Constant[0] :
37592+
# 63| r63_2(bool) = CompareEQ : r63_7, r63_1
37593+
# 63| v63_3(void) = ConditionalBranch : r63_2
37594+
#-----| False -> Block 4
37595+
#-----| True -> Block 2
37596+
37597+
# 63| Block 4
37598+
# 63| r63_4(int) = Constant[1] :
37599+
# 63| r63_5(bool) = CompareEQ : r63_7, r63_4
37600+
# 63| v63_6(void) = ConditionalBranch : r63_5
37601+
#-----| True -> Block 6
37602+
37603+
# 63| Block 5
37604+
# 63| r63_7(int) = Constant[1] :
37605+
# 63| r63_8(int) = Constant[-1] :
37606+
# 63| r63_9(bool) = CompareEQ : r63_7, r63_8
37607+
# 63| v63_10(void) = ConditionalBranch : r63_9
37608+
#-----| False -> Block 3
37609+
#-----| True -> Block 2
37610+
37611+
# 64| Block 6
37612+
# 64| r64_1(glval<unknown>) = FunctionAddress[sink] :
37613+
# 64| r64_2(glval<int>) = VariableAddress[x] :
37614+
# 64| r64_3(int) = Load[x] : &:r64_2, ~m?
37615+
# 64| v64_4(void) = Call[sink] : func:r64_1, 0:r64_3
37616+
# 64| mu64_5(unknown) = ^CallSideEffect : ~m?
37617+
#-----| Goto -> Block 7
37618+
37619+
# 66| Block 7
37620+
# 66| v66_1(void) = NoOp :
37621+
# 56| v56_27(void) = ReturnIndirection[b] : &:r56_6, ~m?
37622+
# 56| v56_28(void) = ReturnIndirection[c] : &:r56_10, ~m?
37623+
# 56| v56_29(void) = ReturnIndirection[d] : &:r56_14, ~m?
37624+
# 56| v56_30(void) = ReturnIndirection[e] : &:r56_18, ~m?
37625+
# 56| v56_31(void) = ReturnIndirection[f] : &:r56_22, ~m?
37626+
# 56| v56_32(void) = ReturnVoid :
37627+
#-----| Goto -> Block 1
37628+
3753637629
try_except.cpp:
3753737630
# 6| void f_cpp()
3753837631
# 6| Block 0

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,15 @@ void j(int b) {
5252
sink(x);
5353
}
5454
}
55+
56+
void k(int *b, int *c, int *d, int *e, int *f) {
57+
int x = 0;
58+
__try {
59+
x = *b;
60+
*c = x;
61+
int y = *d;
62+
}
63+
__except (1) {
64+
sink(x);
65+
}
66+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ void throw_cpp(int b) {
4949
}
5050
}
5151
__except (1) {
52-
sink(x);
52+
sink(x);
5353
}
5454
}

0 commit comments

Comments
 (0)