[llvm-commits] CVS: llvm/utils/TableGen/FileParser.y Record.h
Chris Lattner
lattner at cs.uiuc.edu
Tue Jul 29 23:57:01 PDT 2003
Changes in directory llvm/utils/TableGen:
FileParser.y updated: 1.8 -> 1.9
Record.h updated: 1.13 -> 1.14
---
Log message:
Don't pollute the namespace with template arguments after they have been resolved
---
Diffs of the changes:
Index: llvm/utils/TableGen/FileParser.y
diff -u llvm/utils/TableGen/FileParser.y:1.8 llvm/utils/TableGen/FileParser.y:1.9
--- llvm/utils/TableGen/FileParser.y:1.8 Tue Jul 29 23:31:17 2003
+++ llvm/utils/TableGen/FileParser.y Tue Jul 29 23:56:04 2003
@@ -409,9 +409,9 @@
} 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 @@
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;
};
Index: llvm/utils/TableGen/Record.h
diff -u llvm/utils/TableGen/Record.h:1.13 llvm/utils/TableGen/Record.h:1.14
--- llvm/utils/TableGen/Record.h:1.13 Tue Jul 29 23:16:52 2003
+++ llvm/utils/TableGen/Record.h Tue Jul 29 23:56:05 2003
@@ -536,6 +536,16 @@
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)
More information about the llvm-commits
mailing list