diff options
author | Daniel Sanders <daniel_l_sanders@apple.com> | 2019-02-12 17:36:57 +0000 |
---|---|---|
committer | Daniel Sanders <daniel_l_sanders@apple.com> | 2019-02-12 17:36:57 +0000 |
commit | dff673bb525040f93bd928e114b1dae15df0681c (patch) | |
tree | b0e288b08a033951f110662d7e846471f2945fea /llvm/utils/TableGen/AsmWriterInst.cpp | |
parent | 0e71e73faacf2a061f27654e59c22586adff51b8 (diff) | |
download | bcm5719-llvm-dff673bb525040f93bd928e114b1dae15df0681c.tar.gz bcm5719-llvm-dff673bb525040f93bd928e114b1dae15df0681c.zip |
[tablegen] Add locations to many PrintFatalError() calls
Summary:
While working on the GISel Combiner, I noticed I was producing location-less
error messages fairly often and set about fixing this. In the process, I
noticed quite a few places elsewhere in TableGen that also neglected to include
a relevant location.
This patch adds locations to errors that relate to a specific record (or a
field within it) and also have easy access to the relevant location. This is
particularly useful when multiclasses are involved as many of these errors
refer to the full name of a record and it's difficult to guess which substring
is grep-able.
Unfortunately, tablegen currently only supports Record granularity so it's not
currently possible to point at a specific Init so these sometimes point at the
record that caused the error rather than the precise origin of the error.
Reviewers: bogner, aditya_nandakumar, volkan, aemerson, paquette, nhaehnle
Reviewed By: nhaehnle
Subscribers: jdoerfert, nhaehnle, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D58077
llvm-svn: 353862
Diffstat (limited to 'llvm/utils/TableGen/AsmWriterInst.cpp')
-rw-r--r-- | llvm/utils/TableGen/AsmWriterInst.cpp | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/llvm/utils/TableGen/AsmWriterInst.cpp b/llvm/utils/TableGen/AsmWriterInst.cpp index d065a420969..c26e0e42118 100644 --- a/llvm/utils/TableGen/AsmWriterInst.cpp +++ b/llvm/utils/TableGen/AsmWriterInst.cpp @@ -93,8 +93,10 @@ AsmWriterInst::AsmWriterInst(const CodeGenInstruction &CGI, unsigned CGIIndex, != std::string::npos) { AddLiteralString(std::string(1, AsmString[DollarPos+1])); } else { - PrintFatalError("Non-supported escaped character found in instruction '" + - CGI.TheDef->getName() + "'!"); + PrintFatalError( + CGI.TheDef->getLoc(), + "Non-supported escaped character found in instruction '" + + CGI.TheDef->getName() + "'!"); } LastEmitted = DollarPos+2; continue; @@ -131,15 +133,19 @@ AsmWriterInst::AsmWriterInst(const CodeGenInstruction &CGI, unsigned CGIIndex, // brace. if (hasCurlyBraces) { if (VarEnd >= AsmString.size()) - PrintFatalError("Reached end of string before terminating curly brace in '" - + CGI.TheDef->getName() + "'"); + PrintFatalError( + CGI.TheDef->getLoc(), + "Reached end of string before terminating curly brace in '" + + CGI.TheDef->getName() + "'"); // Look for a modifier string. if (AsmString[VarEnd] == ':') { ++VarEnd; if (VarEnd >= AsmString.size()) - PrintFatalError("Reached end of string before terminating curly brace in '" - + CGI.TheDef->getName() + "'"); + PrintFatalError( + CGI.TheDef->getLoc(), + "Reached end of string before terminating curly brace in '" + + CGI.TheDef->getName() + "'"); std::string::size_type ModifierStart = VarEnd; while (VarEnd < AsmString.size() && isIdentChar(AsmString[VarEnd])) @@ -147,17 +153,22 @@ AsmWriterInst::AsmWriterInst(const CodeGenInstruction &CGI, unsigned CGIIndex, Modifier = std::string(AsmString.begin()+ModifierStart, AsmString.begin()+VarEnd); if (Modifier.empty()) - PrintFatalError("Bad operand modifier name in '"+ CGI.TheDef->getName() + "'"); + PrintFatalError(CGI.TheDef->getLoc(), + "Bad operand modifier name in '" + + CGI.TheDef->getName() + "'"); } if (AsmString[VarEnd] != '}') - PrintFatalError("Variable name beginning with '{' did not end with '}' in '" - + CGI.TheDef->getName() + "'"); + PrintFatalError( + CGI.TheDef->getLoc(), + "Variable name beginning with '{' did not end with '}' in '" + + CGI.TheDef->getName() + "'"); ++VarEnd; } if (VarName.empty() && Modifier.empty()) - PrintFatalError("Stray '$' in '" + CGI.TheDef->getName() + - "' asm string, maybe you want $$?"); + PrintFatalError(CGI.TheDef->getLoc(), + "Stray '$' in '" + CGI.TheDef->getName() + + "' asm string, maybe you want $$?"); if (VarName.empty()) { // Just a modifier, pass this into PrintSpecial. |