Douglas Gregor | d93256e | 2010-01-28 06:00:51 +0000 | [diff] [blame] | 1 | /*===-- CIndexDiagnostic.h - Diagnostics C Interface ------------*- C++ -*-===*\ |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 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 | |* Implements the diagnostic functions of the Clang C interface. *| |
| 11 | |* *| |
| 12 | \*===----------------------------------------------------------------------===*/ |
| 13 | #ifndef LLVM_CLANG_CINDEX_DIAGNOSTIC_H |
| 14 | #define LLVM_CLANG_CINDEX_DIAGNOSTIC_H |
| 15 | |
| 16 | #include "clang-c/Index.h" |
| 17 | #include "clang/Basic/Diagnostic.h" |
| 18 | #include "clang/Basic/LangOptions.h" |
| 19 | |
Douglas Gregor | d93256e | 2010-01-28 06:00:51 +0000 | [diff] [blame] | 20 | namespace llvm { namespace sys { |
| 21 | class Path; |
| 22 | } } |
| 23 | |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 24 | namespace clang { |
| 25 | |
Douglas Gregor | d93256e | 2010-01-28 06:00:51 +0000 | [diff] [blame] | 26 | class Diagnostic; |
Daniel Dunbar | 35b8440 | 2010-01-30 23:31:40 +0000 | [diff] [blame] | 27 | class LangOptions; |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 28 | class Preprocessor; |
| 29 | |
| 30 | /** |
| 31 | * \brief Diagnostic client that translates Clang diagnostics into diagnostics |
| 32 | * for the C interface to Clang. |
| 33 | */ |
| 34 | class CIndexDiagnosticClient : public DiagnosticClient { |
| 35 | CXDiagnosticCallback Callback; |
| 36 | CXClientData ClientData; |
Daniel Dunbar | 4914612 | 2010-01-30 23:31:49 +0000 | [diff] [blame] | 37 | const LangOptions *LangOptsPtr; |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 38 | |
| 39 | public: |
| 40 | CIndexDiagnosticClient(CXDiagnosticCallback Callback, |
| 41 | CXClientData ClientData) |
Daniel Dunbar | 4914612 | 2010-01-30 23:31:49 +0000 | [diff] [blame] | 42 | : Callback(Callback), ClientData(ClientData), LangOptsPtr(0) { } |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 43 | |
| 44 | virtual ~CIndexDiagnosticClient(); |
| 45 | |
| 46 | virtual void BeginSourceFile(const LangOptions &LangOpts, |
| 47 | const Preprocessor *PP); |
| 48 | |
Daniel Dunbar | 4914612 | 2010-01-30 23:31:49 +0000 | [diff] [blame] | 49 | virtual void EndSourceFile(); |
| 50 | |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 51 | virtual void HandleDiagnostic(Diagnostic::Level DiagLevel, |
| 52 | const DiagnosticInfo &Info); |
| 53 | }; |
Douglas Gregor | d93256e | 2010-01-28 06:00:51 +0000 | [diff] [blame] | 54 | |
| 55 | /// \brief Given the path to a file that contains binary, serialized |
| 56 | /// diagnostics produced by Clang, emit those diagnostics via the |
| 57 | /// given diagnostic engine. |
| 58 | void ReportSerializedDiagnostics(const llvm::sys::Path &DiagnosticsPath, |
| 59 | Diagnostic &Diags, |
| 60 | unsigned num_unsaved_files, |
Daniel Dunbar | 35b8440 | 2010-01-30 23:31:40 +0000 | [diff] [blame] | 61 | struct CXUnsavedFile *unsaved_files, |
| 62 | const LangOptions &LangOpts); |
Douglas Gregor | d93256e | 2010-01-28 06:00:51 +0000 | [diff] [blame] | 63 | |
Douglas Gregor | 5352ac0 | 2010-01-28 00:27:43 +0000 | [diff] [blame] | 64 | } // end namespace clang |
| 65 | |
| 66 | #endif // LLVM_CLANG_CINDEX_DIAGNOSTIC_H |