DiagnosticRenderer: emit basic notes as real diagnostics
authorAlp Toker <alp@nuanti.com>
Sat, 21 Jun 2014 23:31:59 +0000 (23:31 +0000)
committerAlp Toker <alp@nuanti.com>
Sat, 21 Jun 2014 23:31:59 +0000 (23:31 +0000)
Fixes terminal column wrapping and vestigial 'note:' prefixes that would appear
when using emitBasicNote().

llvm-svn: 211448

clang/include/clang/Frontend/DiagnosticRenderer.h
clang/include/clang/Frontend/TextDiagnostic.h
clang/lib/Frontend/DiagnosticRenderer.cpp
clang/lib/Frontend/TextDiagnostic.cpp

index 019eec5..ce1dc90 100644 (file)
@@ -83,9 +83,7 @@ protected:
                                  DiagnosticsEngine::Level Level,
                                  ArrayRef<CharSourceRange> Ranges,
                                  const SourceManager &SM) = 0;
-  
-  virtual void emitBasicNote(StringRef Message) = 0;
-  
+
   virtual void emitCodeContext(SourceLocation Loc,
                                DiagnosticsEngine::Level Level,
                                SmallVectorImpl<CharSourceRange>& 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;
 
index a76c2bb..acebb90 100644 (file)
@@ -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;
 
index ce9fc05..cff32b8 100644 (file)
@@ -190,6 +190,12 @@ void DiagnosticRenderer::emitStoredDiagnostic(StoredDiagnostic &Diag) {
                  &Diag);
 }
 
+void DiagnosticRenderer::emitBasicNote(StringRef Message) {
+  emitDiagnosticMessage(
+      SourceLocation(), PresumedLoc(), DiagnosticsEngine::Note, Message,
+      ArrayRef<CharSourceRange>(), 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);
-}
index 840c280..847acf1 100644 (file)
@@ -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) {