summaryrefslogtreecommitdiff
path: root/utils/TableGen/Record.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-09-13 21:44:28 +0000
committerChris Lattner <sabre@nondot.org>2005-09-13 21:44:28 +0000
commit8f493130bb51dea34c49e08aeab161e6a32dfdc6 (patch)
tree5e6dbf923b6c82419210d5e82821256f59b3c29b /utils/TableGen/Record.cpp
parentee9f0c3c2ea8d32218680488fe030bd19547e8b4 (diff)
downloadllvm-8f493130bb51dea34c49e08aeab161e6a32dfdc6.tar.gz
llvm-8f493130bb51dea34c49e08aeab161e6a32dfdc6.tar.bz2
llvm-8f493130bb51dea34c49e08aeab161e6a32dfdc6.tar.xz
Add a new Record::getValueAsCode method to mirror the other getValueAs*
methods. Use it to simplify some code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23336 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/Record.cpp')
-rw-r--r--utils/TableGen/Record.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp
index 077476d07b..c5f0565749 100644
--- a/utils/TableGen/Record.cpp
+++ b/utils/TableGen/Record.cpp
@@ -773,6 +773,18 @@ DagInit *Record::getValueAsDag(const std::string &FieldName) const {
"' does not have a dag initializer!";
}
+std::string Record::getValueAsCode(const std::string &FieldName) const {
+ const RecordVal *R = getValue(FieldName);
+ if (R == 0 || R->getValue() == 0)
+ throw "Record `" + getName() + "' does not have a field named `" +
+ FieldName + "'!\n";
+
+ if (const CodeInit *CI = dynamic_cast<const CodeInit*>(R->getValue()))
+ return CI->getValue();
+ throw "Record `" + getName() + "', field `" + FieldName +
+ "' does not have a code initializer!";
+}
+
void RecordKeeper::dump() const { std::cerr << *this; }