diff options
| author | Alex Lorenz <arphaman@gmail.com> | 2015-06-30 17:55:00 +0000 |
|---|---|---|
| committer | Alex Lorenz <arphaman@gmail.com> | 2015-06-30 17:55:00 +0000 |
| commit | 0fd7c621efaabecd93de194ca56604ede8f75bdc (patch) | |
| tree | 03d73cc5240c70fbacdea8d1bbdb3d69009ecbce | |
| parent | 3708a641b691697463bfb12677e162010f07a548 (diff) | |
| download | bcm5719-llvm-0fd7c621efaabecd93de194ca56604ede8f75bdc.tar.gz bcm5719-llvm-0fd7c621efaabecd93de194ca56604ede8f75bdc.zip | |
MIR Parser: refactor error reporting for machine instruction parser errors. NFC.
This commit extracts the code that reports an error that's produced by the
machine instruction parser into a new method that can be reused in other places.
llvm-svn: 241086
| -rw-r--r-- | llvm/lib/CodeGen/MIRParser/MIRParser.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp index f10a9e7cf45..064b2f15d65 100644 --- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp @@ -60,6 +60,12 @@ public: /// Always returns true. bool error(const Twine &Message); + /// Report a given error with the location translated from the location in an + /// embedded string literal to a location in the MIR file. + /// + /// Always returns true. + bool error(const SMDiagnostic &Error, SMRange SourceRange); + /// Try to parse the optional LLVM module and the machine functions in the MIR /// file. /// @@ -119,6 +125,12 @@ bool MIRParserImpl::error(const Twine &Message) { return true; } +bool MIRParserImpl::error(const SMDiagnostic &Error, SMRange SourceRange) { + assert(Error.getKind() == SourceMgr::DK_Error && "Expected an error"); + reportDiagnostic(diagFromMIStringDiag(Error, SourceRange)); + return true; +} + void MIRParserImpl::reportDiagnostic(const SMDiagnostic &Diag) { DiagnosticSeverity Kind; switch (Diag.getKind()) { @@ -266,11 +278,8 @@ bool MIRParserImpl::initializeMachineBasicBlock( for (const auto &MISource : YamlMBB.Instructions) { SMDiagnostic Error; MachineInstr *MI = nullptr; - if (parseMachineInstr(MI, SM, MF, MISource.Value, MBBSlots, IRSlots, - Error)) { - reportDiagnostic(diagFromMIStringDiag(Error, MISource.SourceRange)); - return true; - } + if (parseMachineInstr(MI, SM, MF, MISource.Value, MBBSlots, IRSlots, Error)) + return error(Error, MISource.SourceRange); MBB.insert(MBB.end(), MI); } return false; |

