diff --git a/support/tools/TableGen/Record.cpp b/support/tools/TableGen/Record.cpp index 72c5a230e5b..a54f8e238b1 100644 --- a/support/tools/TableGen/Record.cpp +++ b/support/tools/TableGen/Record.cpp @@ -116,6 +116,14 @@ Init *ListRecTy::convertValue(ListInit *LI) { return LI; } +Init *ListRecTy::convertValue(TypedInit *TI) { + // Ensure that TI is compatible with our class. + if (ListRecTy *LRT = dynamic_cast(TI->getType())) + if (LRT->getElementClass() == getElementClass()) + return TI; + return 0; +} + void RecordRecTy::print(std::ostream &OS) const { OS << Rec->getName(); } @@ -127,12 +135,12 @@ Init *RecordRecTy::convertValue(DefInit *DI) { return DI; } -Init *RecordRecTy::convertValue(TypedInit *VI) { - // Ensure that VI is compatible with Rec. - if (RecordRecTy *RRT = dynamic_cast(VI->getType())) +Init *RecordRecTy::convertValue(TypedInit *TI) { + // Ensure that TI is compatible with Rec. + if (RecordRecTy *RRT = dynamic_cast(TI->getType())) if (RRT->getRecord()->isSubClassOf(getRecord()) || RRT->getRecord() == getRecord()) - return VI; + return TI; return 0; } diff --git a/support/tools/TableGen/Record.h b/support/tools/TableGen/Record.h index 356d131ae9e..d94bb34504f 100644 --- a/support/tools/TableGen/Record.h +++ b/support/tools/TableGen/Record.h @@ -108,7 +108,7 @@ struct IntRecTy : public RecTy { struct StringRecTy : public RecTy { Init *convertValue(UnsetInit *UI) { return (Init*)UI; } Init *convertValue(StringInit *SI) { return (Init*)SI; } - Init *convertValue(TypedInit *VI); + Init *convertValue(TypedInit *TI); void print(std::ostream &OS) const { OS << "string"; } }; @@ -119,8 +119,14 @@ class ListRecTy : public RecTy { Record *Class; public: ListRecTy(Record *C) : Class(C) {} + + /// getElementClass - Return the class that the list contains. + /// + Record *getElementClass() const { return Class; } + Init *convertValue(UnsetInit *UI) { return (Init*)UI; } Init *convertValue(ListInit *LI); + Init *convertValue(TypedInit *TI); void print(std::ostream &OS) const; };