diff options
author | J-Y You <jyyou.tw@gmail.com> | 2021-02-01 10:59:07 -0500 |
---|---|---|
committer | Paul C. Anagnostopoulos <paul@windfall.com> | 2021-02-01 10:59:07 -0500 |
commit | 267b573b55f7f43aaeaf4860e31101cd6a3dbba0 (patch) | |
tree | 6a30defe7085250196788b71fef5af1d60cd8388 /llvm/lib/TableGen/TGParser.cpp | |
parent | ce587529ad8b5347fa8896e6811469c1857ed1a2 (diff) | |
download | llvm-267b573b55f7f43aaeaf4860e31101cd6a3dbba0.zip llvm-267b573b55f7f43aaeaf4860e31101cd6a3dbba0.tar.gz llvm-267b573b55f7f43aaeaf4860e31101cd6a3dbba0.tar.bz2 |
[TableGen] Fix anonymous record self-reference in foreach and multiclass
If we instantiate self-referenced anonymous records in foreach and
multiclass, the NAME value will point to incorrect record. It's because
anonymous name is resolved too early.
This patch adds AnonymousNameInit to represent an anonymous record name.
When instantiating an anonymous record, it will update the referred name.
Differential Revision: https://reviews.llvm.org/D95309
Diffstat (limited to 'llvm/lib/TableGen/TGParser.cpp')
-rw-r--r-- | llvm/lib/TableGen/TGParser.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp index 1995477..87faf77 100644 --- a/llvm/lib/TableGen/TGParser.cpp +++ b/llvm/lib/TableGen/TGParser.cpp @@ -439,6 +439,7 @@ bool TGParser::resolve(const std::vector<RecordsEntry> &Source, /// Resolve the record fully and add it to the record keeper. bool TGParser::addDefOne(std::unique_ptr<Record> Rec) { + Init *NewName = nullptr; if (Record *Prev = Records.getDef(Rec->getNameInitAsString())) { if (!Rec->isAnonymous()) { PrintError(Rec->getLoc(), @@ -446,10 +447,10 @@ bool TGParser::addDefOne(std::unique_ptr<Record> Rec) { PrintNote(Prev->getLoc(), "location of previous definition"); return true; } - Rec->setName(Records.getNewAnonymousName()); + NewName = Records.getNewAnonymousName(); } - Rec->resolveReferences(); + Rec->resolveReferences(NewName); checkConcrete(*Rec); CheckRecordAsserts(*Rec); |