diff options
Diffstat (limited to 'support/tools/TableGen/Record.cpp')
-rw-r--r-- | support/tools/TableGen/Record.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/support/tools/TableGen/Record.cpp b/support/tools/TableGen/Record.cpp index 8649b5fe4c..7f81a382bb 100644 --- a/support/tools/TableGen/Record.cpp +++ b/support/tools/TableGen/Record.cpp @@ -460,6 +460,18 @@ std::ostream &operator<<(std::ostream &OS, const Record &R) { return OS << "}\n"; } +/// getValueInit - Return the initializer for a value with the specified name, +/// or throw an exception if the field does not exist. +/// +Init *Record::getValueInit(const std::string &FieldName) const { + const RecordVal *R = getValue(FieldName); + if (R == 0 || R->getValue() == 0) + throw "Record '" + R->getName() + "' does not have a field named '" + + FieldName + "!\n"; + return R->getValue(); +} + + /// getValueAsString - This method looks up the specified field and returns its /// value as a string, throwing an exception if the field does not exist or if /// the value is not a string. |