Explorar el Código

Add TextDiagnosticBuffer::FlushDiagnostics, for forwarding the buffered diagnostics to a different diagnostics engine.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90125 91177308-0d34-0410-b5e6-96231b3b80d8
Daniel Dunbar hace 15 años
padre
commit
c238955f09

+ 4 - 0
include/clang/Frontend/TextDiagnosticBuffer.h

@@ -41,6 +41,10 @@ public:
 
   virtual void HandleDiagnostic(Diagnostic::Level DiagLevel,
                                 const DiagnosticInfo &Info);
+
+  /// FlushDiagnostics - Flush the buffered diagnostics to an given
+  /// diagnostic engine.
+  void FlushDiagnostics(Diagnostic &Diags) const;
 };
 
 } // end namspace clang

+ 10 - 0
lib/Frontend/TextDiagnosticBuffer.cpp

@@ -36,3 +36,13 @@ void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic::Level Level,
     break;
   }
 }
+
+void TextDiagnosticBuffer::FlushDiagnostics(Diagnostic &Diags) const {
+  // FIXME: Flush the diagnostics in order.
+  for (const_iterator it = err_begin(), ie = err_end(); it != ie; ++it)
+    Diags.Report(Diags.getCustomDiagID(Diagnostic::Error, it->second.c_str()));
+  for (const_iterator it = warn_begin(), ie = warn_end(); it != ie; ++it)
+    Diags.Report(Diags.getCustomDiagID(Diagnostic::Warning,it->second.c_str()));
+  for (const_iterator it = note_begin(), ie = note_end(); it != ie; ++it)
+    Diags.Report(Diags.getCustomDiagID(Diagnostic::Note, it->second.c_str()));
+}