Path: blob/main/contrib/llvm-project/clang/include/clang-c/CXCompilationDatabase.h
35234 views
/*===-- clang-c/CXCompilationDatabase.h - Compilation database ---*- C -*-===*\1|* *|2|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|3|* Exceptions. *|4|* See https://llvm.org/LICENSE.txt for license information. *|5|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|6|* *|7|*===----------------------------------------------------------------------===*|8|* *|9|* This header provides a public interface to use CompilationDatabase without *|10|* the full Clang C++ API. *|11|* *|12\*===----------------------------------------------------------------------===*/1314#ifndef LLVM_CLANG_C_CXCOMPILATIONDATABASE_H15#define LLVM_CLANG_C_CXCOMPILATIONDATABASE_H1617#include "clang-c/CXString.h"18#include "clang-c/ExternC.h"19#include "clang-c/Platform.h"2021LLVM_CLANG_C_EXTERN_C_BEGIN2223/** \defgroup COMPILATIONDB CompilationDatabase functions24* \ingroup CINDEX25*26* @{27*/2829/**30* A compilation database holds all information used to compile files in a31* project. For each file in the database, it can be queried for the working32* directory or the command line used for the compiler invocation.33*34* Must be freed by \c clang_CompilationDatabase_dispose35*/36typedef void * CXCompilationDatabase;3738/**39* Contains the results of a search in the compilation database40*41* When searching for the compile command for a file, the compilation db can42* return several commands, as the file may have been compiled with43* different options in different places of the project. This choice of compile44* commands is wrapped in this opaque data structure. It must be freed by45* \c clang_CompileCommands_dispose.46*/47typedef void * CXCompileCommands;4849/**50* Represents the command line invocation to compile a specific file.51*/52typedef void * CXCompileCommand;5354/**55* Error codes for Compilation Database56*/57typedef enum {58/*59* No error occurred60*/61CXCompilationDatabase_NoError = 0,6263/*64* Database can not be loaded65*/66CXCompilationDatabase_CanNotLoadDatabase = 16768} CXCompilationDatabase_Error;6970/**71* Creates a compilation database from the database found in directory72* buildDir. For example, CMake can output a compile_commands.json which can73* be used to build the database.74*75* It must be freed by \c clang_CompilationDatabase_dispose.76*/77CINDEX_LINKAGE CXCompilationDatabase78clang_CompilationDatabase_fromDirectory(const char *BuildDir,79CXCompilationDatabase_Error *ErrorCode);8081/**82* Free the given compilation database83*/84CINDEX_LINKAGE void85clang_CompilationDatabase_dispose(CXCompilationDatabase);8687/**88* Find the compile commands used for a file. The compile commands89* must be freed by \c clang_CompileCommands_dispose.90*/91CINDEX_LINKAGE CXCompileCommands92clang_CompilationDatabase_getCompileCommands(CXCompilationDatabase,93const char *CompleteFileName);9495/**96* Get all the compile commands in the given compilation database.97*/98CINDEX_LINKAGE CXCompileCommands99clang_CompilationDatabase_getAllCompileCommands(CXCompilationDatabase);100101/**102* Free the given CompileCommands103*/104CINDEX_LINKAGE void clang_CompileCommands_dispose(CXCompileCommands);105106/**107* Get the number of CompileCommand we have for a file108*/109CINDEX_LINKAGE unsigned110clang_CompileCommands_getSize(CXCompileCommands);111112/**113* Get the I'th CompileCommand for a file114*115* Note : 0 <= i < clang_CompileCommands_getSize(CXCompileCommands)116*/117CINDEX_LINKAGE CXCompileCommand118clang_CompileCommands_getCommand(CXCompileCommands, unsigned I);119120/**121* Get the working directory where the CompileCommand was executed from122*/123CINDEX_LINKAGE CXString124clang_CompileCommand_getDirectory(CXCompileCommand);125126/**127* Get the filename associated with the CompileCommand.128*/129CINDEX_LINKAGE CXString130clang_CompileCommand_getFilename(CXCompileCommand);131132/**133* Get the number of arguments in the compiler invocation.134*135*/136CINDEX_LINKAGE unsigned137clang_CompileCommand_getNumArgs(CXCompileCommand);138139/**140* Get the I'th argument value in the compiler invocations141*142* Invariant :143* - argument 0 is the compiler executable144*/145CINDEX_LINKAGE CXString146clang_CompileCommand_getArg(CXCompileCommand, unsigned I);147148/**149* Get the number of source mappings for the compiler invocation.150*/151CINDEX_LINKAGE unsigned152clang_CompileCommand_getNumMappedSources(CXCompileCommand);153154/**155* Get the I'th mapped source path for the compiler invocation.156*/157CINDEX_LINKAGE CXString158clang_CompileCommand_getMappedSourcePath(CXCompileCommand, unsigned I);159160/**161* Get the I'th mapped source content for the compiler invocation.162*/163CINDEX_LINKAGE CXString164clang_CompileCommand_getMappedSourceContent(CXCompileCommand, unsigned I);165166/**167* @}168*/169170LLVM_CLANG_C_EXTERN_C_END171172#endif173174175176