slang_diagnostic_buffer.h revision 6315f76e3cc6ff2d012d1183a0b030d4ff0dc808
1#ifndef _SLANG_DIAGNOSTIC_BUFFER_H 2#define _SLANG_DIAGNOSTIC_BUFFER_H 3 4#include "llvm/Support/raw_ostream.h" 5 6#include "clang/Basic/Diagnostic.h" 7 8#include <string> 9 10namespace llvm { 11 class raw_string_ostream; 12} 13 14namespace slang { 15 16// The diagnostics client instance (for reading the processed diagnostics) 17class DiagnosticBuffer : public clang::DiagnosticClient { 18 private: 19 std::string mDiags; 20 llvm::raw_string_ostream *mSOS; 21 22 public: 23 DiagnosticBuffer(); 24 25 virtual void HandleDiagnostic(clang::Diagnostic::Level DiagLevel, 26 const clang::DiagnosticInfo& Info); 27 28 inline const std::string &str() const { 29 mSOS->flush(); 30 return mDiags; 31 } 32 33 inline void reset() { 34 this->mSOS->str().clear(); 35 return; 36 } 37 38 virtual ~DiagnosticBuffer(); 39}; 40} 41 42#endif // _SLANG_DIAGNOSTIC_BUFFER_H 43