summaryrefslogtreecommitdiff
path: root/utils/TableGen/Record.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-12-13 00:23:57 +0000
committerChris Lattner <sabre@nondot.org>2010-12-13 00:23:57 +0000
commit67db883487fca3472fdde51e931657e22d4d0495 (patch)
tree18ad5bbf8c061c1ed7c732a4af1f864fe7206700 /utils/TableGen/Record.h
parent9d6250f52ba4ba0a34d44aa2cc9d3fa14c15a006 (diff)
downloadllvm-67db883487fca3472fdde51e931657e22d4d0495.tar.gz
llvm-67db883487fca3472fdde51e931657e22d4d0495.tar.bz2
llvm-67db883487fca3472fdde51e931657e22d4d0495.tar.xz
eliminate the Records global variable, patch by Garrison Venn!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121659 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/Record.h')
-rw-r--r--utils/TableGen/Record.h24
1 files changed, 19 insertions, 5 deletions
diff --git a/utils/TableGen/Record.h b/utils/TableGen/Record.h
index cfe1a4861b..0853037fe3 100644
--- a/utils/TableGen/Record.h
+++ b/utils/TableGen/Record.h
@@ -57,6 +57,7 @@ class VarListElementInit;
class Record;
class RecordVal;
struct MultiClass;
+class RecordKeeper;
//===----------------------------------------------------------------------===//
// Type Classes
@@ -1227,10 +1228,15 @@ class Record {
std::vector<std::string> TemplateArgs;
std::vector<RecordVal> Values;
std::vector<Record*> SuperClasses;
+
+ // Tracks Record instances. Not owned by Record.
+ RecordKeeper &TrackedRecords;
+
public:
- explicit Record(const std::string &N, SMLoc loc) :
- ID(LastID++), Name(N), Loc(loc) {}
+ // Constructs a record. See also RecordKeeper::createRecord.
+ explicit Record(const std::string &N, SMLoc loc, RecordKeeper& records) :
+ ID(LastID++), Name(N), Loc(loc), TrackedRecords(records) {}
~Record() {}
@@ -1315,6 +1321,10 @@ public:
/// possible references.
void resolveReferencesTo(const RecordVal *RV);
+ RecordKeeper &getRecords() const {
+ return(TrackedRecords);
+ }
+
void dump() const;
//===--------------------------------------------------------------------===//
@@ -1396,7 +1406,8 @@ struct MultiClass {
void dump() const;
- MultiClass(const std::string &Name, SMLoc Loc) : Rec(Name, Loc) {}
+ MultiClass(const std::string &Name, SMLoc Loc, RecordKeeper &Records) :
+ Rec(Name, Loc, Records) {}
};
class RecordKeeper {
@@ -1453,6 +1464,11 @@ public:
std::vector<Record*>
getAllDerivedDefinitions(const std::string &ClassName) const;
+ // allocates and returns a record.
+ Record *createRecord(const std::string &N, SMLoc loc) {
+ return(new Record(N, loc, *this));
+ }
+
void dump() const;
};
@@ -1488,8 +1504,6 @@ public:
raw_ostream &operator<<(raw_ostream &OS, const RecordKeeper &RK);
-extern RecordKeeper Records;
-
void PrintError(SMLoc ErrorLoc, const Twine &Msg);
} // End llvm namespace