summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/DiagnosticRenderer.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2012-02-14 02:46:00 +0000
committerTed Kremenek <kremenek@apple.com>2012-02-14 02:46:00 +0000
commit0964cca5d5874162fe09d566ee03b84a17c2a212 (patch)
tree44f5e0a395ff52a10e7313c4fc8e8349db230c99 /clang/lib/Frontend/DiagnosticRenderer.cpp
parent3efa357fee22ff293fedb20751cd725580b00766 (diff)
downloadbcm5719-llvm-0964cca5d5874162fe09d566ee03b84a17c2a212.tar.gz
bcm5719-llvm-0964cca5d5874162fe09d566ee03b84a17c2a212.zip
Refactor DiagnosticRenderer and SDiagsRenderer to have some functionality
pulled into DiagnosticNoteRenderer, and common DiagnosticRenderer that assumes that all custom diagnostic messages are notes. Also extend DiagnosticRenderer to work with StoredDiagnostics in preparation for subsequent changes. llvm-svn: 150455
Diffstat (limited to 'clang/lib/Frontend/DiagnosticRenderer.cpp')
-rw-r--r--clang/lib/Frontend/DiagnosticRenderer.cpp31
1 files changed, 27 insertions, 4 deletions
diff --git a/clang/lib/Frontend/DiagnosticRenderer.cpp b/clang/lib/Frontend/DiagnosticRenderer.cpp
index 548a4a833ce..29f9ed5a7d4 100644
--- a/clang/lib/Frontend/DiagnosticRenderer.cpp
+++ b/clang/lib/Frontend/DiagnosticRenderer.cpp
@@ -133,9 +133,9 @@ void DiagnosticRenderer::emitDiagnostic(SourceLocation Loc,
StringRef Message,
ArrayRef<CharSourceRange> Ranges,
ArrayRef<FixItHint> FixItHints,
- const Diagnostic *Info) {
+ DiagOrStoredDiag D) {
- beginDiagnostic(Info, Level);
+ beginDiagnostic(D, Level);
PresumedLoc PLoc = getDiagnosticPresumedLoc(SM, Loc);
@@ -144,7 +144,7 @@ void DiagnosticRenderer::emitDiagnostic(SourceLocation Loc,
emitIncludeStack(PLoc.getIncludeLoc(), Level);
// Next, emit the actual diagnostic message.
- emitDiagnosticMessage(Loc, PLoc, Level, Message, Ranges, Info);
+ emitDiagnosticMessage(Loc, PLoc, Level, Message, Ranges, D);
// Only recurse if we have a valid location.
if (Loc.isValid()) {
@@ -166,7 +166,14 @@ void DiagnosticRenderer::emitDiagnostic(SourceLocation Loc,
LastLoc = Loc;
LastLevel = Level;
- endDiagnostic(Info, Level);
+ endDiagnostic(D, Level);
+}
+
+
+void DiagnosticRenderer::emitStoredDiagnostic(StoredDiagnostic &Diag) {
+ emitDiagnostic(Diag.getLocation(), Diag.getLevel(), Diag.getMessage(),
+ Diag.getRanges(), Diag.getFixIts(),
+ &Diag);
}
/// \brief Prints an include stack when appropriate for a particular
@@ -304,3 +311,19 @@ void DiagnosticRenderer::emitMacroExpansionsAndCarets(
Ranges, ArrayRef<FixItHint>());
}
+DiagnosticNoteRenderer::~DiagnosticNoteRenderer() {}
+
+void DiagnosticNoteRenderer::emitIncludeLocation(SourceLocation Loc,
+ PresumedLoc PLoc) {
+ // Generate a note indicating the include location.
+ SmallString<200> MessageStorage;
+ llvm::raw_svector_ostream Message(MessageStorage);
+ Message << "in file included from " << PLoc.getFilename() << ':'
+ << PLoc.getLine() << ":";
+ emitNote(Loc, Message.str());
+}
+
+void DiagnosticNoteRenderer::emitBasicNote(StringRef Message) {
+ emitNote(SourceLocation(), Message);
+}
+
OpenPOWER on IntegriCloud