diff options
| author | Nicolai Haehnle <nhaehnle@gmail.com> | 2018-03-09 12:24:14 +0000 |
|---|---|---|
| committer | Nicolai Haehnle <nhaehnle@gmail.com> | 2018-03-09 12:24:14 +0000 |
| commit | 64da6990366551f803474f93030866ae2c283b59 (patch) | |
| tree | 2497ef95b1508d9e695af433cca74b6c92028806 /llvm/lib/TableGen | |
| parent | b537605956400d62729cebc9d5d053c45aa5f4c5 (diff) | |
| download | bcm5719-llvm-64da6990366551f803474f93030866ae2c283b59.tar.gz bcm5719-llvm-64da6990366551f803474f93030866ae2c283b59.zip | |
TableGen: More helpful error messages
Change-Id: Ic78afd0cd765fdb4cf1b7ecfb6bba22653ce6d29
llvm-svn: 327118
Diffstat (limited to 'llvm/lib/TableGen')
| -rw-r--r-- | llvm/lib/TableGen/Record.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp index 76bbe7a0e5d..9fd8b94e4af 100644 --- a/llvm/lib/TableGen/Record.cpp +++ b/llvm/lib/TableGen/Record.cpp @@ -1850,11 +1850,19 @@ void Record::resolveReferences(Resolver &R, const RecordVal *SkipVal) { continue; if (Init *V = Value.getValue()) { Init *VR = V->resolveReferences(R); - if (Value.setValue(VR)) - PrintFatalError(getLoc(), "Invalid value is found when setting '" + + if (Value.setValue(VR)) { + std::string Type; + if (TypedInit *VRT = dyn_cast<TypedInit>(VR)) + Type = + (Twine("of type '") + VRT->getType()->getAsString() + "' ").str(); + PrintFatalError(getLoc(), Twine("Invalid value ") + Type + + "is found when setting '" + Value.getNameInitAsString() + + " of type '" + + Value.getType()->getAsString() + "' after resolving references: " + VR->getAsUnquotedString() + "\n"); + } } } Init *OldName = getNameInit(); @@ -1984,8 +1992,10 @@ int64_t Record::getValueAsInt(StringRef FieldName) const { if (IntInit *II = dyn_cast<IntInit>(R->getValue())) return II->getValue(); - PrintFatalError(getLoc(), "Record `" + getName() + "', field `" + - FieldName + "' does not have an int initializer!"); + PrintFatalError(getLoc(), Twine("Record `") + getName() + "', field `" + + FieldName + + "' does not have an int initializer: " + + R->getValue()->getAsString()); } std::vector<int64_t> @@ -1996,8 +2006,10 @@ Record::getValueAsListOfInts(StringRef FieldName) const { if (IntInit *II = dyn_cast<IntInit>(I)) Ints.push_back(II->getValue()); else - PrintFatalError(getLoc(), "Record `" + getName() + "', field `" + - FieldName + "' does not have a list of ints initializer!"); + PrintFatalError(getLoc(), + Twine("Record `") + getName() + "', field `" + FieldName + + "' does not have a list of ints initializer: " + + I->getAsString()); } return Ints; } @@ -2010,8 +2022,10 @@ Record::getValueAsListOfStrings(StringRef FieldName) const { if (StringInit *SI = dyn_cast<StringInit>(I)) Strings.push_back(SI->getValue()); else - PrintFatalError(getLoc(), "Record `" + getName() + "', field `" + - FieldName + "' does not have a list of strings initializer!"); + PrintFatalError(getLoc(), + Twine("Record `") + getName() + "', field `" + FieldName + + "' does not have a list of strings initializer: " + + I->getAsString()); } return Strings; } |

