]> granicus.if.org Git - clang/blobdiff - include/clang/Frontend/TextDiagnosticPrinter.h
Header guard canonicalization, clang part.
[clang] / include / clang / Frontend / TextDiagnosticPrinter.h
index be8b2984c4052c87c7f127983b311f30b1bb033d..f8a71fe5e0f630defa254309b8add3446588ccfd 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_CLANG_FRONTEND_TEXT_DIAGNOSTIC_PRINTER_H_
-#define LLVM_CLANG_FRONTEND_TEXT_DIAGNOSTIC_PRINTER_H_
+#ifndef LLVM_CLANG_FRONTEND_TEXTDIAGNOSTICPRINTER_H
+#define LLVM_CLANG_FRONTEND_TEXTDIAGNOSTICPRINTER_H
 
 #include "clang/Basic/Diagnostic.h"
-#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/LLVM.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include <memory>
 
 namespace clang {
 class DiagnosticOptions;
 class LangOptions;
+class TextDiagnostic;
 
 class TextDiagnosticPrinter : public DiagnosticConsumer {
   raw_ostream &OS;
-  const LangOptions *LangOpts;
-  const DiagnosticOptions *DiagOpts;
+  IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
 
-  SourceLocation LastWarningLoc;
-  FullSourceLoc LastLoc;
-  unsigned LastCaretDiagnosticWasNote : 1;
-  unsigned OwnsOutputStream : 1;
+  /// \brief Handle to the currently active text diagnostic emitter.
+  std::unique_ptr<TextDiagnostic> TextDiag;
 
   /// A string to prefix to error messages.
   std::string Prefix;
 
+  unsigned OwnsOutputStream : 1;
+
 public:
-  TextDiagnosticPrinter(raw_ostream &os, const DiagnosticOptions &diags,
+  TextDiagnosticPrinter(raw_ostream &os, DiagnosticOptions *diags,
                         bool OwnsOutputStream = false);
   virtual ~TextDiagnosticPrinter();
 
@@ -45,27 +47,10 @@ public:
   /// used.
   void setPrefix(std::string Value) { Prefix = Value; }
 
-  void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) {
-    LangOpts = &LO;
-  }
-
-  void EndSourceFile() {
-    LangOpts = 0;
-  }
-
-  void PrintIncludeStack(DiagnosticsEngine::Level Level, SourceLocation Loc,
-                         const SourceManager &SM);
-
-  virtual void HandleDiagnostic(DiagnosticsEngine::Level Level,
-                                const Diagnostic &Info);
-
-  DiagnosticConsumer *clone(DiagnosticsEngine &Diags) const;
-
-private:
-  void EmitDiagnosticLoc(SourceLocation Loc, PresumedLoc PLoc,
-                         DiagnosticsEngine::Level Level,
-                         ArrayRef<CharSourceRange> Ranges,
-                         const SourceManager &SM);
+  void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) override;
+  void EndSourceFile() override;
+  void HandleDiagnostic(DiagnosticsEngine::Level Level,
+                        const Diagnostic &Info) override;
 };
 
 } // end namespace clang