blob: 9f7ae51a108307e119dd0e68fc03cf62bd248240 [file] [log] [blame]
Douglas Gregord93256e2010-01-28 06:00:51 +00001/*===-- CIndexDiagnostic.h - Diagnostics C Interface ------------*- C++ -*-===*\
Douglas Gregor5352ac02010-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 Gregord93256e2010-01-28 06:00:51 +000020namespace llvm { namespace sys {
21class Path;
22} }
23
Douglas Gregor5352ac02010-01-28 00:27:43 +000024namespace clang {
25
Douglas Gregord93256e2010-01-28 06:00:51 +000026class Diagnostic;
Daniel Dunbar35b84402010-01-30 23:31:40 +000027class LangOptions;
Douglas Gregor5352ac02010-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;
Daniel Dunbar49146122010-01-30 23:31:49 +000037 const LangOptions *LangOptsPtr;
Douglas Gregor5352ac02010-01-28 00:27:43 +000038
39public:
40 CIndexDiagnosticClient(CXDiagnosticCallback Callback,
41 CXClientData ClientData)
Daniel Dunbar49146122010-01-30 23:31:49 +000042 : Callback(Callback), ClientData(ClientData), LangOptsPtr(0) { }
Douglas Gregor5352ac02010-01-28 00:27:43 +000043
44 virtual ~CIndexDiagnosticClient();
45
46 virtual void BeginSourceFile(const LangOptions &LangOpts,
47 const Preprocessor *PP);
48
Daniel Dunbar49146122010-01-30 23:31:49 +000049 virtual void EndSourceFile();
50
Douglas Gregor5352ac02010-01-28 00:27:43 +000051 virtual void HandleDiagnostic(Diagnostic::Level DiagLevel,
52 const DiagnosticInfo &Info);
53};
Douglas Gregord93256e2010-01-28 06:00:51 +000054
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,
Daniel Dunbar35b84402010-01-30 23:31:40 +000061 struct CXUnsavedFile *unsaved_files,
62 const LangOptions &LangOpts);
Douglas Gregord93256e2010-01-28 06:00:51 +000063
Douglas Gregor5352ac02010-01-28 00:27:43 +000064} // end namespace clang
65
66#endif // LLVM_CLANG_CINDEX_DIAGNOSTIC_H