blob: 5fef01e555ae3b1b054f1762cd969338b96005ea [file] [log] [blame]
Douglas Gregorac0605e2010-01-28 06:00:51 +00001/*===-- CIndexDiagnostic.h - Diagnostics C Interface ------------*- C++ -*-===*\
Douglas Gregor4f9c3762010-01-28 00:27:43 +00002|* *|
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 Gregorac0605e2010-01-28 06:00:51 +000020namespace llvm { namespace sys {
21class Path;
22} }
23
Douglas Gregor4f9c3762010-01-28 00:27:43 +000024namespace clang {
25
Douglas Gregorac0605e2010-01-28 06:00:51 +000026class Diagnostic;
Daniel Dunbar854d36b2010-01-30 23:31:40 +000027class LangOptions;
Douglas Gregor4f9c3762010-01-28 00:27:43 +000028class 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 LangOptions LangOpts;
38
39public:
40 CIndexDiagnosticClient(CXDiagnosticCallback Callback,
41 CXClientData ClientData)
42 : Callback(Callback), ClientData(ClientData), LangOpts() { }
43
44 virtual ~CIndexDiagnosticClient();
45
46 virtual void BeginSourceFile(const LangOptions &LangOpts,
47 const Preprocessor *PP);
48
49 virtual void HandleDiagnostic(Diagnostic::Level DiagLevel,
50 const DiagnosticInfo &Info);
51};
Douglas Gregorac0605e2010-01-28 06:00:51 +000052
53/// \brief Given the path to a file that contains binary, serialized
54/// diagnostics produced by Clang, emit those diagnostics via the
55/// given diagnostic engine.
56void ReportSerializedDiagnostics(const llvm::sys::Path &DiagnosticsPath,
57 Diagnostic &Diags,
58 unsigned num_unsaved_files,
Daniel Dunbar854d36b2010-01-30 23:31:40 +000059 struct CXUnsavedFile *unsaved_files,
60 const LangOptions &LangOpts);
Douglas Gregorac0605e2010-01-28 06:00:51 +000061
Douglas Gregor4f9c3762010-01-28 00:27:43 +000062} // end namespace clang
63
64#endif // LLVM_CLANG_CINDEX_DIAGNOSTIC_H