diff options
author | Nicolai Haehnle <nhaehnle@gmail.com> | 2018-03-05 15:21:11 +0000 |
---|---|---|
committer | Nicolai Haehnle <nhaehnle@gmail.com> | 2018-03-05 15:21:11 +0000 |
commit | b0cf9e93a68f224288d3fb029255c97d5c6fe5eb (patch) | |
tree | 816abb2e62c0cd86898d16c342a1e2fbc804b627 /llvm/lib/TableGen/TGParser.cpp | |
parent | 8ebf7e4dfa222ae04e063f1c1e0bb5c945331ac7 (diff) | |
download | bcm5719-llvm-b0cf9e93a68f224288d3fb029255c97d5c6fe5eb.tar.gz bcm5719-llvm-b0cf9e93a68f224288d3fb029255c97d5c6fe5eb.zip |
TableGen: Resolve all template args simultaneously in AddSubClass
Summary:
Use the new resolver interface more explicitly, and avoid traversing
all the initializers multiple times.
Add a test case for a pattern that was broken by an earlier version
of this change.
An additional change is that we now remove *all* template arguments
after resolving them.
Change-Id: I86c828c8cc84c18b052dfe0f64c0d5cbf3c4e13c
Reviewers: arsenm, craig.topper, tra, MartinO
Subscribers: wdng, llvm-commits
Differential Revision: https://reviews.llvm.org/D43652
llvm-svn: 326706
Diffstat (limited to 'llvm/lib/TableGen/TGParser.cpp')
-rw-r--r-- | llvm/lib/TableGen/TGParser.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp index b42580c9cda..3c1f4f3ab6f 100644 --- a/llvm/lib/TableGen/TGParser.cpp +++ b/llvm/lib/TableGen/TGParser.cpp @@ -175,27 +175,28 @@ bool TGParser::AddSubClass(Record *CurRec, SubClassReference &SubClass) { // Loop over all of the template arguments, setting them to the specified // value or leaving them as the default if necessary. + MapResolver R(CurRec); + for (unsigned i = 0, e = TArgs.size(); i != e; ++i) { if (i < SubClass.TemplateArgs.size()) { // If a value is specified for this template arg, set it now. if (SetValue(CurRec, SubClass.RefRange.Start, TArgs[i], None, SubClass.TemplateArgs[i])) return true; - - // Resolve it next. - CurRec->resolveReferencesTo(CurRec->getValue(TArgs[i])); - - // Now remove it. - CurRec->removeValue(TArgs[i]); - } else if (!CurRec->getValue(TArgs[i])->getValue()->isComplete()) { return Error(SubClass.RefRange.Start, "Value not specified for template argument #" + Twine(i) + " (" + TArgs[i]->getAsUnquotedString() + ") of subclass '" + SC->getNameInitAsString() + "'!"); } + + R.set(TArgs[i], CurRec->getValue(TArgs[i])->getValue()); + + CurRec->removeValue(TArgs[i]); } + CurRec->resolveReferences(R); + // Since everything went well, we can now set the "superclass" list for the // current record. ArrayRef<std::pair<Record *, SMRange>> SCs = SC->getSuperClasses(); |