blob: e4da6273d8486941b903952b9006bea27e6f7a52 [file] [log] [blame]
Arnaud A. de Grandmaisondb293182012-06-30 11:27:57 +00001/*===-- clang-c/CXCompilationDatabase.h - Compilation database ---*- 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|* This header provides a public inferface to use CompilationDatabase without *|
11|* the full Clang C++ API. *|
12|* *|
13\*===----------------------------------------------------------------------===*/
14
15#ifndef CLANG_CXCOMPILATIONDATABASE_H
16#define CLANG_CXCOMPILATIONDATABASE_H
17
18#include "clang-c/Platform.h"
19#include "clang-c/CXString.h"
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/** \defgroup COMPILATIONDB CompilationDatabase functions
26 * \ingroup CINDEX
27 *
28 * @{
29 */
30
31/**
32 * \brief Represents clang::tooling::CompilationDatabase
33 *
34 * Must be freed by \c clang_tooling_CompilationDatabase_dispose
35 */
36typedef void * CXCompilationDatabase;
37
38/**
39 * \brief Contains the results of a search in the compilation database
40 *
41 * When searching for the compile command for a file, the compilation db can
42 * return several commands, as the file may have been compiled with
43 * different options in different places of the project. This choice of compile
44 * commands is wrapped in this opaque data structure. It must be freed by
45 * \c clang_tooling_CompileCommands_dispose.
46 */
47typedef void * CXCompileCommands;
48
49/**
50 * \brief Represents the command line invocation to compile a specific file.
51 */
52typedef void * CXCompileCommand;
53
54/**
55 * \brief Error codes for Compilation Database
56 */
57typedef enum {
58 /*
59 * \brief No error occured
60 */
61 CXCompilationDatabase_NoError = 0,
62
63 /*
64 * \brief Database can not be loaded
65 */
66 CXCompilationDatabase_CanNotLoadDatabase = 1
67
68} CXCompilationDatabase_Error;
69
70/**
71 * \brief Creates a compilation database from the database found in directory
72 * buildDir. It must be freed by \c clang_tooling_CompilationDatabase_dispose.
73 */
74CINDEX_LINKAGE CXCompilationDatabase
75clang_tooling_CompilationDatabase_fromDirectory(
76 const char *BuildDir,
77 CXCompilationDatabase_Error *ErrorCode);
78
79/**
80 * \brief Free the given compilation database
81 */
82CINDEX_LINKAGE void
83clang_tooling_CompilationDatabase_dispose(CXCompilationDatabase);
84
85/**
86 * \brief Find the compile commands used for a file. The compile commands
87 * must be freed by \c clang_tooling_CompileCommands_dispose.
88 */
89CINDEX_LINKAGE CXCompileCommands
90clang_tooling_CompilationDatabase_getCompileCommands(
91 CXCompilationDatabase,
92 const char *CompleteFileName);
93
94/**
95 * \brief Free the given CompileCommands
96 */
97CINDEX_LINKAGE void clang_tooling_CompileCommands_dispose(CXCompileCommands);
98
99/**
100 * \brief Get the number of CompileCommand we have for a file
101 */
102CINDEX_LINKAGE unsigned
103clang_tooling_CompileCommands_getSize(CXCompileCommands);
104
105/**
106 * \brief Get the I'th CompileCommand for a file
107 *
108 * Note : 0 <= i < clang_tooling_CompileCommands_getSize(CXCompileCommands)
109 */
110CINDEX_LINKAGE CXCompileCommand
111clang_tooling_CompileCommands_getCommand(CXCompileCommands, unsigned I);
112
113/**
114 * \brief Get the working directory where the CompileCommand was executed from
115 */
116CINDEX_LINKAGE CXString
117clang_tooling_CompileCommand_getDirectory(CXCompileCommand);
118
119/**
120 * \brief Get the number of arguments in the compiler invocation.
121 *
122 */
123CINDEX_LINKAGE unsigned
124clang_tooling_CompileCommand_getNumArgs(CXCompileCommand);
125
126/**
127 * \brief Get the I'th argument value in the compiler invocations
128 *
129 * Invariant :
130 * - argument 0 is the compiler executable
131 */
132CINDEX_LINKAGE CXString
133clang_tooling_CompileCommand_getArg(CXCompileCommand, unsigned I);
134
135/**
136 * @}
137 */
138
139#ifdef __cplusplus
140}
141#endif
142#endif
143