From: Alp Toker Date: Sat, 21 Jun 2014 23:31:59 +0000 (+0000) Subject: DiagnosticRenderer: emit basic notes as real diagnostics X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=47f76959dbc864aac90c3ee86faa844a2a973f39;p=clang DiagnosticRenderer: emit basic notes as real diagnostics Fixes terminal column wrapping and vestigial 'note:' prefixes that would appear when using emitBasicNote(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211448 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Frontend/DiagnosticRenderer.h b/include/clang/Frontend/DiagnosticRenderer.h index 019eec5e0e..ce1dc90465 100644 --- a/include/clang/Frontend/DiagnosticRenderer.h +++ b/include/clang/Frontend/DiagnosticRenderer.h @@ -83,9 +83,7 @@ protected: DiagnosticsEngine::Level Level, ArrayRef Ranges, const SourceManager &SM) = 0; - - virtual void emitBasicNote(StringRef Message) = 0; - + virtual void emitCodeContext(SourceLocation Loc, DiagnosticsEngine::Level Level, SmallVectorImpl& Ranges, @@ -108,6 +106,7 @@ protected: private: + void emitBasicNote(StringRef Message); void emitIncludeStack(SourceLocation Loc, PresumedLoc PLoc, DiagnosticsEngine::Level Level, const SourceManager &SM); void emitIncludeStackRecursively(SourceLocation Loc, const SourceManager &SM); @@ -159,8 +158,6 @@ public: virtual ~DiagnosticNoteRenderer(); - void emitBasicNote(StringRef Message) override; - void emitIncludeLocation(SourceLocation Loc, PresumedLoc PLoc, const SourceManager &SM) override; diff --git a/include/clang/Frontend/TextDiagnostic.h b/include/clang/Frontend/TextDiagnostic.h index a76c2bb984..acebb90b70 100644 --- a/include/clang/Frontend/TextDiagnostic.h +++ b/include/clang/Frontend/TextDiagnostic.h @@ -95,8 +95,6 @@ protected: emitSnippetAndCaret(Loc, Level, Ranges, Hints, SM); } - void emitBasicNote(StringRef Message) override; - void emitIncludeLocation(SourceLocation Loc, PresumedLoc PLoc, const SourceManager &SM) override; diff --git a/lib/Frontend/DiagnosticRenderer.cpp b/lib/Frontend/DiagnosticRenderer.cpp index ce9fc0548c..cff32b852b 100644 --- a/lib/Frontend/DiagnosticRenderer.cpp +++ b/lib/Frontend/DiagnosticRenderer.cpp @@ -190,6 +190,12 @@ void DiagnosticRenderer::emitStoredDiagnostic(StoredDiagnostic &Diag) { &Diag); } +void DiagnosticRenderer::emitBasicNote(StringRef Message) { + emitDiagnosticMessage( + SourceLocation(), PresumedLoc(), DiagnosticsEngine::Note, Message, + ArrayRef(), nullptr, DiagOrStoredDiag()); +} + /// \brief Prints an include stack when appropriate for a particular /// diagnostic level and location. /// @@ -506,8 +512,3 @@ DiagnosticNoteRenderer::emitBuildingModuleLocation(SourceLocation Loc, Message << "while building module '" << ModuleName << ":"; emitNote(Loc, Message.str(), &SM); } - - -void DiagnosticNoteRenderer::emitBasicNote(StringRef Message) { - emitNote(SourceLocation(), Message, nullptr); -} diff --git a/lib/Frontend/TextDiagnostic.cpp b/lib/Frontend/TextDiagnostic.cpp index 840c280b51..847acf114e 100644 --- a/lib/Frontend/TextDiagnostic.cpp +++ b/lib/Frontend/TextDiagnostic.cpp @@ -870,12 +870,6 @@ void TextDiagnostic::emitDiagnosticLoc(SourceLocation Loc, PresumedLoc PLoc, OS << ' '; } -void TextDiagnostic::emitBasicNote(StringRef Message) { - // FIXME: Emit this as a real note diagnostic. - // FIXME: Format an actual diagnostic rather than a hard coded string. - OS << "note: " << Message << "\n"; -} - void TextDiagnostic::emitIncludeLocation(SourceLocation Loc, PresumedLoc PLoc, const SourceManager &SM) {