diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-05-24 22:17:36 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-05-24 22:17:36 +0000 |
commit | 72cba6cdf640411e2fb6207858a0abd87c4286fc (patch) | |
tree | ea65f3d9cbaba881b40a3be74efdafb0b579f19f | |
parent | 8e5286e18ffbe4716ef92cd1de8901942d685e1b (diff) |
Don't put TGParser scratch results in the output.
Only fully expanded Records should go into RecordKeeper.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157431 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/TableGen/Record.h | 10 | ||||
-rw-r--r-- | lib/TableGen/TGParser.cpp | 4 | ||||
-rw-r--r-- | test/TableGen/ForeachLoop.td | 1 |
3 files changed, 9 insertions, 6 deletions
diff --git a/include/llvm/TableGen/Record.h b/include/llvm/TableGen/Record.h index 3aea1aeaea..a8256b7735 100644 --- a/include/llvm/TableGen/Record.h +++ b/include/llvm/TableGen/Record.h @@ -1558,12 +1558,14 @@ public: return I == Defs.end() ? 0 : I->second; } void addClass(Record *R) { - assert(getClass(R->getNameInitAsString()) == 0 && "Class already exists!"); - Classes.insert(std::make_pair(R->getNameInitAsString(), R)); + bool Ins = Classes.insert(std::make_pair(R->getName(), R)).second; + (void)Ins; + assert(Ins && "Class already exists"); } void addDef(Record *R) { - assert(getDef(R->getNameInitAsString()) == 0 && "Def already exists!"); - Defs.insert(std::make_pair(R->getNameInitAsString(), R)); + bool Ins = Defs.insert(std::make_pair(R->getName(), R)).second; + (void)Ins; + assert(Ins && "Record already exists"); } /// removeClass - Remove, but do not delete, the specified record. diff --git a/lib/TableGen/TGParser.cpp b/lib/TableGen/TGParser.cpp index 68d9ef4c09..b23f410013 100644 --- a/lib/TableGen/TGParser.cpp +++ b/lib/TableGen/TGParser.cpp @@ -1903,7 +1903,7 @@ bool TGParser::ParseDef(MultiClass *CurMultiClass) { // Parse ObjectName and make a record for it. Record *CurRec = new Record(ParseObjectName(CurMultiClass), DefLoc, Records); - if (!CurMultiClass) { + if (!CurMultiClass && Loops.empty()) { // Top-level def definition. // Ensure redefinition doesn't happen. @@ -1913,7 +1913,7 @@ bool TGParser::ParseDef(MultiClass *CurMultiClass) { return true; } Records.addDef(CurRec); - } else { + } else if (CurMultiClass) { // Otherwise, a def inside a multiclass, add it to the multiclass. for (unsigned i = 0, e = CurMultiClass->DefPrototypes.size(); i != e; ++i) if (CurMultiClass->DefPrototypes[i]->getNameInit() diff --git a/test/TableGen/ForeachLoop.td b/test/TableGen/ForeachLoop.td index e2defe9cfe..342609643c 100644 --- a/test/TableGen/ForeachLoop.td +++ b/test/TableGen/ForeachLoop.td @@ -9,6 +9,7 @@ class Register<string name, int idx> { foreach i = [0, 1, 2, 3, 4, 5, 6, 7] in def R#i : Register<"R"#i, i>; +// CHECK-NOT: !strconcat // CHECK: def R0 // CHECK: string Name = "R0"; |