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"
29 class TextDiagnosticPrinter : public DiagnosticClient {
30 llvm::raw_ostream &OS;
31 const LangOptions *LangOpts;
32 SourceLocation LastWarningLoc;
33 FullSourceLoc LastLoc;
34 bool LastCaretDiagnosticWasNote;
37 bool CaretDiagnostics;
40 bool PrintDiagnosticOption;
42 unsigned MessageLength;
45 TextDiagnosticPrinter(llvm::raw_ostream &os,
46 bool showColumn = true,
47 bool caretDiagnistics = true, bool showLocation = true,
48 bool printRangeInfo = true,
49 bool printDiagnosticOption = true,
50 bool printFixItInfo = true,
51 unsigned messageLength = 0)
52 : OS(os), LangOpts(0),
53 LastCaretDiagnosticWasNote(false), ShowColumn(showColumn),
54 CaretDiagnostics(caretDiagnistics), ShowLocation(showLocation),
55 PrintRangeInfo(printRangeInfo),
56 PrintDiagnosticOption(printDiagnosticOption),
57 PrintFixItInfo(printFixItInfo),
58 MessageLength(messageLength) {}
60 void setLangOptions(const LangOptions *LO) {
64 void PrintIncludeStack(SourceLocation Loc, const SourceManager &SM);
66 void HighlightRange(const SourceRange &R,
67 const SourceManager &SrcMgr,
68 unsigned LineNo, FileID FID,
69 std::string &CaretLine,
70 const std::string &SourceLine);
72 void EmitCaretDiagnostic(SourceLocation Loc,
73 SourceRange *Ranges, unsigned NumRanges,
75 const CodeModificationHint *Hints,
77 unsigned AvoidColumn);
79 virtual void HandleDiagnostic(Diagnostic::Level DiagLevel,
80 const DiagnosticInfo &Info);
83 } // end namspace clang