[PATCH] D100253: [TableGen] Resolve concrete but not complete field access initializers
Daniel Sanders via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 13 15:15:28 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbe50657c6ac5: [TableGen] Resolve concrete but not complete field access initializers (authored by dsanders).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D100253/new/
https://reviews.llvm.org/D100253
Files:
llvm/include/llvm/TableGen/Record.h
llvm/lib/TableGen/Record.cpp
llvm/test/TableGen/ListSlices.td
llvm/test/TableGen/field-access-initializers.td
Index: llvm/test/TableGen/field-access-initializers.td
===================================================================
--- llvm/test/TableGen/field-access-initializers.td
+++ llvm/test/TableGen/field-access-initializers.td
@@ -1,6 +1,10 @@
// RUN: llvm-tblgen %s | FileCheck %s
// XFAIL: vg_leak
+// CHECK: class B<A B:impl = ?> {
+// CHECK: string value = B:impl.value;
+// CHECK: }
+
// CHECK: --- Defs ---
// CHECK: def A1 {
@@ -8,7 +12,7 @@
// CHECK: }
// CHECK: def B1 {
-// CHECK: string value = A1.value;
+// CHECK: string value = ?;
// CHECK: }
class A {
Index: llvm/test/TableGen/ListSlices.td
===================================================================
--- llvm/test/TableGen/ListSlices.td
+++ llvm/test/TableGen/ListSlices.td
@@ -111,8 +111,11 @@
// CHECK: def Rec09
// CHECK: int Zero = ?;
// CHECK: list<int> TwoFive = [2, 3, ?, 5];
-// CHECK: def Rec10
-// CHECK: list<int> TwoFive = [2, 3, ?, 5];
+// We need CHECK-NEXT for these because otherwise it will match anonymous defs
+// that appear later.
+// CHECK: def Rec10 {
+// CHECK-NEXT: int Zero = ?;
+// CHECK-NEXT: list<int> TwoFive = [2, 3, ?, 5];
def Rec09 : Class1<[?, ?, 2, 3, ?, 5, ?]>;
@@ -120,6 +123,3 @@
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
@@ -655,6 +655,14 @@
return const_cast<ListInit *>(this);
}
+bool ListInit::isComplete() const {
+ for (Init *Element : *this) {
+ if (!Element->isComplete())
+ return false;
+ }
+ return true;
+}
+
bool ListInit::isConcrete() const {
for (Init *Element : *this) {
if (!Element->isConcrete())
@@ -1924,7 +1932,7 @@
FieldName->getAsUnquotedString() + "' of '" +
Rec->getAsString() + "' is a forbidden self-reference");
Init *FieldVal = Def->getValue(FieldName)->getValue();
- if (FieldVal->isComplete())
+ if (FieldVal->isConcrete())
return FieldVal;
}
return const_cast<FieldInit *>(this);
Index: llvm/include/llvm/TableGen/Record.h
===================================================================
--- llvm/include/llvm/TableGen/Record.h
+++ llvm/include/llvm/TableGen/Record.h
@@ -708,6 +708,7 @@
///
Init *resolveReferences(Resolver &R) const override;
+ bool isComplete() const override;
bool isConcrete() const override;
std::string getAsString() const override;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100253.337268.patch
Type: text/x-patch
Size: 2739 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210413/3761e616/attachment.bin>
More information about the llvm-commits
mailing list