summaryrefslogtreecommitdiff
path: root/utils/TableGen/Record.h
diff options
context:
space:
mode:
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