diff options
| author | Nicolai Haehnle <nhaehnle@gmail.com> | 2018-02-22 15:26:21 +0000 |
|---|---|---|
| committer | Nicolai Haehnle <nhaehnle@gmail.com> | 2018-02-22 15:26:21 +0000 |
| commit | f19083d1edb26c2cd4535ac58327f48667a88043 (patch) | |
| tree | 881bde06485f0fe044781cd8c6108b9a173b33ca /llvm/lib/TableGen/TGParser.cpp | |
| parent | 40b140fef122f429327d494ef2f6c2f71a06ce3f (diff) | |
| download | bcm5719-llvm-f19083d1edb26c2cd4535ac58327f48667a88043.tar.gz bcm5719-llvm-f19083d1edb26c2cd4535ac58327f48667a88043.zip | |
TableGen: Add some more helpful error messages
Summary: Some fairly simple changes to start with.
Reviewers: arsenm, craig.topper, tra, MartinO
Subscribers: wdng, llvm-commits
Differential Revision: https://reviews.llvm.org/D43552
Change-Id: I0c92731b36d309c6edfcae42595ae1a70cc051c9
llvm-svn: 325795
Diffstat (limited to 'llvm/lib/TableGen/TGParser.cpp')
| -rw-r--r-- | llvm/lib/TableGen/TGParser.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp index b492cf9495c..b6e207f7a74 100644 --- a/llvm/lib/TableGen/TGParser.cpp +++ b/llvm/lib/TableGen/TGParser.cpp @@ -104,7 +104,7 @@ bool TGParser::SetValue(Record *CurRec, SMLoc Loc, Init *ValName, if (BitList.empty()) if (VarInit *VI = dyn_cast<VarInit>(V)) if (VI->getNameInit() == ValName && !AllowSelfAssignment) - return true; + return Error(Loc, "Recursion / self-assignment forbidden"); // If we are assigning to a subset of the bits in the value... then we must be // assigning to a field of BitsRecTy, which must have a BitsInit @@ -147,10 +147,12 @@ bool TGParser::SetValue(Record *CurRec, SMLoc Loc, Init *ValName, if (BitsInit *BI = dyn_cast<BitsInit>(V)) InitType = (Twine("' of type bit initializer with length ") + Twine(BI->getNumBits())).str(); + else if (TypedInit *TI = dyn_cast<TypedInit>(V)) + InitType = (Twine("' of type '") + TI->getType()->getAsString()).str(); return Error(Loc, "Value '" + ValName->getAsUnquotedString() + - "' of type '" + RV->getType()->getAsString() + - "' is incompatible with initializer '" + V->getAsString() + - InitType + "'"); + "' of type '" + RV->getType()->getAsString() + + "' is incompatible with initializer '" + + V->getAsString() + InitType + "'"); } return false; } @@ -1396,7 +1398,9 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType, // Make sure the deduced type is compatible with the given type if (GivenListTy) { if (!EltTy->typeIsConvertibleTo(GivenListTy->getElementType())) { - TokError("Element type mismatch for list"); + TokError(Twine("Element type mismatch for list: element type '") + + EltTy->getAsString() + "' not convertible to '" + + GivenListTy->getElementType()->getAsString()); return nullptr; } } |

