diff --git a/cpp/ql/test/library-tests/ir/ir/PrintAST.expected b/cpp/ql/test/library-tests/ir/ir/PrintAST.expected index 9dbcf49777b..ff5bb76bf6b 100644 --- a/cpp/ql/test/library-tests/ir/ir/PrintAST.expected +++ b/cpp/ql/test/library-tests/ir/ir/PrintAST.expected @@ -25562,7 +25562,33 @@ ir.cpp: # 2867| Type = [IntType] int # 2867| Value = [ParenthesisExpr] 0 # 2867| ValueCategory = prvalue -# 2868| getStmt(2): [ReturnStmt] return ... +# 2869| getStmt(2): [TryStmt] try { ... } +# 2869| getStmt(): [BlockStmt] { ... } +# 2870| getStmt(0): [ExprStmt] ExprStmt +# 2870| getExpr(): [ThrowExpr] throw ... +# 2870| Type = [IntType] int +# 2870| ValueCategory = prvalue +# 2870| getExpr(): [Literal] 41 +# 2870| Type = [IntType] int +# 2870| Value = [Literal] 41 +# 2870| ValueCategory = prvalue +# 2871| getChild(1): [Handler] +# 2871| getParameter(): [Parameter] c +# 2871| Type = [IntType] int +# 2871| getBlock(): [CatchBlock] { ... } +# 2872| getStmt(0): [ExprStmt] ExprStmt +# 2872| getExpr(): [Literal] 0 +# 2872| Type = [IntType] int +# 2872| Value = [Literal] 0 +# 2872| ValueCategory = prvalue +# 2872| getExpr().getFullyConverted(): [ParenthesisExpr] (...) +# 2872| Type = [VoidType] void +# 2872| ValueCategory = prvalue +# 2872| getExpr(): [CStyleCast] (void)... +# 2872| Conversion = [VoidConversion] conversion to void +# 2872| Type = [VoidType] void +# 2872| ValueCategory = prvalue +# 2874| getStmt(3): [ReturnStmt] return ... ir23.cpp: # 1| [TopLevelFunction] bool consteval_1() # 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 b7fc1b3a96b..2e183c02f85 100644 --- a/cpp/ql/test/library-tests/ir/ir/aliased_ir.expected +++ b/cpp/ql/test/library-tests/ir/ir/aliased_ir.expected @@ -20990,29 +20990,52 @@ ir.cpp: # 2867| r2867_2(glval) = VariableAddress[b] : # 2867| r2867_3(bool) = Load[b] : &:r2867_2, m2865_8 # 2867| v2867_4(void) = ConditionalBranch : r2867_3 -#-----| False -> Block 3 -#-----| True -> Block 2 +#-----| False -> Block 5 +#-----| True -> Block 4 -# 2867| Block 1 -# 2867| m2867_5(int) = Phi : from 2:m2867_11, from 3:m2867_14 -# 2867| r2867_6(glval) = VariableAddress[#temp2867:13] : -# 2867| r2867_7(int) = Load[#temp2867:13] : &:r2867_6, m2867_5 -# 2867| m2867_8(int) = Store[z] : &:r2867_1, r2867_7 -# 2868| v2868_1(void) = NoOp : -# 2865| v2865_11(void) = ReturnVoid : -# 2865| v2865_12(void) = AliasedUse : m2865_3 -# 2865| v2865_13(void) = ExitFunction : +# 2865| Block 1 +# 2865| v2865_11(void) = AliasedUse : m2865_3 +# 2865| v2865_12(void) = ExitFunction : -# 2867| Block 2 -# 2867| r2867_9(int) = Constant[0] : -# 2867| r2867_10(glval) = VariableAddress[#temp2867:13] : -# 2867| m2867_11(int) = Store[#temp2867:13] : &:r2867_10, r2867_9 +# 2865| Block 2 +# 2865| v2865_13(void) = Unwind : #-----| Goto -> Block 1 # 2867| Block 3 +# 2867| m2867_5(int) = Phi : from 4:m2867_11, from 5:m2867_14 +# 2867| r2867_6(glval) = VariableAddress[#temp2867:13] : +# 2867| r2867_7(int) = Load[#temp2867:13] : &:r2867_6, m2867_5 +# 2867| m2867_8(int) = Store[z] : &:r2867_1, r2867_7 +# 2870| r2870_1(glval) = VariableAddress[#throw2870:9] : +# 2870| r2870_2(int) = Constant[41] : +# 2870| m2870_3(int) = Store[#throw2870:9] : &:r2870_1, r2870_2 +# 2870| v2870_4(void) = ThrowValue : &:r2870_1, m2870_3 +#-----| C++ Exception -> Block 6 + +# 2867| Block 4 +# 2867| r2867_9(int) = Constant[0] : +# 2867| r2867_10(glval) = VariableAddress[#temp2867:13] : +# 2867| m2867_11(int) = Store[#temp2867:13] : &:r2867_10, r2867_9 +#-----| Goto -> Block 3 + +# 2867| Block 5 # 2867| r2867_12(int) = Constant[1] : # 2867| r2867_13(glval) = VariableAddress[#temp2867:13] : # 2867| m2867_14(int) = Store[#temp2867:13] : &:r2867_13, r2867_12 +#-----| Goto -> Block 3 + +# 2871| Block 6 +# 2871| v2871_1(void) = CatchByType[int] : +#-----| C++ Exception -> Block 2 +#-----| Goto -> Block 7 + +# 2871| Block 7 +# 2871| r2871_2(glval) = VariableAddress[c] : +# 2871| m2871_3(int) = InitializeParameter[c] : &:r2871_2 +# 2872| r2872_1(int) = Constant[0] : +# 2872| v2872_2(void) = Convert : r2872_1 +# 2874| v2874_1(void) = NoOp : +# 2865| v2865_14(void) = ReturnVoid : #-----| Goto -> Block 1 ir23.cpp: diff --git a/cpp/ql/test/library-tests/ir/ir/ir.cpp b/cpp/ql/test/library-tests/ir/ir/ir.cpp index c915727a7b4..0eb6ef50df0 100644 --- a/cpp/ql/test/library-tests/ir/ir/ir.cpp +++ b/cpp/ql/test/library-tests/ir/ir/ir.cpp @@ -2865,6 +2865,12 @@ template void test_assert_in_template(short, int, unsigned); void complex_assertions(int x, bool b, int max) { int y = (assert(x > 0), x); int z = b ? (assert(x != 0), 0) : 1; + + try { + throw 41; + } catch (int c) { + assert(c < 42); + } } // semmle-extractor-options: -std=c++20 --clang 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 f21b569f887..431ba110344 100644 --- a/cpp/ql/test/library-tests/ir/ir/raw_ir.expected +++ b/cpp/ql/test/library-tests/ir/ir/raw_ir.expected @@ -19125,28 +19125,51 @@ ir.cpp: # 2867| r2867_2(glval) = VariableAddress[b] : # 2867| r2867_3(bool) = Load[b] : &:r2867_2, ~m? # 2867| v2867_4(void) = ConditionalBranch : r2867_3 -#-----| False -> Block 3 -#-----| True -> Block 2 +#-----| False -> Block 5 +#-----| True -> Block 4 -# 2867| Block 1 -# 2867| r2867_5(glval) = VariableAddress[#temp2867:13] : -# 2867| r2867_6(int) = Load[#temp2867:13] : &:r2867_5, ~m? -# 2867| mu2867_7(int) = Store[z] : &:r2867_1, r2867_6 -# 2868| v2868_1(void) = NoOp : -# 2865| v2865_10(void) = ReturnVoid : -# 2865| v2865_11(void) = AliasedUse : ~m? -# 2865| v2865_12(void) = ExitFunction : +# 2865| Block 1 +# 2865| v2865_10(void) = AliasedUse : ~m? +# 2865| v2865_11(void) = ExitFunction : -# 2867| Block 2 -# 2867| r2867_8(int) = Constant[0] : -# 2867| r2867_9(glval) = VariableAddress[#temp2867:13] : -# 2867| mu2867_10(int) = Store[#temp2867:13] : &:r2867_9, r2867_8 +# 2865| Block 2 +# 2865| v2865_12(void) = Unwind : #-----| Goto -> Block 1 # 2867| Block 3 +# 2867| r2867_5(glval) = VariableAddress[#temp2867:13] : +# 2867| r2867_6(int) = Load[#temp2867:13] : &:r2867_5, ~m? +# 2867| mu2867_7(int) = Store[z] : &:r2867_1, r2867_6 +# 2870| r2870_1(glval) = VariableAddress[#throw2870:9] : +# 2870| r2870_2(int) = Constant[41] : +# 2870| mu2870_3(int) = Store[#throw2870:9] : &:r2870_1, r2870_2 +# 2870| v2870_4(void) = ThrowValue : &:r2870_1, ~m? +#-----| C++ Exception -> Block 6 + +# 2867| Block 4 +# 2867| r2867_8(int) = Constant[0] : +# 2867| r2867_9(glval) = VariableAddress[#temp2867:13] : +# 2867| mu2867_10(int) = Store[#temp2867:13] : &:r2867_9, r2867_8 +#-----| Goto -> Block 3 + +# 2867| Block 5 # 2867| r2867_11(int) = Constant[1] : # 2867| r2867_12(glval) = VariableAddress[#temp2867:13] : # 2867| mu2867_13(int) = Store[#temp2867:13] : &:r2867_12, r2867_11 +#-----| Goto -> Block 3 + +# 2871| Block 6 +# 2871| v2871_1(void) = CatchByType[int] : +#-----| C++ Exception -> Block 2 +#-----| Goto -> Block 7 + +# 2871| Block 7 +# 2871| r2871_2(glval) = VariableAddress[c] : +# 2871| mu2871_3(int) = InitializeParameter[c] : &:r2871_2 +# 2872| r2872_1(int) = Constant[0] : +# 2872| v2872_2(void) = Convert : r2872_1 +# 2874| v2874_1(void) = NoOp : +# 2865| v2865_13(void) = ReturnVoid : #-----| Goto -> Block 1 ir23.cpp: