1 //===--- TextDiagnosticBuffer.h - Buffer Text Diagnostics -------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This is a concrete diagnostic client, which buffers the diagnostic messages. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_CLANG_FRONTEND_TEXTDIAGNOSTICBUFFER_H 15 #define LLVM_CLANG_FRONTEND_TEXTDIAGNOSTICBUFFER_H 16 17 #include "clang/Basic/Diagnostic.h" 18 #include <vector> 19 20 namespace clang { 21 22 class Preprocessor; 23 class SourceManager; 24 25 class TextDiagnosticBuffer : public DiagnosticConsumer { 26 public: 27 typedef std::vector<std::pair<SourceLocation, std::string> > DiagList; 28 typedef DiagList::iterator iterator; 29 typedef DiagList::const_iterator const_iterator; 30 private: 31 DiagList Errors, Warnings, Remarks, Notes; 32 public: err_begin()33 const_iterator err_begin() const { return Errors.begin(); } err_end()34 const_iterator err_end() const { return Errors.end(); } 35 warn_begin()36 const_iterator warn_begin() const { return Warnings.begin(); } warn_end()37 const_iterator warn_end() const { return Warnings.end(); } 38 remark_begin()39 const_iterator remark_begin() const { return Remarks.begin(); } remark_end()40 const_iterator remark_end() const { return Remarks.end(); } 41 note_begin()42 const_iterator note_begin() const { return Notes.begin(); } note_end()43 const_iterator note_end() const { return Notes.end(); } 44 45 void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, 46 const Diagnostic &Info) override; 47 48 /// FlushDiagnostics - Flush the buffered diagnostics to an given 49 /// diagnostic engine. 50 void FlushDiagnostics(DiagnosticsEngine &Diags) const; 51 }; 52 53 } // end namspace clang 54 55 #endif 56