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 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 15 | #ifndef LLVM_CLANG_FRONTEND_TEXTDIAGNOSTICPRINTER_H |
| 16 | #define LLVM_CLANG_FRONTEND_TEXTDIAGNOSTICPRINTER_H |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 17 | |
Nico Weber | 7bfaaae | 2008-08-10 19:59:06 +0000 | [diff] [blame] | 18 | #include "clang/Basic/Diagnostic.h" |
Chandler Carruth | 21a869a | 2011-10-16 02:57:39 +0000 | [diff] [blame] | 19 | #include "clang/Basic/LLVM.h" |
Douglas Gregor | 02c23eb | 2012-10-23 22:26:28 +0000 | [diff] [blame] | 20 | #include "llvm/ADT/IntrusiveRefCntPtr.h" |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 21 | #include <memory> |
Chris Lattner | a03a5b5 | 2008-11-19 06:56:25 +0000 | [diff] [blame] | 22 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 23 | namespace clang { |
Daniel Dunbar | eace874 | 2009-11-04 06:24:30 +0000 | [diff] [blame] | 24 | class DiagnosticOptions; |
Chris Lattner | 2c78b87 | 2009-04-14 23:22:57 +0000 | [diff] [blame] | 25 | class LangOptions; |
Chandler Carruth | 21a869a | 2011-10-16 02:57:39 +0000 | [diff] [blame] | 26 | class TextDiagnostic; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 27 | |
David Blaikie | 78ad0b9 | 2011-09-25 23:39:51 +0000 | [diff] [blame] | 28 | class TextDiagnosticPrinter : public DiagnosticConsumer { |
Chris Lattner | 8cc488f | 2011-07-20 07:06:53 +0000 | [diff] [blame] | 29 | raw_ostream &OS; |
Dmitri Gribenko | cfa88f8 | 2013-01-12 19:30:44 +0000 | [diff] [blame] | 30 | IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts; |
Daniel Dunbar | eace874 | 2009-11-04 06:24:30 +0000 | [diff] [blame] | 31 | |
Chandler Carruth | 21a869a | 2011-10-16 02:57:39 +0000 | [diff] [blame] | 32 | /// \brief Handle to the currently active text diagnostic emitter. |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 33 | std::unique_ptr<TextDiagnostic> TextDiag; |
Chris Lattner | 2c78b87 | 2009-04-14 23:22:57 +0000 | [diff] [blame] | 34 | |
Daniel Dunbar | b96b670 | 2010-02-25 03:23:40 +0000 | [diff] [blame] | 35 | /// A string to prefix to error messages. |
| 36 | std::string Prefix; |
| 37 | |
Chandler Carruth | 21a869a | 2011-10-16 02:57:39 +0000 | [diff] [blame] | 38 | unsigned OwnsOutputStream : 1; |
| 39 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 40 | public: |
Douglas Gregor | 02c23eb | 2012-10-23 22:26:28 +0000 | [diff] [blame] | 41 | TextDiagnosticPrinter(raw_ostream &os, DiagnosticOptions *diags, |
Daniel Dunbar | aea3641 | 2009-11-11 09:38:24 +0000 | [diff] [blame] | 42 | bool OwnsOutputStream = false); |
Pirama Arumuga Nainar | 33337ca | 2015-05-06 11:48:57 -0700 | [diff] [blame] | 43 | ~TextDiagnosticPrinter() override; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 44 | |
Daniel Dunbar | b96b670 | 2010-02-25 03:23:40 +0000 | [diff] [blame] | 45 | /// setPrefix - Set the diagnostic printer prefix string, which will be |
| 46 | /// printed at the start of any diagnostics. If empty, no prefix string is |
| 47 | /// used. |
| 48 | void setPrefix(std::string Value) { Prefix = Value; } |
| 49 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 50 | void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) override; |
| 51 | void EndSourceFile() override; |
| 52 | void HandleDiagnostic(DiagnosticsEngine::Level Level, |
| 53 | const Diagnostic &Info) override; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 54 | }; |
| 55 | |
Douglas Gregor | 6c1cb99 | 2010-05-04 17:13:42 +0000 | [diff] [blame] | 56 | } // end namespace clang |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 57 | |
| 58 | #endif |