Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1 | //===--- TextDiagnosticPrinter.h - Text Diagnostic Client -------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 0bc735f | 2007-12-29 19:59:25 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This is a concrete diagnostic client, which prints the diagnostics to |
| 11 | // standard error. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef TEXT_DIAGNOSTIC_PRINTER_H_ |
| 16 | #define TEXT_DIAGNOSTIC_PRINTER_H_ |
| 17 | |
| 18 | #include "TextDiagnostics.h" |
| 19 | #include "clang/Basic/SourceLocation.h" |
Nate Begeman | 165b954 | 2008-04-17 18:06:57 +0000 | [diff] [blame] | 20 | #include "llvm/Support/Streams.h" |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 21 | |
| 22 | namespace clang { |
| 23 | class SourceManager; |
| 24 | |
| 25 | class TextDiagnosticPrinter : public TextDiagnostics { |
Ted Kremenek | 9c728dc | 2007-12-12 22:39:36 +0000 | [diff] [blame] | 26 | FullSourceLoc LastWarningLoc; |
Steve Naroff | efe7f36 | 2008-02-08 22:06:17 +0000 | [diff] [blame] | 27 | FullSourceLoc LastLoc; |
Nate Begeman | 165b954 | 2008-04-17 18:06:57 +0000 | [diff] [blame] | 28 | llvm::OStream OS; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 29 | public: |
Nate Begeman | 165b954 | 2008-04-17 18:06:57 +0000 | [diff] [blame] | 30 | TextDiagnosticPrinter(llvm::OStream &os = llvm::cerr) : OS(os) {} |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 31 | |
Ted Kremenek | 9c728dc | 2007-12-12 22:39:36 +0000 | [diff] [blame] | 32 | void PrintIncludeStack(FullSourceLoc Pos); |
| 33 | |
Ted Kremenek | 7a9d49f | 2007-12-11 21:27:55 +0000 | [diff] [blame] | 34 | void HighlightRange(const SourceRange &R, |
Ted Kremenek | 9c728dc | 2007-12-12 22:39:36 +0000 | [diff] [blame] | 35 | SourceManager& SrcMgr, |
Chris Lattner | e41b7cd | 2008-01-12 06:43:35 +0000 | [diff] [blame] | 36 | unsigned LineNo, unsigned FileID, |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 37 | std::string &CaratLine, |
| 38 | const std::string &SourceLine); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 39 | |
Ted Kremenek | 9c728dc | 2007-12-12 22:39:36 +0000 | [diff] [blame] | 40 | virtual void HandleDiagnostic(Diagnostic &Diags, |
| 41 | Diagnostic::Level DiagLevel, |
| 42 | FullSourceLoc Pos, |
Ted Kremenek | 7a9d49f | 2007-12-11 21:27:55 +0000 | [diff] [blame] | 43 | diag::kind ID, |
Ted Kremenek | 7a9d49f | 2007-12-11 21:27:55 +0000 | [diff] [blame] | 44 | const std::string *Strs, |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 45 | unsigned NumStrs, |
| 46 | const SourceRange *Ranges, |
| 47 | unsigned NumRanges); |
| 48 | }; |
| 49 | |
| 50 | } // end namspace clang |
| 51 | |
| 52 | #endif |