diff --git a/include/llvm/TableGen/Record.h b/include/llvm/TableGen/Record.h index 6667afe445b..48aeaa14ca4 100644 --- a/include/llvm/TableGen/Record.h +++ b/include/llvm/TableGen/Record.h @@ -1295,6 +1295,7 @@ public: Init *resolveReferences(Resolver &R) const override; Init *Fold(Record *CurRec) const; + bool isConcrete() const override; std::string getAsString() const override { return Rec->getAsString() + "." + FieldName->getValue().str(); } diff --git a/lib/TableGen/Record.cpp b/lib/TableGen/Record.cpp index 54ff9ae3067..ca8cd15294d 100644 --- a/lib/TableGen/Record.cpp +++ b/lib/TableGen/Record.cpp @@ -1778,6 +1778,14 @@ Init *FieldInit::Fold(Record *CurRec) const { return const_cast(this); } +bool FieldInit::isConcrete() const { + if (DefInit *DI = dyn_cast(Rec)) { + Init *FieldVal = DI->getDef()->getValue(FieldName)->getValue(); + return FieldVal->isConcrete(); + } + return false; +} + static void ProfileCondOpInit(FoldingSetNodeID &ID, ArrayRef CondRange, ArrayRef ValRange, diff --git a/test/TableGen/field-access-initializers.td b/test/TableGen/field-access-initializers.td new file mode 100644 index 00000000000..5a25e2901ae --- /dev/null +++ b/test/TableGen/field-access-initializers.td @@ -0,0 +1,23 @@ +// RUN: llvm-tblgen %s | FileCheck %s +// XFAIL: vg_leak + +// CHECK: --- Defs --- + +// CHECK: def A1 { +// CHECK: string value = ?; +// CHECK: } + +// CHECK: def B1 { +// CHECK: string value = A1.value; +// CHECK: } + +class A { + string value = ?; +} + +class B : A { + let value = impl.value; +} + +def A1 : A; +def B1 : B;