Skip to content

Commit 3fe99dc

Browse files
authored
Merge pull request github#13704 from jketema/ir-test
C++: Add assignment operation IR test where the result is being used
2 parents b70e21d + de3251a commit 3fe99dc

File tree

4 files changed

+75
-0
lines changed

4 files changed

+75
-0
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14562,6 +14562,40 @@ ir.cpp:
1456214562
# 1930| Value = [Literal] 40
1456314563
# 1930| ValueCategory = prvalue
1456414564
# 1931| getStmt(2): [ReturnStmt] return ...
14565+
# 1933| [TopLevelFunction] void test_assign_with_assign_operation()
14566+
# 1933| <params>:
14567+
# 1933| getEntryPoint(): [BlockStmt] { ... }
14568+
# 1934| getStmt(0): [DeclStmt] declaration
14569+
# 1934| getDeclarationEntry(0): [VariableDeclarationEntry] definition of i
14570+
# 1934| Type = [IntType] int
14571+
# 1934| getDeclarationEntry(1): [VariableDeclarationEntry] definition of j
14572+
# 1934| Type = [IntType] int
14573+
# 1934| getVariable().getInitializer(): [Initializer] initializer for j
14574+
# 1934| getExpr(): [Literal] 0
14575+
# 1934| Type = [IntType] int
14576+
# 1934| Value = [Literal] 0
14577+
# 1934| ValueCategory = prvalue
14578+
# 1935| getStmt(1): [ExprStmt] ExprStmt
14579+
# 1935| getExpr(): [AssignExpr] ... = ...
14580+
# 1935| Type = [IntType] int
14581+
# 1935| ValueCategory = lvalue
14582+
# 1935| getLValue(): [VariableAccess] i
14583+
# 1935| Type = [IntType] int
14584+
# 1935| ValueCategory = lvalue
14585+
# 1935| getRValue(): [AssignAddExpr] ... += ...
14586+
# 1935| Type = [IntType] int
14587+
# 1935| ValueCategory = prvalue
14588+
# 1935| getLValue(): [VariableAccess] j
14589+
# 1935| Type = [IntType] int
14590+
# 1935| ValueCategory = lvalue
14591+
# 1935| getRValue(): [Literal] 40
14592+
# 1935| Type = [IntType] int
14593+
# 1935| Value = [Literal] 40
14594+
# 1935| ValueCategory = prvalue
14595+
# 1935| getRValue().getFullyConverted(): [ParenthesisExpr] (...)
14596+
# 1935| Type = [IntType] int
14597+
# 1935| ValueCategory = prvalue
14598+
# 1936| getStmt(2): [ReturnStmt] return ...
1456514599
perf-regression.cpp:
1456614600
# 4| [CopyAssignmentOperator] Big& Big::operator=(Big const&)
1456714601
# 4| <params>:

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,4 +1930,9 @@ void test_double_assign() {
19301930
i = j = 40;
19311931
}
19321932

1933+
void test_assign_with_assign_operation() {
1934+
int i, j = 0;
1935+
i = (j += 40);
1936+
}
1937+
19331938
// semmle-extractor-options: -std=c++17 --clang

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8877,6 +8877,20 @@
88778877
| ir.cpp:1930:7:1930:12 | StoreValue | r1930_4 |
88788878
| ir.cpp:1930:11:1930:12 | StoreValue | r1930_1 |
88798879
| ir.cpp:1930:11:1930:12 | Unary | r1930_1 |
8880+
| ir.cpp:1933:6:1933:38 | ChiPartial | partial:m1933_3 |
8881+
| ir.cpp:1933:6:1933:38 | ChiTotal | total:m1933_2 |
8882+
| ir.cpp:1933:6:1933:38 | SideEffect | m1933_3 |
8883+
| ir.cpp:1934:7:1934:7 | Address | &:r1934_1 |
8884+
| ir.cpp:1934:10:1934:10 | Address | &:r1934_3 |
8885+
| ir.cpp:1934:13:1934:14 | StoreValue | r1934_4 |
8886+
| ir.cpp:1935:3:1935:3 | Address | &:r1935_6 |
8887+
| ir.cpp:1935:8:1935:8 | Address | &:r1935_2 |
8888+
| ir.cpp:1935:8:1935:8 | Address | &:r1935_2 |
8889+
| ir.cpp:1935:8:1935:8 | Left | r1935_3 |
8890+
| ir.cpp:1935:8:1935:8 | Load | m1934_5 |
8891+
| ir.cpp:1935:8:1935:14 | StoreValue | r1935_4 |
8892+
| ir.cpp:1935:8:1935:14 | StoreValue | r1935_4 |
8893+
| ir.cpp:1935:13:1935:14 | Right | r1935_1 |
88808894
| perf-regression.cpp:6:3:6:5 | Address | &:r6_5 |
88818895
| perf-regression.cpp:6:3:6:5 | Address | &:r6_5 |
88828896
| perf-regression.cpp:6:3:6:5 | Address | &:r6_7 |

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10244,6 +10244,28 @@ ir.cpp:
1024410244
# 1928| v1928_5(void) = AliasedUse : ~m?
1024510245
# 1928| v1928_6(void) = ExitFunction :
1024610246

10247+
# 1933| void test_assign_with_assign_operation()
10248+
# 1933| Block 0
10249+
# 1933| v1933_1(void) = EnterFunction :
10250+
# 1933| mu1933_2(unknown) = AliasedDefinition :
10251+
# 1933| mu1933_3(unknown) = InitializeNonLocal :
10252+
# 1934| r1934_1(glval<int>) = VariableAddress[i] :
10253+
# 1934| mu1934_2(int) = Uninitialized[i] : &:r1934_1
10254+
# 1934| r1934_3(glval<int>) = VariableAddress[j] :
10255+
# 1934| r1934_4(int) = Constant[0] :
10256+
# 1934| mu1934_5(int) = Store[j] : &:r1934_3, r1934_4
10257+
# 1935| r1935_1(int) = Constant[40] :
10258+
# 1935| r1935_2(glval<int>) = VariableAddress[j] :
10259+
# 1935| r1935_3(int) = Load[j] : &:r1935_2, ~m?
10260+
# 1935| r1935_4(int) = Add : r1935_3, r1935_1
10261+
# 1935| mu1935_5(int) = Store[j] : &:r1935_2, r1935_4
10262+
# 1935| r1935_6(glval<int>) = VariableAddress[i] :
10263+
# 1935| mu1935_7(int) = Store[i] : &:r1935_6, r1935_4
10264+
# 1936| v1936_1(void) = NoOp :
10265+
# 1933| v1933_4(void) = ReturnVoid :
10266+
# 1933| v1933_5(void) = AliasedUse : ~m?
10267+
# 1933| v1933_6(void) = ExitFunction :
10268+
1024710269
perf-regression.cpp:
1024810270
# 6| void Big::Big()
1024910271
# 6| Block 0

0 commit comments

Comments
 (0)