diff options
| author | Alp Toker <alp@nuanti.com> | 2013-12-21 18:51:00 +0000 |
|---|---|---|
| committer | Alp Toker <alp@nuanti.com> | 2013-12-21 18:51:00 +0000 |
| commit | ce91fe55692b6172d14a2408e5e4cd2eed4cab76 (patch) | |
| tree | 79f2f08fc4d729d6964d70e4045f58dc4963d9eb /llvm/lib/TableGen/TGParser.cpp | |
| parent | 888e935978fea8404a58e039491e3c3b3f92013f (diff) | |
| download | bcm5719-llvm-ce91fe55692b6172d14a2408e5e4cd2eed4cab76.tar.gz bcm5719-llvm-ce91fe55692b6172d14a2408e5e4cd2eed4cab76.zip | |
TableGen: Generate valid identifiers for anonymous records
Backends like OptParserEmitter assume that record names can be used as valid
identifiers.
The period '.' in generated anonymous names broke that assumption, causing a
build-time error and in practice forcing all records to be named.
llvm-svn: 197869
Diffstat (limited to 'llvm/lib/TableGen/TGParser.cpp')
| -rw-r--r-- | llvm/lib/TableGen/TGParser.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp index daac5747d3e..38ab71184aa 100644 --- a/llvm/lib/TableGen/TGParser.cpp +++ b/llvm/lib/TableGen/TGParser.cpp @@ -380,10 +380,11 @@ static bool isObjectStart(tgtok::TokKind K) { K == tgtok::MultiClass || K == tgtok::Foreach; } -static std::string GetNewAnonymousName() { - static unsigned AnonCounter = 0; +/// GetNewAnonymousName - Generate a unique anonymous name that can be used as +/// an identifier. +std::string TGParser::GetNewAnonymousName() { unsigned Tmp = AnonCounter++; // MSVC2012 ICEs without this. - return "anonymous." + utostr(Tmp); + return "anonymous_" + utostr(Tmp); } /// ParseObjectName - If an object name is specified, return it. Otherwise, @@ -1215,10 +1216,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType, SMLoc EndLoc = Lex.getLoc(); // Create the new record, set it as CurRec temporarily. - static unsigned AnonCounter = 0; - Record *NewRec = new Record("anonymous.val."+utostr(AnonCounter++), - NameLoc, - Records, + Record *NewRec = new Record(GetNewAnonymousName(), NameLoc, Records, /*IsAnonymous=*/true); SubClassReference SCRef; SCRef.RefRange = SMRange(NameLoc, EndLoc); |

