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 | 8f0f480a10cd5b62914fd53611e696c5069fc62d (patch) | |
tree | ddb0af86b39e52ed6f6d7f931268d32a9f315816 /lib/Support/SourceMgr.cpp | |
parent | a03948633ae848af9cecce0a8042c7db4dac44d9 (diff) |
Give llvm::SourceMgr the ability to have a client-specified
diagnostic handler.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100503 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/SourceMgr.cpp')
-rw-r--r-- | lib/Support/SourceMgr.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Support/SourceMgr.cpp b/lib/Support/SourceMgr.cpp index 83c7964ca0..fe2fbd96f7 100644 --- a/lib/Support/SourceMgr.cpp +++ b/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); |