diff options
author | Chris Lattner <sabre@nondot.org> | 2010-04-06 00:26:48 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-04-06 00:26:48 +0000 |
commit | 3c799811c1405a187f9769ca69553d27fbb0bd5c (patch) | |
tree | 76593f06644ef775378e3833c0db6845631ab0d0 /llvm/lib | |
parent | 104e6ff852b1cc937ca7d3239e3d8e2abfd470ba (diff) | |
download | bcm5719-llvm-3c799811c1405a187f9769ca69553d27fbb0bd5c.tar.gz bcm5719-llvm-3c799811c1405a187f9769ca69553d27fbb0bd5c.zip |
Give llvm::SourceMgr the ability to have a client-specified
diagnostic handler.
llvm-svn: 100503
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/AsmParser/Parser.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Support/SourceMgr.cpp | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/AsmParser/Parser.cpp b/llvm/lib/AsmParser/Parser.cpp index 1ab37345b20..7280cf479f2 100644 --- a/llvm/lib/AsmParser/Parser.cpp +++ b/llvm/lib/AsmParser/Parser.cpp @@ -44,7 +44,7 @@ Module *llvm::ParseAssemblyFile(const std::string &Filename, SMDiagnostic &Err, std::string ErrorStr; MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrorStr); if (F == 0) { - Err = SMDiagnostic("", -1, -1, + Err = SMDiagnostic(SMLoc(), "", -1, -1, "Could not open input file '" + Filename + "': " + ErrorStr, ""); return 0; diff --git a/llvm/lib/Support/SourceMgr.cpp b/llvm/lib/Support/SourceMgr.cpp index 83c7964ca00..fe2fbd96f77 100644 --- a/llvm/lib/Support/SourceMgr.cpp +++ b/llvm/lib/Support/SourceMgr.cpp @@ -168,13 +168,20 @@ SMDiagnostic SourceMgr::GetMessage(SMLoc Loc, const std::string &Msg, } PrintedMsg += Msg; - return SMDiagnostic(CurMB->getBufferIdentifier(), FindLineNumber(Loc, CurBuf), + return SMDiagnostic(Loc, + CurMB->getBufferIdentifier(), FindLineNumber(Loc, CurBuf), Loc.getPointer()-LineStart, PrintedMsg, LineStr, ShowLine); } void SourceMgr::PrintMessage(SMLoc Loc, const std::string &Msg, const char *Type, bool ShowLine) const { + // Report the message with the diagnostic handler if present. + if (DiagHandler) { + DiagHandler(GetMessage(Loc, Msg, Type, ShowLine), DiagContext); + return; + } + raw_ostream &OS = errs(); int CurBuf = FindBufferContainingLoc(Loc); |