Skip to content

Commit ec05942

Browse files
committed
C++: Use unnamed_local_variable in array structured binding test
1 parent 437a85d commit ec05942

File tree

4 files changed

+49
-33
lines changed

4 files changed

+49
-33
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11503,16 +11503,19 @@ ir.cpp:
1150311503
# 1474| getExpr(): [ArrayExpr] access to array
1150411504
# 1474| Type = [IntType] int
1150511505
# 1474| ValueCategory = lvalue
11506-
# 1474| getArrayBase(): [VariableAccess] xs
11507-
# 1474| Type = [ArrayType] int[2]
11508-
# 1474| ValueCategory = lvalue
11506+
# 1474| getArrayBase(): [VariableAccess] unnamed_local_variable
11507+
# 1474| Type = [LValueReferenceType] int(&)[2]
11508+
# 1474| ValueCategory = prvalue(load)
1150911509
# 1474| getArrayOffset(): [Literal] 0
1151011510
# 1474| Type = [IntType] int
1151111511
# 1474| Value = [Literal] 0
1151211512
# 1474| ValueCategory = prvalue
1151311513
# 1474| getArrayBase().getFullyConverted(): [ArrayToPointerConversion] array to pointer conversion
1151411514
# 1474| Type = [IntPointerType] int *
1151511515
# 1474| ValueCategory = prvalue
11516+
# 1474| getExpr(): [ReferenceDereferenceExpr] (reference dereference)
11517+
# 1474| Type = [ArrayType] int[2]
11518+
# 1474| ValueCategory = lvalue
1151611519
# 1474| getExpr().getFullyConverted(): [ReferenceToExpr] (reference to)
1151711520
# 1474| Type = [LValueReferenceType] int &
1151811521
# 1474| ValueCategory = prvalue
@@ -11523,16 +11526,19 @@ ir.cpp:
1152311526
# 1475| getExpr(): [ArrayExpr] access to array
1152411527
# 1475| Type = [IntType] int
1152511528
# 1475| ValueCategory = lvalue
11526-
# 1475| getArrayBase(): [VariableAccess] xs
11527-
# 1475| Type = [ArrayType] int[2]
11528-
# 1475| ValueCategory = lvalue
11529+
# 1475| getArrayBase(): [VariableAccess] unnamed_local_variable
11530+
# 1475| Type = [LValueReferenceType] int(&)[2]
11531+
# 1475| ValueCategory = prvalue(load)
1152911532
# 1475| getArrayOffset(): [Literal] 1
1153011533
# 1475| Type = [IntType] int
1153111534
# 1475| Value = [Literal] 1
1153211535
# 1475| ValueCategory = prvalue
1153311536
# 1475| getArrayBase().getFullyConverted(): [ArrayToPointerConversion] array to pointer conversion
1153411537
# 1475| Type = [IntPointerType] int *
1153511538
# 1475| ValueCategory = prvalue
11539+
# 1475| getExpr(): [ReferenceDereferenceExpr] (reference dereference)
11540+
# 1475| Type = [ArrayType] int[2]
11541+
# 1475| ValueCategory = lvalue
1153611542
# 1475| getExpr().getFullyConverted(): [ReferenceToExpr] (reference to)
1153711543
# 1475| Type = [LValueReferenceType] int &
1153811544
# 1475| ValueCategory = prvalue

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,8 +1471,8 @@ void array_structured_binding() {
14711471
// explicit reference version
14721472
{
14731473
auto& unnamed_local_variable = xs;
1474-
auto& x0 = xs[0];
1475-
auto& x1 = xs[1];
1474+
auto& x0 = unnamed_local_variable[0];
1475+
auto& x1 = unnamed_local_variable[1];
14761476
x1 = 3;
14771477
int &rx1 = x1;
14781478
int x = x1;

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

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6706,34 +6706,40 @@
67066706
| ir.cpp:1473:40:1473:41 | StoreValue | r1473_3 |
67076707
| ir.cpp:1473:40:1473:41 | Unary | r1473_2 |
67086708
| ir.cpp:1474:15:1474:16 | Address | &:r1474_1 |
6709-
| ir.cpp:1474:20:1474:21 | Left | r1474_3 |
6710-
| ir.cpp:1474:20:1474:21 | Unary | r1474_2 |
6711-
| ir.cpp:1474:20:1474:24 | StoreValue | r1474_6 |
6712-
| ir.cpp:1474:20:1474:24 | Unary | r1474_5 |
6713-
| ir.cpp:1474:23:1474:23 | Right | r1474_4 |
6709+
| ir.cpp:1474:20:1474:41 | Address | &:r1474_2 |
6710+
| ir.cpp:1474:20:1474:41 | Left | r1474_5 |
6711+
| ir.cpp:1474:20:1474:41 | Load | m1473_4 |
6712+
| ir.cpp:1474:20:1474:41 | Unary | r1474_3 |
6713+
| ir.cpp:1474:20:1474:41 | Unary | r1474_4 |
6714+
| ir.cpp:1474:20:1474:44 | StoreValue | r1474_8 |
6715+
| ir.cpp:1474:20:1474:44 | Unary | r1474_7 |
6716+
| ir.cpp:1474:43:1474:43 | Right | r1474_6 |
67146717
| ir.cpp:1475:15:1475:16 | Address | &:r1475_1 |
6715-
| ir.cpp:1475:20:1475:21 | Left | r1475_3 |
6716-
| ir.cpp:1475:20:1475:21 | Unary | r1475_2 |
6717-
| ir.cpp:1475:20:1475:24 | StoreValue | r1475_6 |
6718-
| ir.cpp:1475:20:1475:24 | Unary | r1475_5 |
6719-
| ir.cpp:1475:23:1475:23 | Right | r1475_4 |
6718+
| ir.cpp:1475:20:1475:41 | Address | &:r1475_2 |
6719+
| ir.cpp:1475:20:1475:41 | Left | r1475_5 |
6720+
| ir.cpp:1475:20:1475:41 | Load | m1473_4 |
6721+
| ir.cpp:1475:20:1475:41 | Unary | r1475_3 |
6722+
| ir.cpp:1475:20:1475:41 | Unary | r1475_4 |
6723+
| ir.cpp:1475:20:1475:44 | StoreValue | r1475_8 |
6724+
| ir.cpp:1475:20:1475:44 | Unary | r1475_7 |
6725+
| ir.cpp:1475:43:1475:43 | Right | r1475_6 |
67206726
| ir.cpp:1476:9:1476:10 | Address | &:r1476_2 |
67216727
| ir.cpp:1476:9:1476:10 | Address | &:r1476_4 |
6722-
| ir.cpp:1476:9:1476:10 | Load | m1475_7 |
6728+
| ir.cpp:1476:9:1476:10 | Load | m1475_9 |
67236729
| ir.cpp:1476:9:1476:10 | Unary | r1476_3 |
67246730
| ir.cpp:1476:9:1476:14 | ChiPartial | partial:m1476_5 |
67256731
| ir.cpp:1476:9:1476:14 | ChiTotal | total:m1463_12 |
67266732
| ir.cpp:1476:14:1476:14 | StoreValue | r1476_1 |
67276733
| ir.cpp:1477:14:1477:16 | Address | &:r1477_1 |
67286734
| ir.cpp:1477:20:1477:21 | Address | &:r1477_2 |
6729-
| ir.cpp:1477:20:1477:21 | Load | m1475_7 |
6735+
| ir.cpp:1477:20:1477:21 | Load | m1475_9 |
67306736
| ir.cpp:1477:20:1477:21 | StoreValue | r1477_5 |
67316737
| ir.cpp:1477:20:1477:21 | Unary | r1477_3 |
67326738
| ir.cpp:1477:20:1477:21 | Unary | r1477_4 |
67336739
| ir.cpp:1478:13:1478:13 | Address | &:r1478_1 |
67346740
| ir.cpp:1478:17:1478:18 | Address | &:r1478_2 |
67356741
| ir.cpp:1478:17:1478:18 | Address | &:r1478_3 |
6736-
| ir.cpp:1478:17:1478:18 | Load | m1475_7 |
6742+
| ir.cpp:1478:17:1478:18 | Load | m1475_9 |
67376743
| ir.cpp:1478:17:1478:18 | Load | m1476_5 |
67386744
| ir.cpp:1478:17:1478:18 | StoreValue | r1478_4 |
67396745
| ir.cpp:1482:8:1482:8 | Address | &:r1482_5 |

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

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7947,19 +7947,23 @@ ir.cpp:
79477947
# 1473| r1473_3(int(&)[2]) = CopyValue : r1473_2
79487948
# 1473| mu1473_4(int(&)[2]) = Store[unnamed_local_variable] : &:r1473_1, r1473_3
79497949
# 1474| r1474_1(glval<int &>) = VariableAddress[x0] :
7950-
# 1474| r1474_2(glval<int[2]>) = VariableAddress[xs] :
7951-
# 1474| r1474_3(int *) = Convert : r1474_2
7952-
# 1474| r1474_4(int) = Constant[0] :
7953-
# 1474| r1474_5(glval<int>) = PointerAdd[4] : r1474_3, r1474_4
7954-
# 1474| r1474_6(int &) = CopyValue : r1474_5
7955-
# 1474| mu1474_7(int &) = Store[x0] : &:r1474_1, r1474_6
7950+
# 1474| r1474_2(glval<int(&)[2]>) = VariableAddress[unnamed_local_variable] :
7951+
# 1474| r1474_3(int(&)[2]) = Load[unnamed_local_variable] : &:r1474_2, ~m?
7952+
# 1474| r1474_4(glval<int[2]>) = CopyValue : r1474_3
7953+
# 1474| r1474_5(int *) = Convert : r1474_4
7954+
# 1474| r1474_6(int) = Constant[0] :
7955+
# 1474| r1474_7(glval<int>) = PointerAdd[4] : r1474_5, r1474_6
7956+
# 1474| r1474_8(int &) = CopyValue : r1474_7
7957+
# 1474| mu1474_9(int &) = Store[x0] : &:r1474_1, r1474_8
79567958
# 1475| r1475_1(glval<int &>) = VariableAddress[x1] :
7957-
# 1475| r1475_2(glval<int[2]>) = VariableAddress[xs] :
7958-
# 1475| r1475_3(int *) = Convert : r1475_2
7959-
# 1475| r1475_4(int) = Constant[1] :
7960-
# 1475| r1475_5(glval<int>) = PointerAdd[4] : r1475_3, r1475_4
7961-
# 1475| r1475_6(int &) = CopyValue : r1475_5
7962-
# 1475| mu1475_7(int &) = Store[x1] : &:r1475_1, r1475_6
7959+
# 1475| r1475_2(glval<int(&)[2]>) = VariableAddress[unnamed_local_variable] :
7960+
# 1475| r1475_3(int(&)[2]) = Load[unnamed_local_variable] : &:r1475_2, ~m?
7961+
# 1475| r1475_4(glval<int[2]>) = CopyValue : r1475_3
7962+
# 1475| r1475_5(int *) = Convert : r1475_4
7963+
# 1475| r1475_6(int) = Constant[1] :
7964+
# 1475| r1475_7(glval<int>) = PointerAdd[4] : r1475_5, r1475_6
7965+
# 1475| r1475_8(int &) = CopyValue : r1475_7
7966+
# 1475| mu1475_9(int &) = Store[x1] : &:r1475_1, r1475_8
79637967
# 1476| r1476_1(int) = Constant[3] :
79647968
# 1476| r1476_2(glval<int &>) = VariableAddress[x1] :
79657969
# 1476| r1476_3(int &) = Load[x1] : &:r1476_2, ~m?

0 commit comments

Comments
 (0)