diff --git a/cpp/ql/test/library-tests/ir/ir/PrintAST.expected b/cpp/ql/test/library-tests/ir/ir/PrintAST.expected index 3f4a29c59c6..171d83e2f78 100644 --- a/cpp/ql/test/library-tests/ir/ir/PrintAST.expected +++ b/cpp/ql/test/library-tests/ir/ir/PrintAST.expected @@ -1728,6 +1728,76 @@ complex.c: # 144| Type = [LongDoubleType] long double # 144| ValueCategory = prvalue # 145| getStmt(72): [ReturnStmt] return ... +ir.c: +# 5| [TopLevelFunction] int getX(MyCoords*) +# 5| : +# 5| getParameter(0): [Parameter] coords +# 5| Type = [PointerType] MyCoords * +# 7| [TopLevelFunction] void MyCoordsTest(int) +# 7| : +# 7| getParameter(0): [Parameter] pos +# 7| Type = [IntType] int +# 7| getEntryPoint(): [BlockStmt] { ... } +# 8| getStmt(0): [DeclStmt] declaration +# 8| getDeclarationEntry(0): [VariableDeclarationEntry] definition of coords +# 8| Type = [CTypedefType] MyCoords +# 8| getVariable().getInitializer(): [Initializer] initializer for coords +# 8| getExpr(): [ClassAggregateLiteral] {...} +# 8| Type = [Struct] (unnamed class/struct/union) +# 8| ValueCategory = prvalue +# 8| getAFieldExpr(x): [Literal] 0 +# 8| Type = [IntType] int +# 8| Value = [Literal] 0 +# 8| ValueCategory = prvalue +# 9| getStmt(1): [ExprStmt] ExprStmt +# 9| getExpr(): [AssignExpr] ... = ... +# 9| Type = [IntType] int +# 9| ValueCategory = prvalue +# 9| getLValue(): [ValueFieldAccess] x +# 9| Type = [IntType] int +# 9| ValueCategory = lvalue +# 9| getQualifier(): [VariableAccess] coords +# 9| Type = [CTypedefType] MyCoords +# 9| ValueCategory = lvalue +# 9| getRValue(): [AssignExpr] ... = ... +# 9| Type = [IntType] int +# 9| ValueCategory = prvalue +# 9| getLValue(): [ValueFieldAccess] y +# 9| Type = [IntType] int +# 9| ValueCategory = lvalue +# 9| getQualifier(): [VariableAccess] coords +# 9| Type = [CTypedefType] MyCoords +# 9| ValueCategory = lvalue +# 9| getRValue(): [AddExpr] ... + ... +# 9| Type = [IntType] int +# 9| ValueCategory = prvalue +# 9| getLeftOperand(): [VariableAccess] pos +# 9| Type = [IntType] int +# 9| ValueCategory = prvalue(load) +# 9| getRightOperand(): [Literal] 1 +# 9| Type = [IntType] int +# 9| Value = [Literal] 1 +# 9| ValueCategory = prvalue +# 10| getStmt(2): [ExprStmt] ExprStmt +# 10| getExpr(): [AssignExpr] ... = ... +# 10| Type = [IntType] int +# 10| ValueCategory = prvalue +# 10| getLValue(): [ValueFieldAccess] x +# 10| Type = [IntType] int +# 10| ValueCategory = lvalue +# 10| getQualifier(): [VariableAccess] coords +# 10| Type = [CTypedefType] MyCoords +# 10| ValueCategory = lvalue +# 10| getRValue(): [FunctionCall] call to getX +# 10| Type = [IntType] int +# 10| ValueCategory = prvalue +# 10| getArgument(0): [AddressOfExpr] & ... +# 10| Type = [PointerType] MyCoords * +# 10| ValueCategory = prvalue +# 10| getOperand(): [VariableAccess] coords +# 10| Type = [CTypedefType] MyCoords +# 10| ValueCategory = lvalue +# 11| getStmt(3): [ReturnStmt] return ... ir.cpp: # 1| [TopLevelFunction] void Constants() # 1| : diff --git a/cpp/ql/test/library-tests/ir/ir/ir.c b/cpp/ql/test/library-tests/ir/ir/ir.c new file mode 100644 index 00000000000..c162abc2715 --- /dev/null +++ b/cpp/ql/test/library-tests/ir/ir/ir.c @@ -0,0 +1,11 @@ +typedef struct { + int x, y; +} MyCoords; + +int getX(MyCoords *coords); + +void MyCoordsTest(int pos) { + MyCoords coords = {0}; + coords.x = coords.y = pos + 1; + coords.x = getX(&coords); +} 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 8ef33ff286d..c39aba7374b 100644 --- a/cpp/ql/test/library-tests/ir/ir/operand_locations.expected +++ b/cpp/ql/test/library-tests/ir/ir/operand_locations.expected @@ -932,6 +932,52 @@ | file://:0:0:0:0 | Unary | r0_20 | | file://:0:0:0:0 | Unary | r0_21 | | file://:0:0:0:0 | Unary | r0_21 | +| ir.c:7:6:7:17 | ChiPartial | partial:m7_3 | +| ir.c:7:6:7:17 | ChiTotal | total:m7_2 | +| ir.c:7:6:7:17 | SideEffect | ~m10_6 | +| ir.c:7:23:7:25 | Address | &:r7_5 | +| ir.c:8:12:8:17 | Address | &:r8_1 | +| ir.c:8:12:8:17 | Unary | r8_1 | +| ir.c:8:12:8:17 | Unary | r8_1 | +| ir.c:8:20:8:23 | Address | &:r8_3 | +| ir.c:8:20:8:23 | Address | &:r8_7 | +| ir.c:8:20:8:23 | ChiPartial | partial:m8_9 | +| ir.c:8:20:8:23 | ChiTotal | total:m8_6 | +| ir.c:8:20:8:23 | StoreValue | r8_8 | +| ir.c:8:22:8:22 | ChiPartial | partial:m8_5 | +| ir.c:8:22:8:22 | ChiTotal | total:m8_2 | +| ir.c:8:22:8:22 | StoreValue | r8_4 | +| ir.c:9:3:9:8 | Unary | r9_10 | +| ir.c:9:3:9:31 | ChiPartial | partial:m9_12 | +| ir.c:9:3:9:31 | ChiTotal | total:m9_8 | +| ir.c:9:10:9:10 | Address | &:r9_11 | +| ir.c:9:14:9:19 | Unary | r9_5 | +| ir.c:9:14:9:31 | ChiPartial | partial:m9_7 | +| ir.c:9:14:9:31 | ChiTotal | total:m8_10 | +| ir.c:9:14:9:31 | StoreValue | r9_9 | +| ir.c:9:21:9:21 | Address | &:r9_6 | +| ir.c:9:25:9:27 | Address | &:r9_1 | +| ir.c:9:25:9:27 | Left | r9_2 | +| ir.c:9:25:9:27 | Load | m7_6 | +| ir.c:9:25:9:31 | StoreValue | r9_4 | +| ir.c:9:25:9:31 | Unary | r9_4 | +| ir.c:9:31:9:31 | Right | r9_3 | +| ir.c:10:3:10:8 | Unary | r10_10 | +| ir.c:10:3:10:26 | ChiPartial | partial:m10_12 | +| ir.c:10:3:10:26 | ChiTotal | total:m10_9 | +| ir.c:10:10:10:10 | Address | &:r10_11 | +| ir.c:10:14:10:17 | CallTarget | func:r10_1 | +| ir.c:10:14:10:17 | ChiPartial | partial:m10_5 | +| ir.c:10:14:10:17 | ChiTotal | total:m7_4 | +| ir.c:10:14:10:17 | SideEffect | ~m7_4 | +| ir.c:10:14:10:17 | StoreValue | r10_4 | +| ir.c:10:19:10:25 | Address | &:r10_3 | +| ir.c:10:19:10:25 | Address | &:r10_3 | +| ir.c:10:19:10:25 | Arg(0) | 0:r10_3 | +| ir.c:10:19:10:25 | ChiPartial | partial:m10_8 | +| ir.c:10:19:10:25 | ChiTotal | total:m9_13 | +| ir.c:10:19:10:25 | SideEffect | ~m9_13 | +| ir.c:10:20:10:25 | Unary | r10_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_ir.expected b/cpp/ql/test/library-tests/ir/ir/raw_ir.expected index bd3d387c5bb..4b79cdf2eba 100644 --- a/cpp/ql/test/library-tests/ir/ir/raw_ir.expected +++ b/cpp/ql/test/library-tests/ir/ir/raw_ir.expected @@ -724,6 +724,48 @@ complex.c: # 58| v58_5(void) = AliasedUse : ~m? # 58| v58_6(void) = ExitFunction : +ir.c: +# 7| void MyCoordsTest(int) +# 7| Block 0 +# 7| v7_1(void) = EnterFunction : +# 7| mu7_2(unknown) = AliasedDefinition : +# 7| mu7_3(unknown) = InitializeNonLocal : +# 7| r7_4(glval) = VariableAddress[pos] : +# 7| mu7_5(int) = InitializeParameter[pos] : &:r7_4 +# 8| r8_1(glval<(unnamed class/struct/union)>) = VariableAddress[coords] : +# 8| mu8_2((unnamed class/struct/union)) = Uninitialized[coords] : &:r8_1 +# 8| r8_3(glval) = FieldAddress[x] : r8_1 +# 8| r8_4(int) = Constant[0] : +# 8| mu8_5(int) = Store[?] : &:r8_3, r8_4 +# 8| r8_6(glval) = FieldAddress[y] : r8_1 +# 8| r8_7(int) = Constant[0] : +# 8| mu8_8(int) = Store[?] : &:r8_6, r8_7 +# 9| r9_1(glval) = VariableAddress[pos] : +# 9| r9_2(int) = Load[pos] : &:r9_1, ~m? +# 9| r9_3(int) = Constant[1] : +# 9| r9_4(int) = Add : r9_2, r9_3 +# 9| r9_5(glval<(unnamed class/struct/union)>) = VariableAddress[coords] : +# 9| r9_6(glval) = FieldAddress[y] : r9_5 +# 9| mu9_7(int) = Store[?] : &:r9_6, r9_4 +# 9| r9_8(int) = CopyValue : r9_4 +# 9| r9_9(glval<(unnamed class/struct/union)>) = VariableAddress[coords] : +# 9| r9_10(glval) = FieldAddress[x] : r9_9 +# 9| mu9_11(int) = Store[?] : &:r9_10, r9_8 +# 10| r10_1(glval) = FunctionAddress[getX] : +# 10| r10_2(glval<(unnamed class/struct/union)>) = VariableAddress[coords] : +# 10| r10_3(struct *) = CopyValue : r10_2 +# 10| r10_4(int) = Call[getX] : func:r10_1, 0:r10_3 +# 10| mu10_5(unknown) = ^CallSideEffect : ~m? +# 10| v10_6(void) = ^BufferReadSideEffect[0] : &:r10_3, ~m? +# 10| mu10_7(unknown) = ^BufferMayWriteSideEffect[0] : &:r10_3 +# 10| r10_8(glval<(unnamed class/struct/union)>) = VariableAddress[coords] : +# 10| r10_9(glval) = FieldAddress[x] : r10_8 +# 10| mu10_10(int) = Store[?] : &:r10_9, r10_4 +# 11| v11_1(void) = NoOp : +# 7| v7_6(void) = ReturnVoid : +# 7| v7_7(void) = AliasedUse : ~m? +# 7| v7_8(void) = ExitFunction : + ir.cpp: # 1| void Constants() # 1| Block 0