|
|
|||
File indexing completed on 2026-05-10 08:36:17
0001 /*===-- clang-c/CXCompilationDatabase.h - Compilation database ---*- C -*-===*\ 0002 |* *| 0003 |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| 0004 |* Exceptions. *| 0005 |* See https://llvm.org/LICENSE.txt for license information. *| 0006 |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| 0007 |* *| 0008 |*===----------------------------------------------------------------------===*| 0009 |* *| 0010 |* This header provides a public interface to use CompilationDatabase without *| 0011 |* the full Clang C++ API. *| 0012 |* *| 0013 \*===----------------------------------------------------------------------===*/ 0014 0015 #ifndef LLVM_CLANG_C_CXCOMPILATIONDATABASE_H 0016 #define LLVM_CLANG_C_CXCOMPILATIONDATABASE_H 0017 0018 #include "clang-c/CXString.h" 0019 #include "clang-c/ExternC.h" 0020 #include "clang-c/Platform.h" 0021 0022 LLVM_CLANG_C_EXTERN_C_BEGIN 0023 0024 /** \defgroup COMPILATIONDB CompilationDatabase functions 0025 * \ingroup CINDEX 0026 * 0027 * @{ 0028 */ 0029 0030 /** 0031 * A compilation database holds all information used to compile files in a 0032 * project. For each file in the database, it can be queried for the working 0033 * directory or the command line used for the compiler invocation. 0034 * 0035 * Must be freed by \c clang_CompilationDatabase_dispose 0036 */ 0037 typedef void * CXCompilationDatabase; 0038 0039 /** 0040 * Contains the results of a search in the compilation database 0041 * 0042 * When searching for the compile command for a file, the compilation db can 0043 * return several commands, as the file may have been compiled with 0044 * different options in different places of the project. This choice of compile 0045 * commands is wrapped in this opaque data structure. It must be freed by 0046 * \c clang_CompileCommands_dispose. 0047 */ 0048 typedef void * CXCompileCommands; 0049 0050 /** 0051 * Represents the command line invocation to compile a specific file. 0052 */ 0053 typedef void * CXCompileCommand; 0054 0055 /** 0056 * Error codes for Compilation Database 0057 */ 0058 typedef enum { 0059 /* 0060 * No error occurred 0061 */ 0062 CXCompilationDatabase_NoError = 0, 0063 0064 /* 0065 * Database can not be loaded 0066 */ 0067 CXCompilationDatabase_CanNotLoadDatabase = 1 0068 0069 } CXCompilationDatabase_Error; 0070 0071 /** 0072 * Creates a compilation database from the database found in directory 0073 * buildDir. For example, CMake can output a compile_commands.json which can 0074 * be used to build the database. 0075 * 0076 * It must be freed by \c clang_CompilationDatabase_dispose. 0077 */ 0078 CINDEX_LINKAGE CXCompilationDatabase 0079 clang_CompilationDatabase_fromDirectory(const char *BuildDir, 0080 CXCompilationDatabase_Error *ErrorCode); 0081 0082 /** 0083 * Free the given compilation database 0084 */ 0085 CINDEX_LINKAGE void 0086 clang_CompilationDatabase_dispose(CXCompilationDatabase); 0087 0088 /** 0089 * Find the compile commands used for a file. The compile commands 0090 * must be freed by \c clang_CompileCommands_dispose. 0091 */ 0092 CINDEX_LINKAGE CXCompileCommands 0093 clang_CompilationDatabase_getCompileCommands(CXCompilationDatabase, 0094 const char *CompleteFileName); 0095 0096 /** 0097 * Get all the compile commands in the given compilation database. 0098 */ 0099 CINDEX_LINKAGE CXCompileCommands 0100 clang_CompilationDatabase_getAllCompileCommands(CXCompilationDatabase); 0101 0102 /** 0103 * Free the given CompileCommands 0104 */ 0105 CINDEX_LINKAGE void clang_CompileCommands_dispose(CXCompileCommands); 0106 0107 /** 0108 * Get the number of CompileCommand we have for a file 0109 */ 0110 CINDEX_LINKAGE unsigned 0111 clang_CompileCommands_getSize(CXCompileCommands); 0112 0113 /** 0114 * Get the I'th CompileCommand for a file 0115 * 0116 * Note : 0 <= i < clang_CompileCommands_getSize(CXCompileCommands) 0117 */ 0118 CINDEX_LINKAGE CXCompileCommand 0119 clang_CompileCommands_getCommand(CXCompileCommands, unsigned I); 0120 0121 /** 0122 * Get the working directory where the CompileCommand was executed from 0123 */ 0124 CINDEX_LINKAGE CXString 0125 clang_CompileCommand_getDirectory(CXCompileCommand); 0126 0127 /** 0128 * Get the filename associated with the CompileCommand. 0129 */ 0130 CINDEX_LINKAGE CXString 0131 clang_CompileCommand_getFilename(CXCompileCommand); 0132 0133 /** 0134 * Get the number of arguments in the compiler invocation. 0135 * 0136 */ 0137 CINDEX_LINKAGE unsigned 0138 clang_CompileCommand_getNumArgs(CXCompileCommand); 0139 0140 /** 0141 * Get the I'th argument value in the compiler invocations 0142 * 0143 * Invariant : 0144 * - argument 0 is the compiler executable 0145 */ 0146 CINDEX_LINKAGE CXString 0147 clang_CompileCommand_getArg(CXCompileCommand, unsigned I); 0148 0149 /** 0150 * Get the number of source mappings for the compiler invocation. 0151 */ 0152 CINDEX_LINKAGE unsigned 0153 clang_CompileCommand_getNumMappedSources(CXCompileCommand); 0154 0155 /** 0156 * Get the I'th mapped source path for the compiler invocation. 0157 */ 0158 CINDEX_LINKAGE CXString 0159 clang_CompileCommand_getMappedSourcePath(CXCompileCommand, unsigned I); 0160 0161 /** 0162 * Get the I'th mapped source content for the compiler invocation. 0163 */ 0164 CINDEX_LINKAGE CXString 0165 clang_CompileCommand_getMappedSourceContent(CXCompileCommand, unsigned I); 0166 0167 /** 0168 * @} 0169 */ 0170 0171 LLVM_CLANG_C_EXTERN_C_END 0172 0173 #endif 0174
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|