diff options
author | Chris Lattner <sabre@nondot.org> | 2010-12-13 00:23:57 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-12-13 00:23:57 +0000 |
commit | 67db883487fca3472fdde51e931657e22d4d0495 (patch) | |
tree | 18ad5bbf8c061c1ed7c732a4af1f864fe7206700 /utils/TableGen/Record.h | |
parent | 9d6250f52ba4ba0a34d44aa2cc9d3fa14c15a006 (diff) | |
download | external_llvm-67db883487fca3472fdde51e931657e22d4d0495.zip external_llvm-67db883487fca3472fdde51e931657e22d4d0495.tar.gz external_llvm-67db883487fca3472fdde51e931657e22d4d0495.tar.bz2 |
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.h | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/utils/TableGen/Record.h b/utils/TableGen/Record.h index cfe1a48..0853037 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 |