]> granicus.if.org Git - clang/blob - include/clang/Frontend/TextDiagnosticPrinter.h
Normalize .h guards.
[clang] / include / clang / Frontend / TextDiagnosticPrinter.h
1 //===--- TextDiagnosticPrinter.h - Text Diagnostic Client -------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This is a concrete diagnostic client, which prints the diagnostics to
11 // standard error.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_CLANG_FRONTEND_TEXT_DIAGNOSTIC_PRINTER_H_
16 #define LLVM_CLANG_FRONTEND_TEXT_DIAGNOSTIC_PRINTER_H_
17
18 #include "clang/Basic/Diagnostic.h"
19 #include "clang/Basic/SourceLocation.h"
20
21 namespace llvm {
22   class raw_ostream;
23 }
24
25 namespace clang {
26 class SourceManager;
27
28 class TextDiagnosticPrinter : public DiagnosticClient {
29   SourceLocation LastWarningLoc;
30   FullSourceLoc LastLoc;
31   llvm::raw_ostream &OS;
32   bool ShowColumn;
33   bool CaretDiagnostics;
34   bool ShowLocation;
35 public:
36   TextDiagnosticPrinter(llvm::raw_ostream &os, bool showColumn = true,
37                         bool caretDiagnistics = true, bool showLocation = true)
38     : OS(os), ShowColumn(showColumn), CaretDiagnostics(caretDiagnistics),
39       ShowLocation(showLocation) {}
40
41   void PrintIncludeStack(SourceLocation Loc, const SourceManager &SM);
42
43   void HighlightRange(const SourceRange &R,
44                       const SourceManager& SrcMgr,
45                       unsigned LineNo, FileID FID,
46                       std::string &CaretLine,
47                       const std::string &SourceLine);
48
49   void EmitCaretDiagnostic(SourceLocation Loc, 
50                            SourceRange *Ranges, unsigned NumRanges,
51                            SourceManager &SM,
52                            const CodeModificationHint *Hints = 0,
53                            unsigned NumHints = 0);
54   
55   virtual void HandleDiagnostic(Diagnostic::Level DiagLevel,
56                                 const DiagnosticInfo &Info);
57 };
58
59 } // end namspace clang
60
61 #endif