summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-07-30 04:56:05 +0000
committerChris Lattner <sabre@nondot.org>2003-07-30 04:56:05 +0000
commitbfce056ea89f4a243c429c12e47ec78168bb1d2c (patch)
tree8c09f5b9bf75e07ef673172f86924f862eae1237 /utils
parent554af5cd62513799b895a1c15b0d3ae0e7b16a2c (diff)
downloadllvm-bfce056ea89f4a243c429c12e47ec78168bb1d2c.tar.gz
llvm-bfce056ea89f4a243c429c12e47ec78168bb1d2c.tar.bz2
llvm-bfce056ea89f4a243c429c12e47ec78168bb1d2c.tar.xz
Don't pollute the namespace with template arguments after they have been resolved
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7410 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/TableGen/FileParser.y17
-rw-r--r--utils/TableGen/Record.h10
2 files changed, 24 insertions, 3 deletions
diff --git a/utils/TableGen/FileParser.y b/utils/TableGen/FileParser.y
index 6ebcf7691b..f8fa16de2a 100644
--- a/utils/TableGen/FileParser.y
+++ b/utils/TableGen/FileParser.y
@@ -409,9 +409,9 @@ ObjectBody : OptID {
} OptTemplateArgList ClassList {
for (unsigned i = 0, e = $4->size(); i != e; ++i) {
addSubClass((*$4)[i].first, *(*$4)[i].second);
- delete (*$4)[i].second; // Delete the template list
- }
- delete $4;
+ // Delete the template arg values for the class
+ delete (*$4)[i].second;
+ }
// Process any variables on the set stack...
for (unsigned i = 0, e = SetStack.size(); i != e; ++i)
@@ -419,6 +419,17 @@ ObjectBody : OptID {
SetStack[i].second);
} Body {
CurRec->resolveReferences();
+
+ // Now that all of the references have been resolved, we can delete template
+ // arguments for superclasses, so they don't pollute our record, and so that
+ // their names won't conflict with later uses of the name...
+ for (unsigned i = 0, e = $4->size(); i != e; ++i) {
+ Record *SuperClass = (*$4)[i].first;
+ for (unsigned i = 0, e = SuperClass->getTemplateArgs().size(); i != e; ++i)
+ CurRec->removeValue(SuperClass->getTemplateArgs()[i]);
+ }
+ delete $4; // Delete the class list...
+
$$ = CurRec;
CurRec = 0;
};
diff --git a/utils/TableGen/Record.h b/utils/TableGen/Record.h
index d94bb34504..0ac5648c86 100644
--- a/utils/TableGen/Record.h
+++ b/utils/TableGen/Record.h
@@ -536,6 +536,16 @@ public:
Values.push_back(RV);
}
+ void removeValue(const std::string &Name) {
+ assert(getValue(Name) && "Cannot remove an entry that does not exist!");
+ for (unsigned i = 0, e = Values.size(); i != e; ++i)
+ if (Values[i].getName() == Name) {
+ Values.erase(Values.begin()+i);
+ return;
+ }
+ assert(0 && "Name does not exist in record!");
+ }
+
bool isSubClassOf(Record *R) const {
for (unsigned i = 0, e = SuperClasses.size(); i != e; ++i)
if (SuperClasses[i] == R)