[PATCH] D100247: [TableGen] Fix bug in recent change to ListInit::convertInitListSlice()
Paul C. Anagnostopoulos via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 12 06:45:21 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG489cdedd117b: [TableGen] Fix bug in recent change to ListInit::convertInitListSlice() (authored by Paul-C-Anagnostopoulos).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D100247/new/
https://reviews.llvm.org/D100247
Files:
llvm/lib/TableGen/Record.cpp
llvm/test/TableGen/ListSlices.td
Index: llvm/test/TableGen/ListSlices.td
===================================================================
--- llvm/test/TableGen/ListSlices.td
+++ llvm/test/TableGen/ListSlices.td
@@ -9,14 +9,14 @@
// CHECK: list<int> ShowVar1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
// CHECK: int ShowVar2 = 0
// CHECK: list<int> ShowVar3 = [2, 3, 4, 5]
-// CHECK: int ShowVar4 = 0
+// CHECK: int ShowVar4 = 2
// CHECK: list<int> ShowVar5 = [2, 3, 4, 5]
defvar Var1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
defvar Var2 = Var1[0];
defvar Var3 = Var1[2...5];
-defvar Var4 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9][0];
+defvar Var4 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9][2];
defvar Var5 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9][2...5];
def Rec00 { // Display the defvars.
@@ -96,12 +96,30 @@
// CHECK: def Rec08
// CHECK: list<list<string>> Array = {{.*}}"foo", "bar", "snork"], ["zoo", "quux", "flarp"]]
-// CHECK: string Snork = "snork"
+// CHECK: string Flarp = "flarp"
// CHECK: list<string> ZooQuux = ["zoo", "quux"]
def Rec08 {
list<list<string>> Array = [["foo", "bar", "snork"],
["zoo", "quux", "flarp"]];
- string Snork = Array[0][2];
+ string Flarp = Array[1][2];
list<string> ZooQuux = Array[1][0...1];
}
+
+// Test uninitialized list elements.
+
+// CHECK: def Rec09
+// CHECK: int Zero = ?;
+// CHECK: list<int> TwoFive = [2, 3, ?, 5];
+// CHECK: def Rec10
+// CHECK: list<int> TwoFive = [2, 3, ?, 5];
+
+def Rec09 : Class1<[?, ?, 2, 3, ?, 5, ?]>;
+
+def Rec10 {
+ int Zero = Class1<[?, ?, 2, 3, ?, 5, ?]>.Zero;
+ list<int> TwoFive = Class1<[?, ?, 2, 3, ?, 5, ?]>.TwoFive;
+}
+
+// TO-DO: Notice that the first field in Rec10 is not checked.
+// It is not fully resolved for reasons that need to be investigated.
Index: llvm/lib/TableGen/Record.cpp
===================================================================
--- llvm/lib/TableGen/Record.cpp
+++ llvm/lib/TableGen/Record.cpp
@@ -615,8 +615,11 @@
}
Init *ListInit::convertInitListSlice(ArrayRef<unsigned> Elements) const {
- if (Elements.size() == 1)
- return getElement(0);
+ if (Elements.size() == 1) {
+ if (Elements[0] >= size())
+ return nullptr;
+ return getElement(Elements[0]);
+ }
SmallVector<Init*, 8> Vals;
Vals.reserve(Elements.size());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100247.336822.patch
Type: text/x-patch
Size: 2286 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210412/48b24616/attachment.bin>
More information about the llvm-commits
mailing list