]> granicus.if.org Git - clang/blobdiff - include/clang/Frontend/TextDiagnosticPrinter.h
Header guard canonicalization, clang part.
[clang] / include / clang / Frontend / TextDiagnosticPrinter.h
index f5302947a5935ca3dbd01a6bb9853c32d274ca9b..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 DiagnosticClient {
-  llvm::raw_ostream &OS;
-  const LangOptions *LangOpts;
-  const DiagnosticOptions *DiagOpts;
+class TextDiagnosticPrinter : public DiagnosticConsumer {
+  raw_ostream &OS;
+  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(llvm::raw_ostream &os, const DiagnosticOptions &diags,
+  TextDiagnosticPrinter(raw_ostream &os, DiagnosticOptions *diags,
                         bool OwnsOutputStream = false);
   virtual ~TextDiagnosticPrinter();
 
@@ -45,34 +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(SourceLocation Loc, const SourceManager &SM);
-
-  void HighlightRange(const CharSourceRange &R,
-                      const SourceManager &SrcMgr,
-                      unsigned LineNo, FileID FID,
-                      std::string &CaretLine,
-                      const std::string &SourceLine);
-
-  void EmitCaretDiagnostic(SourceLocation Loc,
-                           CharSourceRange *Ranges, unsigned NumRanges,
-                           const SourceManager &SM,
-                           const FixItHint *Hints,
-                           unsigned NumHints,
-                           unsigned Columns,  
-                           unsigned OnMacroInst,
-                           unsigned MacroSkipStart,
-                           unsigned MacroSkipEnd);
-
-  virtual void HandleDiagnostic(Diagnostic::Level DiagLevel,
-                                const DiagnosticInfo &Info);
+  void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) override;
+  void EndSourceFile() override;
+  void HandleDiagnostic(DiagnosticsEngine::Level Level,
+                        const Diagnostic &Info) override;
 };
 
 } // end namespace clang