CIndexDiagnostic.h revision 4914612675787cda11ad6b31735e130a81a1d7a1
1/*===-- CIndexDiagnostic.h - Diagnostics C Interface ------------*- 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|* 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
20namespace llvm { namespace sys {
21class Path;
22} }
23
24namespace clang {
25
26class Diagnostic;
27class LangOptions;
28class Preprocessor;
29
30/**
31 * \brief Diagnostic client that translates Clang diagnostics into diagnostics
32 * for the C interface to Clang.
33 */
34class CIndexDiagnosticClient : public DiagnosticClient {
35  CXDiagnosticCallback Callback;
36  CXClientData ClientData;
37  const LangOptions *LangOptsPtr;
38
39public:
40  CIndexDiagnosticClient(CXDiagnosticCallback Callback,
41                         CXClientData ClientData)
42    : Callback(Callback), ClientData(ClientData), LangOptsPtr(0) { }
43
44  virtual ~CIndexDiagnosticClient();
45
46  virtual void BeginSourceFile(const LangOptions &LangOpts,
47                               const Preprocessor *PP);
48
49  virtual void EndSourceFile();
50
51  virtual void HandleDiagnostic(Diagnostic::Level DiagLevel,
52                                const DiagnosticInfo &Info);
53};
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.
58void ReportSerializedDiagnostics(const llvm::sys::Path &DiagnosticsPath,
59                                 Diagnostic &Diags,
60                                 unsigned num_unsaved_files,
61                                 struct CXUnsavedFile *unsaved_files,
62                                 const LangOptions &LangOpts);
63
64} // end namespace clang
65
66#endif // LLVM_CLANG_CINDEX_DIAGNOSTIC_H
67