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/Support/SourceMgr.cpp | |
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/Support/SourceMgr.cpp')
-rw-r--r-- | llvm/lib/Support/SourceMgr.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
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); |