diff --git a/cpp/ql/test/library-tests/ir/ir/PrintAST.expected b/cpp/ql/test/library-tests/ir/ir/PrintAST.expected index e42cacb8c64..ba76826993d 100644 --- a/cpp/ql/test/library-tests/ir/ir/PrintAST.expected +++ b/cpp/ql/test/library-tests/ir/ir/PrintAST.expected @@ -15463,6 +15463,79 @@ ir.cpp: # 2021| Type = [Struct] TernaryNonPodObj # 2021| ValueCategory = lvalue # 2022| getStmt(4): [ReturnStmt] return ... +# 2024| [TopLevelFunction] void CommaTestHelper(unsigned int) +# 2024| : +# 2024| getParameter(0): [Parameter] (unnamed parameter 0) +# 2024| Type = [IntType] unsigned int +# 2026| [TopLevelFunction] unsigned int CommaTest(unsigned int) +# 2026| : +# 2026| getParameter(0): [Parameter] x +# 2026| Type = [IntType] unsigned int +# 2026| getEntryPoint(): [BlockStmt] { ... } +# 2027| getStmt(0): [DeclStmt] declaration +# 2027| getDeclarationEntry(0): [VariableDeclarationEntry] definition of y +# 2027| Type = [IntType] unsigned int +# 2028| getStmt(1): [ExprStmt] ExprStmt +# 2028| getExpr(): [AssignExpr] ... = ... +# 2028| Type = [IntType] unsigned int +# 2028| ValueCategory = lvalue +# 2028| getLValue(): [VariableAccess] y +# 2028| Type = [IntType] unsigned int +# 2028| ValueCategory = lvalue +# 2028| getRValue(): [ConditionalExpr] ... ? ... : ... +# 2028| Type = [IntType] unsigned int +# 2028| ValueCategory = prvalue +# 2028| getCondition(): [LTExpr] ... < ... +# 2028| Type = [BoolType] bool +# 2028| ValueCategory = prvalue +# 2028| getLesserOperand(): [VariableAccess] x +# 2028| Type = [IntType] unsigned int +# 2028| ValueCategory = prvalue(load) +# 2028| getGreaterOperand(): [Literal] 100 +# 2028| Type = [IntType] int +# 2028| Value = [Literal] 100 +# 2028| ValueCategory = prvalue +# 2028| getGreaterOperand().getFullyConverted(): [CStyleCast] (unsigned int)... +# 2028| Conversion = [IntegralConversion] integral conversion +# 2028| Type = [IntType] unsigned int +# 2028| Value = [CStyleCast] 100 +# 2028| ValueCategory = prvalue +# 2029| getThen(): [CommaExpr] ... , ... +# 2029| Type = [IntType] unsigned int +# 2029| ValueCategory = prvalue +# 2029| getLeftOperand(): [FunctionCall] call to CommaTestHelper +# 2029| Type = [VoidType] void +# 2029| ValueCategory = prvalue +# 2029| getArgument(0): [VariableAccess] x +# 2029| Type = [IntType] unsigned int +# 2029| ValueCategory = prvalue(load) +# 2029| getRightOperand(): [VariableAccess] x +# 2029| Type = [IntType] unsigned int +# 2029| ValueCategory = prvalue(load) +# 2030| getElse(): [CommaExpr] ... , ... +# 2030| Type = [IntType] int +# 2030| ValueCategory = prvalue +# 2030| getLeftOperand(): [FunctionCall] call to CommaTestHelper +# 2030| Type = [VoidType] void +# 2030| ValueCategory = prvalue +# 2030| getArgument(0): [VariableAccess] x +# 2030| Type = [IntType] unsigned int +# 2030| ValueCategory = prvalue(load) +# 2030| getRightOperand(): [Literal] 10 +# 2030| Type = [IntType] int +# 2030| Value = [Literal] 10 +# 2030| ValueCategory = prvalue +# 2029| getThen().getFullyConverted(): [ParenthesisExpr] (...) +# 2029| Type = [IntType] unsigned int +# 2029| ValueCategory = prvalue +# 2030| getElse().getFullyConverted(): [CStyleCast] (unsigned int)... +# 2030| Conversion = [IntegralConversion] integral conversion +# 2030| Type = [IntType] unsigned int +# 2030| ValueCategory = prvalue +# 2030| getExpr(): [ParenthesisExpr] (...) +# 2030| Type = [IntType] int +# 2030| ValueCategory = prvalue +# 2031| getStmt(2): [ReturnStmt] return ... perf-regression.cpp: # 4| [CopyAssignmentOperator] Big& Big::operator=(Big const&) # 4| : diff --git a/cpp/ql/test/library-tests/ir/ir/ir.cpp b/cpp/ql/test/library-tests/ir/ir/ir.cpp index 4568026c7f4..44f88d23166 100644 --- a/cpp/ql/test/library-tests/ir/ir/ir.cpp +++ b/cpp/ql/test/library-tests/ir/ir/ir.cpp @@ -2021,4 +2021,13 @@ void TernaryTestNonPodObj(bool a, TernaryNonPodObj x, TernaryNonPodObj y, Ternar (z = a ? x : y) = TernaryNonPodObj(); } +void CommaTestHelper(unsigned int); + +unsigned int CommaTest(unsigned int x) { + unsigned int y; + y = x < 100 ? + (CommaTestHelper(x), x) : + (CommaTestHelper(x), 10); +} + // semmle-extractor-options: -std=c++17 --clang 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 abab4fd099b..96698243672 100644 --- a/cpp/ql/test/library-tests/ir/ir/operand_locations.expected +++ b/cpp/ql/test/library-tests/ir/ir/operand_locations.expected @@ -9524,6 +9524,44 @@ | ir.cpp:2021:23:2021:40 | SideEffect | ~m2021_27 | | ir.cpp:2021:23:2021:40 | Unary | r2021_20 | | ir.cpp:2021:23:2021:40 | Unary | r2021_28 | +| ir.cpp:2026:14:2026:22 | ChiPartial | partial:m2026_3 | +| ir.cpp:2026:14:2026:22 | ChiTotal | total:m2026_2 | +| ir.cpp:2026:37:2026:37 | Address | &:r2026_5 | +| ir.cpp:2027:16:2027:16 | Address | &:r2027_1 | +| ir.cpp:2028:3:2028:3 | Address | &:r2028_9 | +| ir.cpp:2028:7:2028:7 | Address | &:r2028_1 | +| ir.cpp:2028:7:2028:7 | Left | r2028_2 | +| ir.cpp:2028:7:2028:7 | Load | m2026_6 | +| ir.cpp:2028:7:2028:13 | Condition | r2028_4 | +| ir.cpp:2028:7:2030:28 | Address | &:r2028_7 | +| ir.cpp:2028:7:2030:28 | Address | &:r2028_11 | +| ir.cpp:2028:7:2030:28 | Address | &:r2028_13 | +| ir.cpp:2028:7:2030:28 | Load | m2028_6 | +| ir.cpp:2028:7:2030:28 | Phi | from 2:m2028_12 | +| ir.cpp:2028:7:2030:28 | Phi | from 3:m2028_14 | +| ir.cpp:2028:7:2030:28 | StoreValue | r2028_8 | +| ir.cpp:2028:11:2028:13 | Right | r2028_3 | +| ir.cpp:2029:6:2029:20 | CallTarget | func:r2029_1 | +| ir.cpp:2029:6:2029:20 | ChiPartial | partial:m2029_5 | +| ir.cpp:2029:6:2029:20 | ChiTotal | total:m2026_4 | +| ir.cpp:2029:6:2029:20 | SideEffect | ~m2026_4 | +| ir.cpp:2029:6:2029:26 | StoreValue | r2029_9 | +| ir.cpp:2029:22:2029:22 | Address | &:r2029_2 | +| ir.cpp:2029:22:2029:22 | Arg(0) | 0:r2029_3 | +| ir.cpp:2029:22:2029:22 | Load | m2026_6 | +| ir.cpp:2029:26:2029:26 | Address | &:r2029_7 | +| ir.cpp:2029:26:2029:26 | Load | m2026_6 | +| ir.cpp:2029:26:2029:26 | Unary | r2029_8 | +| ir.cpp:2030:5:2030:28 | StoreValue | r2030_9 | +| ir.cpp:2030:6:2030:20 | CallTarget | func:r2030_1 | +| ir.cpp:2030:6:2030:20 | ChiPartial | partial:m2030_5 | +| ir.cpp:2030:6:2030:20 | ChiTotal | total:m2026_4 | +| ir.cpp:2030:6:2030:20 | SideEffect | ~m2026_4 | +| ir.cpp:2030:6:2030:27 | Unary | r2030_8 | +| ir.cpp:2030:22:2030:22 | Address | &:r2030_2 | +| ir.cpp:2030:22:2030:22 | Arg(0) | 0:r2030_3 | +| ir.cpp:2030:22:2030:22 | Load | m2026_6 | +| ir.cpp:2030:26:2030:27 | Unary | r2030_7 | | perf-regression.cpp:6:3:6:5 | Address | &:r6_5 | | perf-regression.cpp:6:3:6:5 | Address | &:r6_5 | | perf-regression.cpp:6:3:6:5 | Address | &:r6_7 | 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 e4f3b9d743e..79dd36ed029 100644 --- a/cpp/ql/test/library-tests/ir/ir/raw_ir.expected +++ b/cpp/ql/test/library-tests/ir/ir/raw_ir.expected @@ -11015,6 +11015,62 @@ ir.cpp: # 2021| mu2021_36(glval) = Store[#temp2021:10] : &:r2021_35, r2021_34 #-----| Goto -> Block 10 +# 2026| unsigned int CommaTest(unsigned int) +# 2026| Block 0 +# 2026| v2026_1(void) = EnterFunction : +# 2026| mu2026_2(unknown) = AliasedDefinition : +# 2026| mu2026_3(unknown) = InitializeNonLocal : +# 2026| r2026_4(glval) = VariableAddress[x] : +# 2026| mu2026_5(unsigned int) = InitializeParameter[x] : &:r2026_4 +# 2027| r2027_1(glval) = VariableAddress[y] : +# 2027| mu2027_2(unsigned int) = Uninitialized[y] : &:r2027_1 +# 2028| r2028_1(glval) = VariableAddress[x] : +# 2028| r2028_2(unsigned int) = Load[x] : &:r2028_1, ~m? +# 2028| r2028_3(unsigned int) = Constant[100] : +# 2028| r2028_4(bool) = CompareLT : r2028_2, r2028_3 +# 2028| v2028_5(void) = ConditionalBranch : r2028_4 +#-----| False -> Block 4 +#-----| True -> Block 3 + +# 2026| Block 1 +# 2026| r2026_6(glval) = VariableAddress[#return] : +# 2026| v2026_7(void) = ReturnValue : &:r2026_6, ~m? +# 2026| v2026_8(void) = AliasedUse : ~m? +# 2026| v2026_9(void) = ExitFunction : + +# 2028| Block 2 +# 2028| r2028_6(glval) = VariableAddress[#temp2028:7] : +# 2028| r2028_7(unsigned int) = Load[#temp2028:7] : &:r2028_6, ~m? +# 2028| r2028_8(glval) = VariableAddress[y] : +# 2028| mu2028_9(unsigned int) = Store[y] : &:r2028_8, r2028_7 +# 2031| v2031_1(void) = Unreached : + +# 2029| Block 3 +# 2029| r2029_1(glval) = FunctionAddress[CommaTestHelper] : +# 2029| r2029_2(glval) = VariableAddress[x] : +# 2029| r2029_3(unsigned int) = Load[x] : &:r2029_2, ~m? +# 2029| v2029_4(void) = Call[CommaTestHelper] : func:r2029_1, 0:r2029_3 +# 2029| mu2029_5(unknown) = ^CallSideEffect : ~m? +# 2029| r2029_6(glval) = VariableAddress[x] : +# 2029| r2029_7(unsigned int) = Load[x] : &:r2029_6, ~m? +# 2029| r2029_8(unsigned int) = CopyValue : r2029_7 +# 2028| r2028_10(glval) = VariableAddress[#temp2028:7] : +# 2028| mu2028_11(unsigned int) = Store[#temp2028:7] : &:r2028_10, r2029_8 +#-----| Goto -> Block 2 + +# 2030| Block 4 +# 2030| r2030_1(glval) = FunctionAddress[CommaTestHelper] : +# 2030| r2030_2(glval) = VariableAddress[x] : +# 2030| r2030_3(unsigned int) = Load[x] : &:r2030_2, ~m? +# 2030| v2030_4(void) = Call[CommaTestHelper] : func:r2030_1, 0:r2030_3 +# 2030| mu2030_5(unknown) = ^CallSideEffect : ~m? +# 2030| r2030_6(int) = Constant[10] : +# 2030| r2030_7(int) = CopyValue : r2030_6 +# 2030| r2030_8(unsigned int) = Convert : r2030_7 +# 2028| r2028_12(glval) = VariableAddress[#temp2028:7] : +# 2028| mu2028_13(unsigned int) = Store[#temp2028:7] : &:r2028_12, r2030_8 +#-----| Goto -> Block 2 + perf-regression.cpp: # 6| void Big::Big() # 6| Block 0