clang 19.0.0git
Typedefs | Enumerations | Functions
CompilationDatabase functions
Collaboration diagram for CompilationDatabase functions:

Typedefs

typedef void * CXCompilationDatabase
 A compilation database holds all information used to compile files in a project.
 
typedef void * CXCompileCommands
 Contains the results of a search in the compilation database.
 
typedef void * CXCompileCommand
 Represents the command line invocation to compile a specific file.
 

Enumerations

enum  CXCompilationDatabase_Error { CXCompilationDatabase_NoError = 0 , CXCompilationDatabase_CanNotLoadDatabase = 1 }
 Error codes for Compilation Database. More...
 

Functions

CINDEX_LINKAGE CXCompilationDatabase clang_CompilationDatabase_fromDirectory (const char *BuildDir, CXCompilationDatabase_Error *ErrorCode)
 Creates a compilation database from the database found in directory buildDir.
 
CINDEX_LINKAGE void clang_CompilationDatabase_dispose (CXCompilationDatabase)
 Free the given compilation database.
 
CINDEX_LINKAGE CXCompileCommands clang_CompilationDatabase_getCompileCommands (CXCompilationDatabase, const char *CompleteFileName)
 Find the compile commands used for a file.
 
CINDEX_LINKAGE CXCompileCommands clang_CompilationDatabase_getAllCompileCommands (CXCompilationDatabase)
 Get all the compile commands in the given compilation database.
 
CINDEX_LINKAGE void clang_CompileCommands_dispose (CXCompileCommands)
 Free the given CompileCommands.
 
CINDEX_LINKAGE unsigned clang_CompileCommands_getSize (CXCompileCommands)
 Get the number of CompileCommand we have for a file.
 
CINDEX_LINKAGE CXCompileCommand clang_CompileCommands_getCommand (CXCompileCommands, unsigned I)
 Get the I'th CompileCommand for a file.
 
CINDEX_LINKAGE CXString clang_CompileCommand_getDirectory (CXCompileCommand)
 Get the working directory where the CompileCommand was executed from.
 
CINDEX_LINKAGE CXString clang_CompileCommand_getFilename (CXCompileCommand)
 Get the filename associated with the CompileCommand.
 
CINDEX_LINKAGE unsigned clang_CompileCommand_getNumArgs (CXCompileCommand)
 Get the number of arguments in the compiler invocation.
 
CINDEX_LINKAGE CXString clang_CompileCommand_getArg (CXCompileCommand, unsigned I)
 Get the I'th argument value in the compiler invocations.
 
CINDEX_LINKAGE unsigned clang_CompileCommand_getNumMappedSources (CXCompileCommand)
 Get the number of source mappings for the compiler invocation.
 
CINDEX_LINKAGE CXString clang_CompileCommand_getMappedSourcePath (CXCompileCommand, unsigned I)
 Get the I'th mapped source path for the compiler invocation.
 
CINDEX_LINKAGE CXString clang_CompileCommand_getMappedSourceContent (CXCompileCommand, unsigned I)
 Get the I'th mapped source content for the compiler invocation.
 

Detailed Description

Typedef Documentation

◆ CXCompilationDatabase

typedef void* CXCompilationDatabase

A compilation database holds all information used to compile files in a project.

For each file in the database, it can be queried for the working directory or the command line used for the compiler invocation.

Must be freed by clang_CompilationDatabase_dispose

Definition at line 37 of file CXCompilationDatabase.h.

◆ CXCompileCommand

typedef void* CXCompileCommand

Represents the command line invocation to compile a specific file.

Definition at line 53 of file CXCompilationDatabase.h.

◆ CXCompileCommands

typedef void* CXCompileCommands

Contains the results of a search in the compilation database.

When searching for the compile command for a file, the compilation db can return several commands, as the file may have been compiled with different options in different places of the project. This choice of compile commands is wrapped in this opaque data structure. It must be freed by clang_CompileCommands_dispose.

Definition at line 48 of file CXCompilationDatabase.h.

Enumeration Type Documentation

◆ CXCompilationDatabase_Error

Error codes for Compilation Database.

Enumerator
CXCompilationDatabase_NoError 
CXCompilationDatabase_CanNotLoadDatabase 

Definition at line 58 of file CXCompilationDatabase.h.

Function Documentation

◆ clang_CompilationDatabase_dispose()

CINDEX_LINKAGE void clang_CompilationDatabase_dispose ( CXCompilationDatabase  )

Free the given compilation database.

◆ clang_CompilationDatabase_fromDirectory()

CINDEX_LINKAGE CXCompilationDatabase clang_CompilationDatabase_fromDirectory ( const char *  BuildDir,
CXCompilationDatabase_Error ErrorCode 
)

Creates a compilation database from the database found in directory buildDir.

For example, CMake can output a compile_commands.json which can be used to build the database.

It must be freed by clang_CompilationDatabase_dispose.

◆ clang_CompilationDatabase_getAllCompileCommands()

CINDEX_LINKAGE CXCompileCommands clang_CompilationDatabase_getAllCompileCommands ( CXCompilationDatabase  )

Get all the compile commands in the given compilation database.

◆ clang_CompilationDatabase_getCompileCommands()

CINDEX_LINKAGE CXCompileCommands clang_CompilationDatabase_getCompileCommands ( CXCompilationDatabase  ,
const char *  CompleteFileName 
)

Find the compile commands used for a file.

The compile commands must be freed by clang_CompileCommands_dispose.

◆ clang_CompileCommand_getArg()

CINDEX_LINKAGE CXString clang_CompileCommand_getArg ( CXCompileCommand  ,
unsigned  I 
)

Get the I'th argument value in the compiler invocations.

Invariant :

  • argument 0 is the compiler executable

◆ clang_CompileCommand_getDirectory()

CINDEX_LINKAGE CXString clang_CompileCommand_getDirectory ( CXCompileCommand  )

Get the working directory where the CompileCommand was executed from.

◆ clang_CompileCommand_getFilename()

CINDEX_LINKAGE CXString clang_CompileCommand_getFilename ( CXCompileCommand  )

Get the filename associated with the CompileCommand.

◆ clang_CompileCommand_getMappedSourceContent()

CINDEX_LINKAGE CXString clang_CompileCommand_getMappedSourceContent ( CXCompileCommand  ,
unsigned  I 
)

Get the I'th mapped source content for the compiler invocation.

◆ clang_CompileCommand_getMappedSourcePath()

CINDEX_LINKAGE CXString clang_CompileCommand_getMappedSourcePath ( CXCompileCommand  ,
unsigned  I 
)

Get the I'th mapped source path for the compiler invocation.

◆ clang_CompileCommand_getNumArgs()

CINDEX_LINKAGE unsigned clang_CompileCommand_getNumArgs ( CXCompileCommand  )

Get the number of arguments in the compiler invocation.

◆ clang_CompileCommand_getNumMappedSources()

CINDEX_LINKAGE unsigned clang_CompileCommand_getNumMappedSources ( CXCompileCommand  )

Get the number of source mappings for the compiler invocation.

◆ clang_CompileCommands_dispose()

CINDEX_LINKAGE void clang_CompileCommands_dispose ( CXCompileCommands  )

Free the given CompileCommands.

◆ clang_CompileCommands_getCommand()

CINDEX_LINKAGE CXCompileCommand clang_CompileCommands_getCommand ( CXCompileCommands  ,
unsigned  I 
)

Get the I'th CompileCommand for a file.

Note : 0 <= i < clang_CompileCommands_getSize(CXCompileCommands)

◆ clang_CompileCommands_getSize()

CINDEX_LINKAGE unsigned clang_CompileCommands_getSize ( CXCompileCommands  )

Get the number of CompileCommand we have for a file.