1 //===--- TextDiagnosticPrinter.h - Text Diagnostic Client -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This is a concrete diagnostic client, which prints the diagnostics to
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CLANG_FRONTEND_TEXT_DIAGNOSTIC_PRINTER_H_
16 #define LLVM_CLANG_FRONTEND_TEXT_DIAGNOSTIC_PRINTER_H_
18 #include "clang/Basic/Diagnostic.h"
19 #include "clang/Basic/SourceLocation.h"
22 class DiagnosticOptions;
25 class TextDiagnosticPrinter : public DiagnosticClient {
27 const LangOptions *LangOpts;
28 const DiagnosticOptions *DiagOpts;
30 SourceLocation LastWarningLoc;
31 FullSourceLoc LastLoc;
32 unsigned LastCaretDiagnosticWasNote : 1;
33 unsigned OwnsOutputStream : 1;
35 /// A string to prefix to error messages.
39 TextDiagnosticPrinter(raw_ostream &os, const DiagnosticOptions &diags,
40 bool OwnsOutputStream = false);
41 virtual ~TextDiagnosticPrinter();
43 /// setPrefix - Set the diagnostic printer prefix string, which will be
44 /// printed at the start of any diagnostics. If empty, no prefix string is
46 void setPrefix(std::string Value) { Prefix = Value; }
48 void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) {
52 void EndSourceFile() {
56 void PrintIncludeStack(Diagnostic::Level Level, SourceLocation Loc,
57 const SourceManager &SM);
59 virtual void HandleDiagnostic(Diagnostic::Level Level,
60 const DiagnosticInfo &Info);
63 void EmitDiagnosticLoc(Diagnostic::Level Level,
64 const DiagnosticInfo &Info,
65 const SourceManager &SM,
68 void EmitCaretDiagnostic(SourceLocation Loc,
69 SmallVectorImpl<CharSourceRange> &Ranges,
70 const SourceManager &SM,
71 ArrayRef<FixItHint> Hints, unsigned Columns);
75 } // end namespace clang