clang API Documentation
00001 //===--- TextDiagnosticPrinter.h - Text Diagnostic Client -------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This is a concrete diagnostic client, which prints the diagnostics to 00011 // standard error. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_CLANG_FRONTEND_TEXT_DIAGNOSTIC_PRINTER_H_ 00016 #define LLVM_CLANG_FRONTEND_TEXT_DIAGNOSTIC_PRINTER_H_ 00017 00018 #include "clang/Basic/Diagnostic.h" 00019 #include "clang/Basic/LLVM.h" 00020 #include "llvm/ADT/OwningPtr.h" 00021 00022 namespace clang { 00023 class DiagnosticOptions; 00024 class LangOptions; 00025 class TextDiagnostic; 00026 00027 class TextDiagnosticPrinter : public DiagnosticConsumer { 00028 raw_ostream &OS; 00029 const DiagnosticOptions *DiagOpts; 00030 00031 /// \brief Handle to the currently active text diagnostic emitter. 00032 OwningPtr<TextDiagnostic> TextDiag; 00033 00034 /// A string to prefix to error messages. 00035 std::string Prefix; 00036 00037 unsigned OwnsOutputStream : 1; 00038 00039 public: 00040 TextDiagnosticPrinter(raw_ostream &os, const DiagnosticOptions &diags, 00041 bool OwnsOutputStream = false); 00042 virtual ~TextDiagnosticPrinter(); 00043 00044 /// setPrefix - Set the diagnostic printer prefix string, which will be 00045 /// printed at the start of any diagnostics. If empty, no prefix string is 00046 /// used. 00047 void setPrefix(std::string Value) { Prefix = Value; } 00048 00049 void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP); 00050 void EndSourceFile(); 00051 void HandleDiagnostic(DiagnosticsEngine::Level Level, const Diagnostic &Info); 00052 DiagnosticConsumer *clone(DiagnosticsEngine &Diags) const; 00053 }; 00054 00055 } // end namespace clang 00056 00057 #endif