diff --git a/cpp/ql/test/library-tests/ir/ir/PrintAST.expected b/cpp/ql/test/library-tests/ir/ir/PrintAST.expected index 77e618ef6bb..c14fbc66926 100644 --- a/cpp/ql/test/library-tests/ir/ir/PrintAST.expected +++ b/cpp/ql/test/library-tests/ir/ir/PrintAST.expected @@ -1815,6 +1815,42 @@ ir.c: # 15| Type = [CharPointerType] char * # 15| ValueCategory = prvalue # 16| getStmt(1): [ReturnStmt] return ... +# 18| [TopLevelFunction] void ExRaiseAccessViolation(int) +# 18| : +# 18| getParameter(0): [Parameter] (unnamed parameter 0) +# 18| Type = [IntType] int +# 21| [TopLevelFunction] int TryExceptTest(int) +# 21| : +# 21| getParameter(0): [Parameter] x +# 21| Type = [IntType] int +# 21| getEntryPoint(): [BlockStmt] { ... } +# 22| getStmt(0): [DeclStmt] declaration +# 22| getDeclarationEntry(0): [VariableDeclarationEntry] definition of localPtr +# 22| Type = [IntPointerType] int * +# 24| getStmt(1): [MicrosoftTryExceptStmt] __try { ... } __except( ... ) { ... } +# 24| getStmt(): [BlockStmt] { ... } +# 25| getStmt(0): [ExprStmt] ExprStmt +# 25| getExpr(): [FunctionCall] call to ExRaiseAccessViolation +# 25| Type = [VoidType] void +# 25| ValueCategory = prvalue +# 25| getArgument(0): [VariableAccess] x +# 25| Type = [IntType] int +# 25| ValueCategory = prvalue(load) +# 26| getCondition(): [Literal] 1 +# 26| Type = [IntType] int +# 26| Value = [Literal] 1 +# 26| ValueCategory = prvalue +# 26| getExcept(): [BlockStmt] { ... } +# 27| getStmt(0): [ReturnStmt] return ... +# 27| getExpr(): [Literal] 1 +# 27| Type = [IntType] int +# 27| Value = [Literal] 1 +# 27| ValueCategory = prvalue +# 29| getStmt(2): [ReturnStmt] return ... +# 29| getExpr(): [Literal] 0 +# 29| Type = [IntType] int +# 29| Value = [Literal] 0 +# 29| ValueCategory = prvalue ir.cpp: # 1| [TopLevelFunction] void Constants() # 1| : diff --git a/cpp/ql/test/library-tests/ir/ir/aliased_ir.expected b/cpp/ql/test/library-tests/ir/ir/aliased_ir.expected index 9d56ffda040..203a962b8cd 100644 --- a/cpp/ql/test/library-tests/ir/ir/aliased_ir.expected +++ b/cpp/ql/test/library-tests/ir/ir/aliased_ir.expected @@ -809,6 +809,33 @@ ir.c: # 13| v13_11(void) = AliasedUse : m13_3 # 13| v13_12(void) = ExitFunction : +# 21| int TryExceptTest(int) +# 21| Block 0 +# 21| v21_1(void) = EnterFunction : +# 21| m21_2(unknown) = AliasedDefinition : +# 21| m21_3(unknown) = InitializeNonLocal : +# 21| m21_4(unknown) = Chi : total:m21_2, partial:m21_3 +# 21| r21_5(glval) = VariableAddress[x] : +# 21| m21_6(int) = InitializeParameter[x] : &:r21_5 +# 22| r22_1(glval) = VariableAddress[localPtr] : +# 22| m22_2(int *) = Uninitialized[localPtr] : &:r22_1 +# 25| r25_1(glval) = FunctionAddress[ExRaiseAccessViolation] : +# 25| r25_2(glval) = VariableAddress[x] : +# 25| r25_3(int) = Load[x] : &:r25_2, m21_6 +# 25| v25_4(void) = Call[ExRaiseAccessViolation] : func:r25_1, 0:r25_3 +# 25| m25_5(unknown) = ^CallSideEffect : ~m21_4 +# 25| m25_6(unknown) = Chi : total:m21_4, partial:m25_5 +# 29| r29_1(glval) = VariableAddress[#return] : +# 29| r29_2(int) = Constant[0] : +# 29| m29_3(int) = Store[#return] : &:r29_1, r29_2 +# 21| r21_7(glval) = VariableAddress[#return] : +# 21| v21_8(void) = ReturnValue : &:r21_7, m29_3 +# 21| v21_9(void) = AliasedUse : ~m25_6 +# 21| v21_10(void) = ExitFunction : + +# 21| Block 1 +# 21| v21_11(void) = Unreached : + ir.cpp: # 1| void Constants() # 1| Block 0 diff --git a/cpp/ql/test/library-tests/ir/ir/ir.c b/cpp/ql/test/library-tests/ir/ir/ir.c index c2daea43653..c5c2c79bb51 100644 --- a/cpp/ql/test/library-tests/ir/ir/ir.c +++ b/cpp/ql/test/library-tests/ir/ir/ir.c @@ -15,4 +15,18 @@ void CStyleCast(void *src) char *dst = (char*)src; } +void ExRaiseAccessViolation(int); +#define EXCEPTION_EXECUTE_HANDLER 1 + +int TryExceptTest(int x) { + int *localPtr; + + __try { + ExRaiseAccessViolation(x); + } __except(EXCEPTION_EXECUTE_HANDLER) { + return 1; + } + return 0; +} + // semmle-extractor-options: --microsoft diff --git a/cpp/ql/test/library-tests/ir/ir/operand_locations.expected b/cpp/ql/test/library-tests/ir/ir/operand_locations.expected index c77c7f5e364..4f3eb911121 100644 --- a/cpp/ql/test/library-tests/ir/ir/operand_locations.expected +++ b/cpp/ql/test/library-tests/ir/ir/operand_locations.expected @@ -1005,6 +1005,22 @@ | ir.c:15:24:15:26 | Address | &:r15_2 | | ir.c:15:24:15:26 | Load | m13_6 | | ir.c:15:24:15:26 | Unary | r15_3 | +| ir.c:21:5:21:17 | Address | &:r21_7 | +| ir.c:21:5:21:17 | ChiPartial | partial:m21_3 | +| ir.c:21:5:21:17 | ChiTotal | total:m21_2 | +| ir.c:21:5:21:17 | Load | m29_3 | +| ir.c:21:5:21:17 | SideEffect | ~m25_6 | +| ir.c:21:23:21:23 | Address | &:r21_5 | +| ir.c:22:8:22:15 | Address | &:r22_1 | +| ir.c:25:5:25:26 | CallTarget | func:r25_1 | +| ir.c:25:5:25:26 | ChiPartial | partial:m25_5 | +| ir.c:25:5:25:26 | ChiTotal | total:m21_4 | +| ir.c:25:5:25:26 | SideEffect | ~m21_4 | +| ir.c:25:28:25:28 | Address | &:r25_2 | +| ir.c:25:28:25:28 | Arg(0) | 0:r25_3 | +| ir.c:25:28:25:28 | Load | m21_6 | +| ir.c:29:3:29:11 | Address | &:r29_1 | +| ir.c:29:10:29:10 | StoreValue | r29_2 | | ir.cpp:1:6:1:14 | ChiPartial | partial:m1_3 | | ir.cpp:1:6:1:14 | ChiTotal | total:m1_2 | | ir.cpp:1:6:1:14 | SideEffect | m1_3 | diff --git a/cpp/ql/test/library-tests/ir/ir/raw_consistency.expected b/cpp/ql/test/library-tests/ir/ir/raw_consistency.expected index d2a11541fd1..645d8c4a739 100644 --- a/cpp/ql/test/library-tests/ir/ir/raw_consistency.expected +++ b/cpp/ql/test/library-tests/ir/ir/raw_consistency.expected @@ -20,6 +20,8 @@ multipleIRTypes lostReachability backEdgeCountMismatch useNotDominatedByDefinition +| ir.c:26:14:26:38 | Left | Operand 'Left' is not dominated by its definition in function '$@'. | ir.c:21:5:21:17 | int TryExceptTest(int) | int TryExceptTest(int) | +| ir.c:26:14:26:38 | Left | Operand 'Left' is not dominated by its definition in function '$@'. | ir.c:21:5:21:17 | int TryExceptTest(int) | int TryExceptTest(int) | | ir.cpp:1486:8:1486:8 | Unary | Operand 'Unary' is not dominated by its definition in function '$@'. | ir.cpp:1486:8:1486:8 | void StructuredBindingDataMemberStruct::StructuredBindingDataMemberStruct() | void StructuredBindingDataMemberStruct::StructuredBindingDataMemberStruct() | | 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() | | 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() | diff --git a/cpp/ql/test/library-tests/ir/ir/raw_ir.expected b/cpp/ql/test/library-tests/ir/ir/raw_ir.expected index 88b3f5dafd1..925012aa3db 100644 --- a/cpp/ql/test/library-tests/ir/ir/raw_ir.expected +++ b/cpp/ql/test/library-tests/ir/ir/raw_ir.expected @@ -786,6 +786,65 @@ ir.c: # 13| v13_10(void) = AliasedUse : ~m? # 13| v13_11(void) = ExitFunction : +# 21| int TryExceptTest(int) +# 21| Block 0 +# 21| v21_1(void) = EnterFunction : +# 21| mu21_2(unknown) = AliasedDefinition : +# 21| mu21_3(unknown) = InitializeNonLocal : +# 21| r21_4(glval) = VariableAddress[x] : +# 21| mu21_5(int) = InitializeParameter[x] : &:r21_4 +# 22| r22_1(glval) = VariableAddress[localPtr] : +# 22| mu22_2(int *) = Uninitialized[localPtr] : &:r22_1 +# 25| r25_1(glval) = FunctionAddress[ExRaiseAccessViolation] : +# 25| r25_2(glval) = VariableAddress[x] : +# 25| r25_3(int) = Load[x] : &:r25_2, ~m? +# 25| v25_4(void) = Call[ExRaiseAccessViolation] : func:r25_1, 0:r25_3 +# 25| mu25_5(unknown) = ^CallSideEffect : ~m? +#-----| Goto -> Block 7 + +# 21| Block 1 +# 21| r21_6(glval) = VariableAddress[#return] : +# 21| v21_7(void) = ReturnValue : &:r21_6, ~m? +# 21| v21_8(void) = AliasedUse : ~m? +# 21| v21_9(void) = ExitFunction : + +# 26| Block 2 +# 26| r26_1(int) = Constant[0] : +# 26| r26_2(bool) = CompareEQ : r26_8, r26_1 +# 26| v26_3(void) = ConditionalBranch : r26_2 +#-----| False -> Block 3 +#-----| True -> Block 4 + +# 26| Block 3 +# 26| r26_4(int) = Constant[1] : +# 26| r26_5(bool) = CompareEQ : r26_8, r26_4 +# 26| v26_6(void) = ConditionalBranch : r26_5 +#-----| True -> Block 6 + +# 26| Block 4 +# 26| v26_7(void) = Unwind : +#-----| Goto -> Block 7 + +# 26| Block 5 +# 26| r26_8(int) = Constant[1] : +# 26| r26_9(int) = Constant[-1] : +# 26| r26_10(bool) = CompareEQ : r26_8, r26_9 +# 26| v26_11(void) = ConditionalBranch : r26_10 +#-----| False -> Block 2 +#-----| True -> Block 4 + +# 27| Block 6 +# 27| r27_1(glval) = VariableAddress[#return] : +# 27| r27_2(int) = Constant[1] : +# 27| mu27_3(int) = Store[#return] : &:r27_1, r27_2 +#-----| Goto -> Block 1 + +# 29| Block 7 +# 29| r29_1(glval) = VariableAddress[#return] : +# 29| r29_2(int) = Constant[0] : +# 29| mu29_3(int) = Store[#return] : &:r29_1, r29_2 +#-----| Goto -> Block 1 + ir.cpp: # 1| void Constants() # 1| Block 0