[llvm] r211087 - Add an overload for SourceMgr::PrintMessage that takes an existing diagnostic.
Jordan Rose
jordan_rose at apple.com
Mon Jun 16 19:15:40 PDT 2014
Author: jrose
Date: Mon Jun 16 21:15:40 2014
New Revision: 211087
URL: http://llvm.org/viewvc/llvm-project?rev=211087&view=rev
Log:
Add an overload for SourceMgr::PrintMessage that takes an existing diagnostic.
Modified:
llvm/trunk/include/llvm/Support/SourceMgr.h
llvm/trunk/lib/Support/SourceMgr.cpp
Modified: llvm/trunk/include/llvm/Support/SourceMgr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/SourceMgr.h?rev=211087&r1=211086&r2=211087&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/SourceMgr.h (original)
+++ llvm/trunk/include/llvm/Support/SourceMgr.h Mon Jun 16 21:15:40 2014
@@ -157,6 +157,13 @@ public:
ArrayRef<SMFixIt> FixIts = None,
bool ShowColors = true) const;
+ /// Emits a manually-constructed diagnostic to the given output stream.
+ ///
+ /// \param ShowColors Display colored messages if output is a terminal and
+ /// the default error handler is used.
+ void PrintMessage(raw_ostream &OS, const SMDiagnostic &Diagnostic,
+ bool ShowColors = true) const;
+
/// Return an SMDiagnostic at the specified location with the specified
/// string.
///
Modified: llvm/trunk/lib/Support/SourceMgr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/SourceMgr.cpp?rev=211087&r1=211086&r2=211087&view=diff
==============================================================================
--- llvm/trunk/lib/Support/SourceMgr.cpp (original)
+++ llvm/trunk/lib/Support/SourceMgr.cpp Mon Jun 16 21:15:40 2014
@@ -199,20 +199,16 @@ SMDiagnostic SourceMgr::GetMessage(SMLoc
LineStr, ColRanges, FixIts);
}
-void SourceMgr::PrintMessage(raw_ostream &OS, SMLoc Loc,
- SourceMgr::DiagKind Kind,
- const Twine &Msg, ArrayRef<SMRange> Ranges,
- ArrayRef<SMFixIt> FixIts, bool ShowColors) const {
- SMDiagnostic Diagnostic = GetMessage(Loc, Kind, Msg, Ranges, FixIts);
-
+void SourceMgr::PrintMessage(raw_ostream &OS, const SMDiagnostic &Diagnostic,
+ bool ShowColors) const {
// Report the message with the diagnostic handler if present.
if (DiagHandler) {
DiagHandler(Diagnostic, DiagContext);
return;
}
- if (Loc != SMLoc()) {
- int CurBuf = FindBufferContainingLoc(Loc);
+ if (Diagnostic.getLoc().isValid()) {
+ int CurBuf = FindBufferContainingLoc(Diagnostic.getLoc());
assert(CurBuf != -1 && "Invalid or unspecified location!");
PrintIncludeStack(getBufferInfo(CurBuf).IncludeLoc, OS);
}
@@ -220,6 +216,13 @@ void SourceMgr::PrintMessage(raw_ostream
Diagnostic.print(nullptr, OS, ShowColors);
}
+void SourceMgr::PrintMessage(raw_ostream &OS, SMLoc Loc,
+ SourceMgr::DiagKind Kind,
+ const Twine &Msg, ArrayRef<SMRange> Ranges,
+ ArrayRef<SMFixIt> FixIts, bool ShowColors) const {
+ PrintMessage(OS, GetMessage(Loc, Kind, Msg, Ranges, FixIts), ShowColors);
+}
+
void SourceMgr::PrintMessage(SMLoc Loc, SourceMgr::DiagKind Kind,
const Twine &Msg, ArrayRef<SMRange> Ranges,
ArrayRef<SMFixIt> FixIts, bool ShowColors) const {
More information about the llvm-commits
mailing list