slang_diagnostic_buffer.h revision 9ef2f785e0cc490af678dfd685995dec787321ff
1#ifndef _SLANG_DIAGNOSTIC_BUFFER_HPP 2# define _SLANG_DIAGNOSTIC_BUFFER_HPP 3 4#include "llvm/Support/raw_ostream.h" 5 6#include "clang/Basic/Diagnostic.h" 7 8#include <string> 9 10namespace llvm { 11class 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 { mSOS->flush(); return mDiags; } 29 30 inline void reset() { this->mSOS->str().clear(); return; } 31 32 virtual ~DiagnosticBuffer(); 33}; 34} 35 36#endif // _SLANG_DIAGNOSTIC_BUFFER_HPP 37