clang 20.0.0git
Modules | Classes | Typedefs | Enumerations | Functions
libclang: C Interface to Clang

The C Interface to Clang provides a relatively small API that exposes facilities for parsing source code into an abstract syntax tree (AST), loading already-parsed ASTs, traversing the AST, associating physical source locations with elements within the AST, and other facilities that support Clang-based development tools. More...

Collaboration diagram for libclang: C Interface to Clang:

Modules

 CompilationDatabase functions
 
 String manipulation routines
 
 Translation unit manipulation
 The routines in this group provide the ability to create and destroy translation units from files, either by parsing the contents of the files or by reading in a serialized representation of a translation unit.
 
 Cursor manipulations
 
 Mapping between cursors and source code
 Cursors represent a location within the Abstract Syntax Tree (AST).
 
 Type information for CXCursors
 
 Information for attributes
 
 Traversing the AST with cursors
 These routines provide the ability to traverse the abstract syntax tree using cursors.
 
 Cross-referencing in the AST
 These routines provide the ability to determine references within and across translation units, by providing the names of the entities referenced by cursors, follow reference cursors to the declarations they reference, and associate declarations with their definitions.
 
 Name Mangling API Functions
 
 Module introspection
 The functions in this group provide access to information about modules.
 
 C++ AST introspection
 The routines in this group provide access information in the ASTs specific to C++ language features.
 
 Token extraction and manipulation
 The routines in this group provide access to the tokens within a translation unit, along with a semantic mapping of those tokens to their corresponding cursors.
 
 Debugging facilities
 These routines are used for testing and debugging, only, and should not be relied upon.
 
 Code completion
 Code completion involves taking an (incomplete) source file, along with knowledge of where the user is actively editing that file, and suggesting syntactically- and semantically-valid constructs that the user might want to use at that particular point in the source code.
 
 Miscellaneous utility functions
 
 Remapping functions
 
 Higher level API functions
 

Classes

struct  CXUnsavedFile
 Provides the contents of a file that has not yet been saved to disk. More...
 
struct  CXVersion
 Describes a version number of the form major.minor.subminor. More...
 
struct  CXIndexOptions
 Index initialization options. More...
 
struct  CXCursor
 A cursor representing some element in the abstract syntax tree for a translation unit. More...
 

Typedefs

typedef void * CXIndex
 An "index" that consists of a set of translation units that would typically be linked together into an executable or library.
 
typedef struct CXTargetInfoImpl * CXTargetInfo
 An opaque type representing target information for a given translation unit.
 
typedef struct CXTranslationUnitImpl * CXTranslationUnit
 A single translation unit, which resides in an index.
 
typedef void * CXClientData
 Opaque pointer representing client data that will be passed through to various callbacks and visitors.
 
typedef struct CXVersion CXVersion
 Describes a version number of the form major.minor.subminor.
 
typedef struct CXIndexOptions CXIndexOptions
 Index initialization options.
 

Enumerations

enum  CXAvailabilityKind { CXAvailability_Available , CXAvailability_Deprecated , CXAvailability_NotAvailable , CXAvailability_NotAccessible }
 Describes the availability of a particular entity, which indicates whether the use of this entity will result in a warning or error due to it being deprecated or unavailable. More...
 
enum  CXCursor_ExceptionSpecificationKind {
  CXCursor_ExceptionSpecificationKind_None , CXCursor_ExceptionSpecificationKind_DynamicNone , CXCursor_ExceptionSpecificationKind_Dynamic , CXCursor_ExceptionSpecificationKind_MSAny ,
  CXCursor_ExceptionSpecificationKind_BasicNoexcept , CXCursor_ExceptionSpecificationKind_ComputedNoexcept , CXCursor_ExceptionSpecificationKind_Unevaluated , CXCursor_ExceptionSpecificationKind_Uninstantiated ,
  CXCursor_ExceptionSpecificationKind_Unparsed , CXCursor_ExceptionSpecificationKind_NoThrow
}
 Describes the exception specification of a cursor. More...
 
enum  CXChoice { CXChoice_Default = 0 , CXChoice_Enabled = 1 , CXChoice_Disabled = 2 }
 
enum  CXGlobalOptFlags { CXGlobalOpt_None = 0x0 , CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1 , CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2 , CXGlobalOpt_ThreadBackgroundPriorityForAll }
 
enum  CXCursorKind {
  CXCursor_UnexposedDecl = 1 , CXCursor_StructDecl = 2 , CXCursor_UnionDecl = 3 , CXCursor_ClassDecl = 4 ,
  CXCursor_EnumDecl = 5 , CXCursor_FieldDecl = 6 , CXCursor_EnumConstantDecl = 7 , CXCursor_FunctionDecl = 8 ,
  CXCursor_VarDecl = 9 , CXCursor_ParmDecl = 10 , CXCursor_ObjCInterfaceDecl = 11 , CXCursor_ObjCCategoryDecl = 12 ,
  CXCursor_ObjCProtocolDecl = 13 , CXCursor_ObjCPropertyDecl = 14 , CXCursor_ObjCIvarDecl = 15 , CXCursor_ObjCInstanceMethodDecl = 16 ,
  CXCursor_ObjCClassMethodDecl = 17 , CXCursor_ObjCImplementationDecl = 18 , CXCursor_ObjCCategoryImplDecl = 19 , CXCursor_TypedefDecl = 20 ,
  CXCursor_CXXMethod = 21 , CXCursor_Namespace = 22 , CXCursor_LinkageSpec = 23 , CXCursor_Constructor = 24 ,
  CXCursor_Destructor = 25 , CXCursor_ConversionFunction = 26 , CXCursor_TemplateTypeParameter = 27 , CXCursor_NonTypeTemplateParameter = 28 ,
  CXCursor_TemplateTemplateParameter = 29 , CXCursor_FunctionTemplate = 30 , CXCursor_ClassTemplate = 31 , CXCursor_ClassTemplatePartialSpecialization = 32 ,
  CXCursor_NamespaceAlias = 33 , CXCursor_UsingDirective = 34 , CXCursor_UsingDeclaration = 35 , CXCursor_TypeAliasDecl = 36 ,
  CXCursor_ObjCSynthesizeDecl = 37 , CXCursor_ObjCDynamicDecl = 38 , CXCursor_CXXAccessSpecifier = 39 , CXCursor_FirstDecl = CXCursor_UnexposedDecl ,
  CXCursor_LastDecl = CXCursor_CXXAccessSpecifier , CXCursor_FirstRef = 40 , CXCursor_ObjCSuperClassRef = 40 , CXCursor_ObjCProtocolRef = 41 ,
  CXCursor_ObjCClassRef = 42 , CXCursor_TypeRef = 43 , CXCursor_CXXBaseSpecifier = 44 , CXCursor_TemplateRef = 45 ,
  CXCursor_NamespaceRef = 46 , CXCursor_MemberRef = 47 , CXCursor_LabelRef = 48 , CXCursor_OverloadedDeclRef = 49 ,
  CXCursor_VariableRef = 50 , CXCursor_LastRef = CXCursor_VariableRef , CXCursor_FirstInvalid = 70 , CXCursor_InvalidFile = 70 ,
  CXCursor_NoDeclFound = 71 , CXCursor_NotImplemented = 72 , CXCursor_InvalidCode = 73 , CXCursor_LastInvalid = CXCursor_InvalidCode ,
  CXCursor_FirstExpr = 100 , CXCursor_UnexposedExpr = 100 , CXCursor_DeclRefExpr = 101 , CXCursor_MemberRefExpr = 102 ,
  CXCursor_CallExpr = 103 , CXCursor_ObjCMessageExpr = 104 , CXCursor_BlockExpr = 105 , CXCursor_IntegerLiteral = 106 ,
  CXCursor_FloatingLiteral = 107 , CXCursor_ImaginaryLiteral = 108 , CXCursor_StringLiteral = 109 , CXCursor_CharacterLiteral = 110 ,
  CXCursor_ParenExpr = 111 , CXCursor_UnaryOperator = 112 , CXCursor_ArraySubscriptExpr = 113 , CXCursor_BinaryOperator = 114 ,
  CXCursor_CompoundAssignOperator = 115 , CXCursor_ConditionalOperator = 116 , CXCursor_CStyleCastExpr = 117 , CXCursor_CompoundLiteralExpr = 118 ,
  CXCursor_InitListExpr = 119 , CXCursor_AddrLabelExpr = 120 , CXCursor_StmtExpr = 121 , CXCursor_GenericSelectionExpr = 122 ,
  CXCursor_GNUNullExpr = 123 , CXCursor_CXXStaticCastExpr = 124 , CXCursor_CXXDynamicCastExpr = 125 , CXCursor_CXXReinterpretCastExpr = 126 ,
  CXCursor_CXXConstCastExpr = 127 , CXCursor_CXXFunctionalCastExpr = 128 , CXCursor_CXXTypeidExpr = 129 , CXCursor_CXXBoolLiteralExpr = 130 ,
  CXCursor_CXXNullPtrLiteralExpr = 131 , CXCursor_CXXThisExpr = 132 , CXCursor_CXXThrowExpr = 133 , CXCursor_CXXNewExpr = 134 ,
  CXCursor_CXXDeleteExpr = 135 , CXCursor_UnaryExpr = 136 , CXCursor_ObjCStringLiteral = 137 , CXCursor_ObjCEncodeExpr = 138 ,
  CXCursor_ObjCSelectorExpr = 139 , CXCursor_ObjCProtocolExpr = 140 , CXCursor_ObjCBridgedCastExpr = 141 , CXCursor_PackExpansionExpr = 142 ,
  CXCursor_SizeOfPackExpr = 143 , CXCursor_LambdaExpr = 144 , CXCursor_ObjCBoolLiteralExpr = 145 , CXCursor_ObjCSelfExpr = 146 ,
  CXCursor_ArraySectionExpr = 147 , CXCursor_ObjCAvailabilityCheckExpr = 148 , CXCursor_FixedPointLiteral = 149 , CXCursor_OMPArrayShapingExpr = 150 ,
  CXCursor_OMPIteratorExpr = 151 , CXCursor_CXXAddrspaceCastExpr = 152 , CXCursor_ConceptSpecializationExpr = 153 , CXCursor_RequiresExpr = 154 ,
  CXCursor_CXXParenListInitExpr = 155 , CXCursor_PackIndexingExpr = 156 , CXCursor_LastExpr = CXCursor_PackIndexingExpr , CXCursor_FirstStmt = 200 ,
  CXCursor_UnexposedStmt = 200 , CXCursor_LabelStmt = 201 , CXCursor_CompoundStmt = 202 , CXCursor_CaseStmt = 203 ,
  CXCursor_DefaultStmt = 204 , CXCursor_IfStmt = 205 , CXCursor_SwitchStmt = 206 , CXCursor_WhileStmt = 207 ,
  CXCursor_DoStmt = 208 , CXCursor_ForStmt = 209 , CXCursor_GotoStmt = 210 , CXCursor_IndirectGotoStmt = 211 ,
  CXCursor_ContinueStmt = 212 , CXCursor_BreakStmt = 213 , CXCursor_ReturnStmt = 214 , CXCursor_GCCAsmStmt = 215 ,
  CXCursor_AsmStmt = CXCursor_GCCAsmStmt , CXCursor_ObjCAtTryStmt = 216 , CXCursor_ObjCAtCatchStmt = 217 , CXCursor_ObjCAtFinallyStmt = 218 ,
  CXCursor_ObjCAtThrowStmt = 219 , CXCursor_ObjCAtSynchronizedStmt = 220 , CXCursor_ObjCAutoreleasePoolStmt = 221 , CXCursor_ObjCForCollectionStmt = 222 ,
  CXCursor_CXXCatchStmt = 223 , CXCursor_CXXTryStmt = 224 , CXCursor_CXXForRangeStmt = 225 , CXCursor_SEHTryStmt = 226 ,
  CXCursor_SEHExceptStmt = 227 , CXCursor_SEHFinallyStmt = 228 , CXCursor_MSAsmStmt = 229 , CXCursor_NullStmt = 230 ,
  CXCursor_DeclStmt = 231 , CXCursor_OMPParallelDirective = 232 , CXCursor_OMPSimdDirective = 233 , CXCursor_OMPForDirective = 234 ,
  CXCursor_OMPSectionsDirective = 235 , CXCursor_OMPSectionDirective = 236 , CXCursor_OMPSingleDirective = 237 , CXCursor_OMPParallelForDirective = 238 ,
  CXCursor_OMPParallelSectionsDirective = 239 , CXCursor_OMPTaskDirective = 240 , CXCursor_OMPMasterDirective = 241 , CXCursor_OMPCriticalDirective = 242 ,
  CXCursor_OMPTaskyieldDirective = 243 , CXCursor_OMPBarrierDirective = 244 , CXCursor_OMPTaskwaitDirective = 245 , CXCursor_OMPFlushDirective = 246 ,
  CXCursor_SEHLeaveStmt = 247 , CXCursor_OMPOrderedDirective = 248 , CXCursor_OMPAtomicDirective = 249 , CXCursor_OMPForSimdDirective = 250 ,
  CXCursor_OMPParallelForSimdDirective = 251 , CXCursor_OMPTargetDirective = 252 , CXCursor_OMPTeamsDirective = 253 , CXCursor_OMPTaskgroupDirective = 254 ,
  CXCursor_OMPCancellationPointDirective = 255 , CXCursor_OMPCancelDirective = 256 , CXCursor_OMPTargetDataDirective = 257 , CXCursor_OMPTaskLoopDirective = 258 ,
  CXCursor_OMPTaskLoopSimdDirective = 259 , CXCursor_OMPDistributeDirective = 260 , CXCursor_OMPTargetEnterDataDirective = 261 , CXCursor_OMPTargetExitDataDirective = 262 ,
  CXCursor_OMPTargetParallelDirective = 263 , CXCursor_OMPTargetParallelForDirective = 264 , CXCursor_OMPTargetUpdateDirective = 265 , CXCursor_OMPDistributeParallelForDirective = 266 ,
  CXCursor_OMPDistributeParallelForSimdDirective = 267 , CXCursor_OMPDistributeSimdDirective = 268 , CXCursor_OMPTargetParallelForSimdDirective = 269 , CXCursor_OMPTargetSimdDirective = 270 ,
  CXCursor_OMPTeamsDistributeDirective = 271 , CXCursor_OMPTeamsDistributeSimdDirective = 272 , CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273 , CXCursor_OMPTeamsDistributeParallelForDirective = 274 ,
  CXCursor_OMPTargetTeamsDirective = 275 , CXCursor_OMPTargetTeamsDistributeDirective = 276 , CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277 , CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278 ,
  CXCursor_OMPTargetTeamsDistributeSimdDirective = 279 , CXCursor_BuiltinBitCastExpr = 280 , CXCursor_OMPMasterTaskLoopDirective = 281 , CXCursor_OMPParallelMasterTaskLoopDirective = 282 ,
  CXCursor_OMPMasterTaskLoopSimdDirective = 283 , CXCursor_OMPParallelMasterTaskLoopSimdDirective = 284 , CXCursor_OMPParallelMasterDirective = 285 , CXCursor_OMPDepobjDirective = 286 ,
  CXCursor_OMPScanDirective = 287 , CXCursor_OMPTileDirective = 288 , CXCursor_OMPCanonicalLoop = 289 , CXCursor_OMPInteropDirective = 290 ,
  CXCursor_OMPDispatchDirective = 291 , CXCursor_OMPMaskedDirective = 292 , CXCursor_OMPUnrollDirective = 293 , CXCursor_OMPMetaDirective = 294 ,
  CXCursor_OMPGenericLoopDirective = 295 , CXCursor_OMPTeamsGenericLoopDirective = 296 , CXCursor_OMPTargetTeamsGenericLoopDirective = 297 , CXCursor_OMPParallelGenericLoopDirective = 298 ,
  CXCursor_OMPTargetParallelGenericLoopDirective = 299 , CXCursor_OMPParallelMaskedDirective = 300 , CXCursor_OMPMaskedTaskLoopDirective = 301 , CXCursor_OMPMaskedTaskLoopSimdDirective = 302 ,
  CXCursor_OMPParallelMaskedTaskLoopDirective = 303 , CXCursor_OMPParallelMaskedTaskLoopSimdDirective = 304 , CXCursor_OMPErrorDirective = 305 , CXCursor_OMPScopeDirective = 306 ,
  CXCursor_OMPReverseDirective = 307 , CXCursor_OMPInterchangeDirective = 308 , CXCursor_OMPAssumeDirective = 309 , CXCursor_OpenACCComputeConstruct = 320 ,
  CXCursor_OpenACCLoopConstruct = 321 , CXCursor_OpenACCCombinedConstruct = 322 , CXCursor_OpenACCDataConstruct = 323 , CXCursor_OpenACCEnterDataConstruct = 324 ,
  CXCursor_OpenACCExitDataConstruct = 325 , CXCursor_OpenACCHostDataConstruct = 326 , CXCursor_OpenACCWaitConstruct = 327 , CXCursor_OpenACCInitConstruct = 328 ,
  CXCursor_OpenACCShutdownConstruct = 329 , CXCursor_LastStmt = CXCursor_OpenACCShutdownConstruct , CXCursor_TranslationUnit = 350 , CXCursor_FirstAttr = 400 ,
  CXCursor_UnexposedAttr = 400 , CXCursor_IBActionAttr = 401 , CXCursor_IBOutletAttr = 402 , CXCursor_IBOutletCollectionAttr = 403 ,
  CXCursor_CXXFinalAttr = 404 , CXCursor_CXXOverrideAttr = 405 , CXCursor_AnnotateAttr = 406 , CXCursor_AsmLabelAttr = 407 ,
  CXCursor_PackedAttr = 408 , CXCursor_PureAttr = 409 , CXCursor_ConstAttr = 410 , CXCursor_NoDuplicateAttr = 411 ,
  CXCursor_CUDAConstantAttr = 412 , CXCursor_CUDADeviceAttr = 413 , CXCursor_CUDAGlobalAttr = 414 , CXCursor_CUDAHostAttr = 415 ,
  CXCursor_CUDASharedAttr = 416 , CXCursor_VisibilityAttr = 417 , CXCursor_DLLExport = 418 , CXCursor_DLLImport = 419 ,
  CXCursor_NSReturnsRetained = 420 , CXCursor_NSReturnsNotRetained = 421 , CXCursor_NSReturnsAutoreleased = 422 , CXCursor_NSConsumesSelf = 423 ,
  CXCursor_NSConsumed = 424 , CXCursor_ObjCException = 425 , CXCursor_ObjCNSObject = 426 , CXCursor_ObjCIndependentClass = 427 ,
  CXCursor_ObjCPreciseLifetime = 428 , CXCursor_ObjCReturnsInnerPointer = 429 , CXCursor_ObjCRequiresSuper = 430 , CXCursor_ObjCRootClass = 431 ,
  CXCursor_ObjCSubclassingRestricted = 432 , CXCursor_ObjCExplicitProtocolImpl = 433 , CXCursor_ObjCDesignatedInitializer = 434 , CXCursor_ObjCRuntimeVisible = 435 ,
  CXCursor_ObjCBoxable = 436 , CXCursor_FlagEnum = 437 , CXCursor_ConvergentAttr = 438 , CXCursor_WarnUnusedAttr = 439 ,
  CXCursor_WarnUnusedResultAttr = 440 , CXCursor_AlignedAttr = 441 , CXCursor_LastAttr = CXCursor_AlignedAttr , CXCursor_PreprocessingDirective = 500 ,
  CXCursor_MacroDefinition = 501 , CXCursor_MacroExpansion = 502 , CXCursor_MacroInstantiation = CXCursor_MacroExpansion , CXCursor_InclusionDirective = 503 ,
  CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective , CXCursor_LastPreprocessing = CXCursor_InclusionDirective , CXCursor_ModuleImportDecl = 600 , CXCursor_TypeAliasTemplateDecl = 601 ,
  CXCursor_StaticAssert = 602 , CXCursor_FriendDecl = 603 , CXCursor_ConceptDecl = 604 , CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl ,
  CXCursor_LastExtraDecl = CXCursor_ConceptDecl , CXCursor_OverloadCandidate = 700
}
 Describes the kind of entity that a cursor refers to. More...
 

Functions

CINDEX_LINKAGE CXIndex clang_createIndex (int excludeDeclarationsFromPCH, int displayDiagnostics)
 Provides a shared context for creating translation units.
 
CINDEX_LINKAGE void clang_disposeIndex (CXIndex index)
 Destroy the given index.
 
CINDEX_LINKAGE CXIndex clang_createIndexWithOptions (const CXIndexOptions *options)
 Provides a shared context for creating translation units.
 
CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions (CXIndex, unsigned options)
 Sets general options associated with a CXIndex.
 
CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions (CXIndex)
 Gets the general options associated with a CXIndex.
 
CINDEX_LINKAGE void clang_CXIndex_setInvocationEmissionPathOption (CXIndex, const char *Path)
 Sets the invocation emission path option in a CXIndex.
 
CINDEX_LINKAGE unsigned clang_isFileMultipleIncludeGuarded (CXTranslationUnit tu, CXFile file)
 Determine whether the given header is guarded against multiple inclusions, either with the conventional #ifndef/#define/#endif macro guards or with #pragma once.
 
CINDEX_LINKAGE CXFile clang_getFile (CXTranslationUnit tu, const char *file_name)
 Retrieve a file handle within the given translation unit.
 
CINDEX_LINKAGE const char * clang_getFileContents (CXTranslationUnit tu, CXFile file, size_t *size)
 Retrieve the buffer associated with the given file.
 
CINDEX_LINKAGE CXSourceLocation clang_getLocation (CXTranslationUnit tu, CXFile file, unsigned line, unsigned column)
 Retrieves the source location associated with a given file/line/column in a particular translation unit.
 
CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset (CXTranslationUnit tu, CXFile file, unsigned offset)
 Retrieves the source location associated with a given character offset in a particular translation unit.
 
CINDEX_LINKAGE CXSourceRangeListclang_getSkippedRanges (CXTranslationUnit tu, CXFile file)
 Retrieve all ranges that were skipped by the preprocessor.
 
CINDEX_LINKAGE CXSourceRangeListclang_getAllSkippedRanges (CXTranslationUnit tu)
 Retrieve all ranges from all files that were skipped by the preprocessor.
 
CINDEX_LINKAGE unsigned clang_getNumDiagnostics (CXTranslationUnit Unit)
 Determine the number of diagnostics produced for the given translation unit.
 
CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic (CXTranslationUnit Unit, unsigned Index)
 Retrieve a diagnostic associated with the given translation unit.
 
CINDEX_LINKAGE CXDiagnosticSet clang_getDiagnosticSetFromTU (CXTranslationUnit Unit)
 Retrieve the complete set of diagnostics associated with a translation unit.
 

Detailed Description

The C Interface to Clang provides a relatively small API that exposes facilities for parsing source code into an abstract syntax tree (AST), loading already-parsed ASTs, traversing the AST, associating physical source locations with elements within the AST, and other facilities that support Clang-based development tools.

This C interface to Clang will never provide all of the information representation stored in Clang's C++ AST, nor should it: the intent is to maintain an API that is relatively stable from one release to the next, providing only the basic functionality needed to support development tools.

To avoid namespace pollution, data types are prefixed with "CX" and functions are prefixed with "clang_".

Typedef Documentation

◆ CXClientData

typedef void* CXClientData

Opaque pointer representing client data that will be passed through to various callbacks and visitors.

Definition at line 97 of file Index.h.

◆ CXIndex

typedef void* CXIndex

An "index" that consists of a set of translation units that would typically be linked together into an executable or library.

Definition at line 80 of file Index.h.

◆ CXIndexOptions

Index initialization options.

0 is the default value of each member of this struct except for Size. Initialize the struct in one of the following three ways to avoid adapting code each time a new member is added to it:

memset(&Opts, 0, sizeof(Opts));
Opts.Size = sizeof(CXIndexOptions);
__DEVICE__ void * memset(void *__a, int __b, size_t __c)
Index initialization options.
Definition: Index.h:353
unsigned Size
The size of struct CXIndexOptions used for option versioning.
Definition: Index.h:360

or explicitly initialize the first data member and zero-initialize the rest:

CXIndexOptions Opts = { sizeof(CXIndexOptions) };

or to prevent the -Wmissing-field-initializers warning for the above version:

Opts.Size = sizeof(CXIndexOptions);

◆ CXTargetInfo

typedef struct CXTargetInfoImpl* CXTargetInfo

An opaque type representing target information for a given translation unit.

Definition at line 86 of file Index.h.

◆ CXTranslationUnit

typedef struct CXTranslationUnitImpl* CXTranslationUnit

A single translation unit, which resides in an index.

Definition at line 91 of file Index.h.

◆ CXVersion

typedef struct CXVersion CXVersion

Describes a version number of the form major.minor.subminor.

Enumeration Type Documentation

◆ CXAvailabilityKind

Describes the availability of a particular entity, which indicates whether the use of this entity will result in a warning or error due to it being deprecated or unavailable.

Enumerator
CXAvailability_Available 

The entity is available.

CXAvailability_Deprecated 

The entity is available, but has been deprecated (and its use is not recommended).

CXAvailability_NotAvailable 

The entity is not available; any use of it will be an error.

CXAvailability_NotAccessible 

The entity is available, but not accessible; any use of it will be an error.

Definition at line 130 of file Index.h.

◆ CXChoice

enum CXChoice
Enumerator
CXChoice_Default 

Use the default value of an option that may depend on the process environment.

CXChoice_Enabled 

Enable the option.

CXChoice_Disabled 

Disable the option.

Definition at line 282 of file Index.h.

◆ CXCursor_ExceptionSpecificationKind

Describes the exception specification of a cursor.

A negative value indicates that the cursor is not a function declaration.

Enumerator
CXCursor_ExceptionSpecificationKind_None 

The cursor has no exception specification.

CXCursor_ExceptionSpecificationKind_DynamicNone 

The cursor has exception specification throw()

CXCursor_ExceptionSpecificationKind_Dynamic 

The cursor has exception specification throw(T1, T2)

CXCursor_ExceptionSpecificationKind_MSAny 

The cursor has exception specification throw(...).

CXCursor_ExceptionSpecificationKind_BasicNoexcept 

The cursor has exception specification basic noexcept.

CXCursor_ExceptionSpecificationKind_ComputedNoexcept 

The cursor has exception specification computed noexcept.

CXCursor_ExceptionSpecificationKind_Unevaluated 

The exception specification has not yet been evaluated.

CXCursor_ExceptionSpecificationKind_Uninstantiated 

The exception specification has not yet been instantiated.

CXCursor_ExceptionSpecificationKind_Unparsed 

The exception specification has not been parsed yet.

CXCursor_ExceptionSpecificationKind_NoThrow 

The cursor has a __declspec(nothrow) exception specification.

Definition at line 179 of file Index.h.

◆ CXCursorKind

Describes the kind of entity that a cursor refers to.

Enumerator
CXCursor_UnexposedDecl 

A declaration whose specific kind is not exposed via this interface.

Unexposed declarations have the same operations as any other kind of declaration; one can extract their location information, spelling, find their definitions, etc. However, the specific kind of the declaration is not reported.

CXCursor_StructDecl 

A C or C++ struct.

CXCursor_UnionDecl 

A C or C++ union.

CXCursor_ClassDecl 

A C++ class.

CXCursor_EnumDecl 

An enumeration.

CXCursor_FieldDecl 

A field (in C) or non-static data member (in C++) in a struct, union, or C++ class.

CXCursor_EnumConstantDecl 

An enumerator constant.

CXCursor_FunctionDecl 

A function.

CXCursor_VarDecl 

A variable.

CXCursor_ParmDecl 

A function or method parameter.

CXCursor_ObjCInterfaceDecl 

An Objective-C @interface.

CXCursor_ObjCCategoryDecl 

An Objective-C @interface for a category.

CXCursor_ObjCProtocolDecl 

An Objective-C @protocol declaration.

CXCursor_ObjCPropertyDecl 

An Objective-C @property declaration.

CXCursor_ObjCIvarDecl 

An Objective-C instance variable.

CXCursor_ObjCInstanceMethodDecl 

An Objective-C instance method.

CXCursor_ObjCClassMethodDecl 

An Objective-C class method.

CXCursor_ObjCImplementationDecl 

An Objective-C @implementation.

CXCursor_ObjCCategoryImplDecl 

An Objective-C @implementation for a category.

CXCursor_TypedefDecl 

A typedef.

CXCursor_CXXMethod 

A C++ class method.

CXCursor_Namespace 

A C++ namespace.

CXCursor_LinkageSpec 

A linkage specification, e.g.

'extern "C"'.

CXCursor_Constructor 

A C++ constructor.

CXCursor_Destructor 

A C++ destructor.

CXCursor_ConversionFunction 

A C++ conversion function.

CXCursor_TemplateTypeParameter 

A C++ template type parameter.

CXCursor_NonTypeTemplateParameter 

A C++ non-type template parameter.

CXCursor_TemplateTemplateParameter 

A C++ template template parameter.

CXCursor_FunctionTemplate 

A C++ function template.

CXCursor_ClassTemplate 

A C++ class template.

CXCursor_ClassTemplatePartialSpecialization 

A C++ class template partial specialization.

CXCursor_NamespaceAlias 

A C++ namespace alias declaration.

CXCursor_UsingDirective 

A C++ using directive.

CXCursor_UsingDeclaration 

A C++ using declaration.

CXCursor_TypeAliasDecl 

A C++ alias declaration.

CXCursor_ObjCSynthesizeDecl 

An Objective-C @synthesize definition.

CXCursor_ObjCDynamicDecl 

An Objective-C @dynamic definition.

CXCursor_CXXAccessSpecifier 

An access specifier.

CXCursor_FirstDecl 
CXCursor_LastDecl 
CXCursor_FirstRef 
CXCursor_ObjCSuperClassRef 
CXCursor_ObjCProtocolRef 
CXCursor_ObjCClassRef 
CXCursor_TypeRef 

A reference to a type declaration.

A type reference occurs anywhere where a type is named but not declared. For example, given:

typedef unsigned size_type;
size_type size;

The typedef is a declaration of size_type (CXCursor_TypedefDecl), while the type of the variable "size" is referenced. The cursor referenced by the type of size is the typedef for size_type.

CXCursor_CXXBaseSpecifier 
CXCursor_TemplateRef 

A reference to a class template, function template, template template parameter, or class template partial specialization.

CXCursor_NamespaceRef 

A reference to a namespace or namespace alias.

CXCursor_MemberRef 

A reference to a member of a struct, union, or class that occurs in some non-expression context, e.g., a designated initializer.

CXCursor_LabelRef 

A reference to a labeled statement.

This cursor kind is used to describe the jump to "start_over" in the goto statement in the following example:

start_over:
++counter;
goto start_over;

A label reference cursor refers to a label statement.

CXCursor_OverloadedDeclRef 

A reference to a set of overloaded functions or function templates that has not yet been resolved to a specific function or function template.

An overloaded declaration reference cursor occurs in C++ templates where a dependent name refers to a function. For example:

template<typename T> void swap(T&, T&);
struct X { ... };
void swap(X&, X&);
template<typename T>
void reverse(T* first, T* last) {
while (first < last - 1) {
swap(*first, *--last);
++first;
}
}
struct Y { };
void swap(Y&, Y&);

Here, the identifier "swap" is associated with an overloaded declaration reference. In the template definition, "swap" refers to either of the two "swap" functions declared above, so both results will be available. At instantiation time, "swap" may also refer to other functions found via argument-dependent lookup (e.g., the "swap" function at the end of the example).

The functions clang_getNumOverloadedDecls() and clang_getOverloadedDecl() can be used to retrieve the definitions referenced by this cursor.

CXCursor_VariableRef 

A reference to a variable that occurs in some non-expression context, e.g., a C++ lambda capture list.

CXCursor_LastRef 
CXCursor_FirstInvalid 
CXCursor_InvalidFile 
CXCursor_NoDeclFound 
CXCursor_NotImplemented 
CXCursor_InvalidCode 
CXCursor_LastInvalid 
CXCursor_FirstExpr 
CXCursor_UnexposedExpr 

An expression whose specific kind is not exposed via this interface.

Unexposed expressions have the same operations as any other kind of expression; one can extract their location information, spelling, children, etc. However, the specific kind of the expression is not reported.

CXCursor_DeclRefExpr 

An expression that refers to some value declaration, such as a function, variable, or enumerator.

CXCursor_MemberRefExpr 

An expression that refers to a member of a struct, union, class, Objective-C class, etc.

CXCursor_CallExpr 

An expression that calls a function.

CXCursor_ObjCMessageExpr 

An expression that sends a message to an Objective-C object or class.

CXCursor_BlockExpr 

An expression that represents a block literal.

CXCursor_IntegerLiteral 

An integer literal.

CXCursor_FloatingLiteral 

A floating point number literal.

CXCursor_ImaginaryLiteral 

An imaginary number literal.

CXCursor_StringLiteral 

A string literal.

CXCursor_CharacterLiteral 

A character literal.

CXCursor_ParenExpr 

A parenthesized expression, e.g.

"(1)".

This AST node is only formed if full location information is requested.

CXCursor_UnaryOperator 

This represents the unary-expression's (except sizeof and alignof).

CXCursor_ArraySubscriptExpr 

[C99 6.5.2.1] Array Subscripting.

CXCursor_BinaryOperator 

A builtin binary operation expression such as "x + y" or "x <= y".

CXCursor_CompoundAssignOperator 

Compound assignment such as "+=".

CXCursor_ConditionalOperator 

The ?: ternary operator.

CXCursor_CStyleCastExpr 

An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr.cast]), which uses the syntax (Type)expr.

For example: (int)f.

CXCursor_CompoundLiteralExpr 

[C99 6.5.2.5]

CXCursor_InitListExpr 

Describes an C or C++ initializer list.

CXCursor_AddrLabelExpr 

The GNU address of label extension, representing &&label.

CXCursor_StmtExpr 

This is the GNU Statement Expression extension: ({int X=4; X;})

CXCursor_GenericSelectionExpr 

Represents a C11 generic selection.

CXCursor_GNUNullExpr 

Implements the GNU __null extension, which is a name for a null pointer constant that has integral type (e.g., int or long) and is the same size and alignment as a pointer.

The __null extension is typically only used by system headers, which define NULL as __null in C++ rather than using 0 (which is an integer that may not match the size of a pointer).

CXCursor_CXXStaticCastExpr 

C++'s static_cast<> expression.

CXCursor_CXXDynamicCastExpr 

C++'s dynamic_cast<> expression.

CXCursor_CXXReinterpretCastExpr 

C++'s reinterpret_cast<> expression.

CXCursor_CXXConstCastExpr 

C++'s const_cast<> expression.

CXCursor_CXXFunctionalCastExpr 

Represents an explicit C++ type conversion that uses "functional" notion (C++ [expr.type.conv]).

Example:

x = int(0.5);
CXCursor_CXXTypeidExpr 

A C++ typeid expression (C++ [expr.typeid]).

CXCursor_CXXBoolLiteralExpr 

[C++ 2.13.5] C++ Boolean Literal.

CXCursor_CXXNullPtrLiteralExpr 

[C++0x 2.14.7] C++ Pointer Literal.

CXCursor_CXXThisExpr 

Represents the "this" expression in C++.

CXCursor_CXXThrowExpr 

[C++ 15] C++ Throw Expression.

This handles 'throw' and 'throw' assignment-expression. When assignment-expression isn't present, Op will be null.

CXCursor_CXXNewExpr 

A new expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".

CXCursor_CXXDeleteExpr 

A delete expression for memory deallocation and destructor calls, e.g.

"delete[] pArray".

CXCursor_UnaryExpr 

A unary expression.

(noexcept, sizeof, or other traits)

CXCursor_ObjCStringLiteral 

An Objective-C string literal i.e.

"foo".

CXCursor_ObjCEncodeExpr 

An Objective-C @encode expression.

CXCursor_ObjCSelectorExpr 

An Objective-C @selector expression.

CXCursor_ObjCProtocolExpr 

An Objective-C @protocol expression.

CXCursor_ObjCBridgedCastExpr 

An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers, transferring ownership in the process.

NSString *str = (__bridge_transfer NSString *)CFCreateString();
CXCursor_PackExpansionExpr 

Represents a C++0x pack expansion that produces a sequence of expressions.

A pack expansion expression contains a pattern (which itself is an expression) followed by an ellipsis. For example:

template<typename F, typename ...Types>
void forward(F f, Types &&...args) {
f(static_cast<Types&&>(args)...);
}
CXCursor_SizeOfPackExpr 

Represents an expression that computes the length of a parameter pack.

template<typename ...Types>
struct count {
static const unsigned value = sizeof...(Types);
};
CXCursor_LambdaExpr 
CXCursor_ObjCBoolLiteralExpr 

Objective-c Boolean Literal.

CXCursor_ObjCSelfExpr 

Represents the "self" expression in an Objective-C method.

CXCursor_ArraySectionExpr 

OpenMP 5.0 [2.1.5, Array Section].

OpenACC 3.3 [2.7.1, Data Specification for Data Clauses (Sub Arrays)]

CXCursor_ObjCAvailabilityCheckExpr 

Represents an @available(...) check.

CXCursor_FixedPointLiteral 

Fixed point literal.

CXCursor_OMPArrayShapingExpr 

OpenMP 5.0 [2.1.4, Array Shaping].

CXCursor_OMPIteratorExpr 

OpenMP 5.0 [2.1.6 Iterators].

CXCursor_CXXAddrspaceCastExpr 

OpenCL's addrspace_cast<> expression.

CXCursor_ConceptSpecializationExpr 

Expression that references a C++20 concept.

CXCursor_RequiresExpr 

Expression that references a C++20 requires expression.

CXCursor_CXXParenListInitExpr 

Expression that references a C++20 parenthesized list aggregate initializer.

CXCursor_PackIndexingExpr 

Represents a C++26 pack indexing expression.

CXCursor_LastExpr 
CXCursor_FirstStmt 
CXCursor_UnexposedStmt 

A statement whose specific kind is not exposed via this interface.

Unexposed statements have the same operations as any other kind of statement; one can extract their location information, spelling, children, etc. However, the specific kind of the statement is not reported.

CXCursor_LabelStmt 

A labelled statement in a function.

This cursor kind is used to describe the "start_over:" label statement in the following example:

start_over:
++counter;
CXCursor_CompoundStmt 

A group of statements like { stmt stmt }.

This cursor kind is used to describe compound statements, e.g. function bodies.

CXCursor_CaseStmt 

A case statement.

CXCursor_DefaultStmt 

A default statement.

CXCursor_IfStmt 

An if statement.

CXCursor_SwitchStmt 

A switch statement.

CXCursor_WhileStmt 

A while statement.

CXCursor_DoStmt 

A do statement.

CXCursor_ForStmt 

A for statement.

CXCursor_GotoStmt 

A goto statement.

CXCursor_IndirectGotoStmt 

An indirect goto statement.

CXCursor_ContinueStmt 

A continue statement.

CXCursor_BreakStmt 

A break statement.

CXCursor_ReturnStmt 

A return statement.

CXCursor_GCCAsmStmt 

A GCC inline assembly statement extension.

CXCursor_AsmStmt 
CXCursor_ObjCAtTryStmt 

Objective-C's overall @try-@catch-@finally statement.

CXCursor_ObjCAtCatchStmt 

Objective-C's @catch statement.

CXCursor_ObjCAtFinallyStmt 

Objective-C's @finally statement.

CXCursor_ObjCAtThrowStmt 

Objective-C's @throw statement.

CXCursor_ObjCAtSynchronizedStmt 

Objective-C's @synchronized statement.

CXCursor_ObjCAutoreleasePoolStmt 

Objective-C's autorelease pool statement.

CXCursor_ObjCForCollectionStmt 

Objective-C's collection statement.

CXCursor_CXXCatchStmt 

C++'s catch statement.

CXCursor_CXXTryStmt 

C++'s try statement.

CXCursor_CXXForRangeStmt 

C++'s for (* : *) statement.

CXCursor_SEHTryStmt 

Windows Structured Exception Handling's try statement.

CXCursor_SEHExceptStmt 

Windows Structured Exception Handling's except statement.

CXCursor_SEHFinallyStmt 

Windows Structured Exception Handling's finally statement.

CXCursor_MSAsmStmt 

A MS inline assembly statement extension.

CXCursor_NullStmt 

The null statement ";": C99 6.8.3p3.

This cursor kind is used to describe the null statement.

CXCursor_DeclStmt 

Adaptor class for mixing declarations with statements and expressions.

CXCursor_OMPParallelDirective 

OpenMP parallel directive.

CXCursor_OMPSimdDirective 

OpenMP SIMD directive.

CXCursor_OMPForDirective 

OpenMP for directive.

CXCursor_OMPSectionsDirective 

OpenMP sections directive.

CXCursor_OMPSectionDirective 

OpenMP section directive.

CXCursor_OMPSingleDirective 

OpenMP single directive.

CXCursor_OMPParallelForDirective 

OpenMP parallel for directive.

CXCursor_OMPParallelSectionsDirective 

OpenMP parallel sections directive.

CXCursor_OMPTaskDirective 

OpenMP task directive.

CXCursor_OMPMasterDirective 

OpenMP master directive.

CXCursor_OMPCriticalDirective 

OpenMP critical directive.

CXCursor_OMPTaskyieldDirective 

OpenMP taskyield directive.

CXCursor_OMPBarrierDirective 

OpenMP barrier directive.

CXCursor_OMPTaskwaitDirective 

OpenMP taskwait directive.

CXCursor_OMPFlushDirective 

OpenMP flush directive.

CXCursor_SEHLeaveStmt 

Windows Structured Exception Handling's leave statement.

CXCursor_OMPOrderedDirective 

OpenMP ordered directive.

CXCursor_OMPAtomicDirective 

OpenMP atomic directive.

CXCursor_OMPForSimdDirective 

OpenMP for SIMD directive.

CXCursor_OMPParallelForSimdDirective 

OpenMP parallel for SIMD directive.

CXCursor_OMPTargetDirective 

OpenMP target directive.

CXCursor_OMPTeamsDirective 

OpenMP teams directive.

CXCursor_OMPTaskgroupDirective 

OpenMP taskgroup directive.

CXCursor_OMPCancellationPointDirective 

OpenMP cancellation point directive.

CXCursor_OMPCancelDirective 

OpenMP cancel directive.

CXCursor_OMPTargetDataDirective 

OpenMP target data directive.

CXCursor_OMPTaskLoopDirective 

OpenMP taskloop directive.

CXCursor_OMPTaskLoopSimdDirective 

OpenMP taskloop simd directive.

CXCursor_OMPDistributeDirective 

OpenMP distribute directive.

CXCursor_OMPTargetEnterDataDirective 

OpenMP target enter data directive.

CXCursor_OMPTargetExitDataDirective 

OpenMP target exit data directive.

CXCursor_OMPTargetParallelDirective 

OpenMP target parallel directive.

CXCursor_OMPTargetParallelForDirective 

OpenMP target parallel for directive.

CXCursor_OMPTargetUpdateDirective 

OpenMP target update directive.

CXCursor_OMPDistributeParallelForDirective 

OpenMP distribute parallel for directive.

CXCursor_OMPDistributeParallelForSimdDirective 

OpenMP distribute parallel for simd directive.

CXCursor_OMPDistributeSimdDirective 

OpenMP distribute simd directive.

CXCursor_OMPTargetParallelForSimdDirective 

OpenMP target parallel for simd directive.

CXCursor_OMPTargetSimdDirective 

OpenMP target simd directive.

CXCursor_OMPTeamsDistributeDirective 

OpenMP teams distribute directive.

CXCursor_OMPTeamsDistributeSimdDirective 

OpenMP teams distribute simd directive.

CXCursor_OMPTeamsDistributeParallelForSimdDirective 

OpenMP teams distribute parallel for simd directive.

CXCursor_OMPTeamsDistributeParallelForDirective 

OpenMP teams distribute parallel for directive.

CXCursor_OMPTargetTeamsDirective 

OpenMP target teams directive.

CXCursor_OMPTargetTeamsDistributeDirective 

OpenMP target teams distribute directive.

CXCursor_OMPTargetTeamsDistributeParallelForDirective 

OpenMP target teams distribute parallel for directive.

CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective 

OpenMP target teams distribute parallel for simd directive.

CXCursor_OMPTargetTeamsDistributeSimdDirective 

OpenMP target teams distribute simd directive.

CXCursor_BuiltinBitCastExpr 

C++2a std::bit_cast expression.

CXCursor_OMPMasterTaskLoopDirective 

OpenMP master taskloop directive.

CXCursor_OMPParallelMasterTaskLoopDirective 

OpenMP parallel master taskloop directive.

CXCursor_OMPMasterTaskLoopSimdDirective 

OpenMP master taskloop simd directive.

CXCursor_OMPParallelMasterTaskLoopSimdDirective 

OpenMP parallel master taskloop simd directive.

CXCursor_OMPParallelMasterDirective 

OpenMP parallel master directive.

CXCursor_OMPDepobjDirective 

OpenMP depobj directive.

CXCursor_OMPScanDirective 

OpenMP scan directive.

CXCursor_OMPTileDirective 

OpenMP tile directive.

CXCursor_OMPCanonicalLoop 

OpenMP canonical loop.

CXCursor_OMPInteropDirective 

OpenMP interop directive.

CXCursor_OMPDispatchDirective 

OpenMP dispatch directive.

CXCursor_OMPMaskedDirective 

OpenMP masked directive.

CXCursor_OMPUnrollDirective 

OpenMP unroll directive.

CXCursor_OMPMetaDirective 

OpenMP metadirective directive.

CXCursor_OMPGenericLoopDirective 

OpenMP loop directive.

CXCursor_OMPTeamsGenericLoopDirective 

OpenMP teams loop directive.

CXCursor_OMPTargetTeamsGenericLoopDirective 

OpenMP target teams loop directive.

CXCursor_OMPParallelGenericLoopDirective 

OpenMP parallel loop directive.

CXCursor_OMPTargetParallelGenericLoopDirective 

OpenMP target parallel loop directive.

CXCursor_OMPParallelMaskedDirective 

OpenMP parallel masked directive.

CXCursor_OMPMaskedTaskLoopDirective 

OpenMP masked taskloop directive.

CXCursor_OMPMaskedTaskLoopSimdDirective 

OpenMP masked taskloop simd directive.

CXCursor_OMPParallelMaskedTaskLoopDirective 

OpenMP parallel masked taskloop directive.

CXCursor_OMPParallelMaskedTaskLoopSimdDirective 

OpenMP parallel masked taskloop simd directive.

CXCursor_OMPErrorDirective 

OpenMP error directive.

CXCursor_OMPScopeDirective 

OpenMP scope directive.

CXCursor_OMPReverseDirective 

OpenMP reverse directive.

CXCursor_OMPInterchangeDirective 

OpenMP interchange directive.

CXCursor_OMPAssumeDirective 

OpenMP assume directive.

CXCursor_OpenACCComputeConstruct 

OpenACC Compute Construct.

CXCursor_OpenACCLoopConstruct 

OpenACC Loop Construct.

CXCursor_OpenACCCombinedConstruct 

OpenACC Combined Constructs.

CXCursor_OpenACCDataConstruct 

OpenACC data Construct.

CXCursor_OpenACCEnterDataConstruct 

OpenACC enter data Construct.

CXCursor_OpenACCExitDataConstruct 

OpenACC exit data Construct.

CXCursor_OpenACCHostDataConstruct 

OpenACC host_data Construct.

CXCursor_OpenACCWaitConstruct 

OpenACC wait Construct.

CXCursor_OpenACCInitConstruct 

OpenACC init Construct.

CXCursor_OpenACCShutdownConstruct 

OpenACC shutdown Construct.

CXCursor_LastStmt 
CXCursor_TranslationUnit 

Cursor that represents the translation unit itself.

The translation unit cursor exists primarily to act as the root cursor for traversing the contents of a translation unit.

CXCursor_FirstAttr 
CXCursor_UnexposedAttr 

An attribute whose specific kind is not exposed via this interface.

CXCursor_IBActionAttr 
CXCursor_IBOutletAttr 
CXCursor_IBOutletCollectionAttr 
CXCursor_CXXFinalAttr 
CXCursor_CXXOverrideAttr 
CXCursor_AnnotateAttr 
CXCursor_AsmLabelAttr 
CXCursor_PackedAttr 
CXCursor_PureAttr 
CXCursor_ConstAttr 
CXCursor_NoDuplicateAttr 
CXCursor_CUDAConstantAttr 
CXCursor_CUDADeviceAttr 
CXCursor_CUDAGlobalAttr 
CXCursor_CUDAHostAttr 
CXCursor_CUDASharedAttr 
CXCursor_VisibilityAttr 
CXCursor_DLLExport 
CXCursor_DLLImport 
CXCursor_NSReturnsRetained 
CXCursor_NSReturnsNotRetained 
CXCursor_NSReturnsAutoreleased 
CXCursor_NSConsumesSelf 
CXCursor_NSConsumed 
CXCursor_ObjCException 
CXCursor_ObjCNSObject 
CXCursor_ObjCIndependentClass 
CXCursor_ObjCPreciseLifetime 
CXCursor_ObjCReturnsInnerPointer 
CXCursor_ObjCRequiresSuper 
CXCursor_ObjCRootClass 
CXCursor_ObjCSubclassingRestricted 
CXCursor_ObjCExplicitProtocolImpl 
CXCursor_ObjCDesignatedInitializer 
CXCursor_ObjCRuntimeVisible 
CXCursor_ObjCBoxable 
CXCursor_FlagEnum 
CXCursor_ConvergentAttr 
CXCursor_WarnUnusedAttr 
CXCursor_WarnUnusedResultAttr 
CXCursor_AlignedAttr 
CXCursor_LastAttr 
CXCursor_PreprocessingDirective 
CXCursor_MacroDefinition 
CXCursor_MacroExpansion 
CXCursor_MacroInstantiation 
CXCursor_InclusionDirective 
CXCursor_FirstPreprocessing 
CXCursor_LastPreprocessing 
CXCursor_ModuleImportDecl 

A module import declaration.

CXCursor_TypeAliasTemplateDecl 
CXCursor_StaticAssert 

A static_assert or _Static_assert node.

CXCursor_FriendDecl 

a friend declaration.

CXCursor_ConceptDecl 

a concept declaration.

CXCursor_FirstExtraDecl 
CXCursor_LastExtraDecl 
CXCursor_OverloadCandidate 

A code completion overload candidate.

Definition at line 1186 of file Index.h.

◆ CXGlobalOptFlags

Enumerator
CXGlobalOpt_None 

Used to indicate that no special CXIndex options are needed.

CXGlobalOpt_ThreadBackgroundPriorityForIndexing 

Used to indicate that threads that libclang creates for indexing purposes should use background priority.

Affects clang_indexSourceFile, clang_indexTranslationUnit, clang_parseTranslationUnit, clang_saveTranslationUnit.

CXGlobalOpt_ThreadBackgroundPriorityForEditing 

Used to indicate that threads that libclang creates for editing purposes should use background priority.

Affects clang_reparseTranslationUnit, clang_codeCompleteAt, clang_annotateTokens

CXGlobalOpt_ThreadBackgroundPriorityForAll 

Used to indicate that all threads that libclang creates should use background priority.

Definition at line 298 of file Index.h.

Function Documentation

◆ clang_createIndex()

CINDEX_LINKAGE CXIndex clang_createIndex ( int  excludeDeclarationsFromPCH,
int  displayDiagnostics 
)

Provides a shared context for creating translation units.

It provides two options:

  • excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local" declarations (when loading any new translation units). A "local" declaration is one that belongs in the translation unit itself and not in a precompiled header that was used by the translation unit. If zero, all declarations will be enumerated.

Here is an example:

// excludeDeclsFromPCH = 1, displayDiagnostics=1
Idx = clang_createIndex(1, 1);
// IndexTest.pch was produced with the following command:
// "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
// This will load all the symbols from 'IndexTest.pch'
TranslationUnitVisitor, 0);
// This will load all the symbols from 'IndexTest.c', excluding symbols
// from 'IndexTest.pch'.
char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
0, 0);
TranslationUnitVisitor, 0);
CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit)
Retrieve the cursor that represents the given translation unit.
CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent, CXCursorVisitor visitor, CXClientData client_data)
Visit the children of a particular cursor.
CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(CXIndex CIdx, const char *ast_filename)
Same as clang_createTranslationUnit2, but returns the CXTranslationUnit instead of an error code.
CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit)
Destroy the specified CXTranslationUnit object.
CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(CXIndex CIdx, const char *source_filename, int num_clang_command_line_args, const char *const *clang_command_line_args, unsigned num_unsaved_files, struct CXUnsavedFile *unsaved_files)
Return the CXTranslationUnit for a given source file and the provided command line arguments one woul...
CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH, int displayDiagnostics)
Provides a shared context for creating translation units.

This process of creating the 'pch', loading it separately, and using it (via -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks (which gives the indexer the same performance benefit as the compiler).

◆ clang_createIndexWithOptions()

CINDEX_LINKAGE CXIndex clang_createIndexWithOptions ( const CXIndexOptions options)

Provides a shared context for creating translation units.

Call this function instead of clang_createIndex() if you need to configure the additional options in CXIndexOptions.

Returns
The created index or null in case of error, such as an unsupported value of options->Size.

For example:

CXIndex createIndex(const char *ApplicationTemporaryPath) {
const int ExcludeDeclarationsFromPCH = 1;
const int DisplayDiagnostics = 1;
CXIndex Idx;
#if CINDEX_VERSION_MINOR >= 64
memset(&Opts, 0, sizeof(Opts));
Opts.Size = sizeof(CXIndexOptions);
Opts.ExcludeDeclarationsFromPCH = ExcludeDeclarationsFromPCH;
Opts.DisplayDiagnostics = DisplayDiagnostics;
Opts.PreambleStoragePath = ApplicationTemporaryPath;
if (Idx)
return Idx;
fprintf(stderr,
"clang_createIndexWithOptions() failed. "
"CINDEX_VERSION_MINOR = %d, sizeof(CXIndexOptions) = %u\n",
#else
(void)ApplicationTemporaryPath;
#endif
Idx = clang_createIndex(ExcludeDeclarationsFromPCH, DisplayDiagnostics);
return Idx;
}
#define CINDEX_VERSION_MINOR
Definition: Index.h:37
CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex)
Gets the general options associated with a CXIndex.
CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options)
Sets general options associated with a CXIndex.
CINDEX_LINKAGE CXIndex clang_createIndexWithOptions(const CXIndexOptions *options)
Provides a shared context for creating translation units.
void * CXIndex
An "index" that consists of a set of translation units that would typically be linked together into a...
Definition: Index.h:80
@ CXGlobalOpt_ThreadBackgroundPriorityForIndexing
Used to indicate that threads that libclang creates for indexing purposes should use background prior...
Definition: Index.h:311
unsigned char ThreadBackgroundPriorityForIndexing
A CXChoice enumerator that specifies the indexing priority policy.
Definition: Index.h:365
unsigned ExcludeDeclarationsFromPCH
Definition: Index.h:374
const char * PreambleStoragePath
The path to a directory, in which to store temporary PCH files.
Definition: Index.h:395
unsigned DisplayDiagnostics
Definition: Index.h:378
See also
clang_createIndex()

◆ clang_CXIndex_getGlobalOptions()

CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions ( CXIndex  )

Gets the general options associated with a CXIndex.

This function allows to obtain the final option values used by libclang after specifying the option policies via CXChoice enumerators.

Returns
A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that are associated with the given CXIndex object.

◆ clang_CXIndex_setGlobalOptions()

CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions ( CXIndex  ,
unsigned  options 
)

Sets general options associated with a CXIndex.

This function is DEPRECATED. Set CXIndexOptions::ThreadBackgroundPriorityForIndexing and/or CXIndexOptions::ThreadBackgroundPriorityForEditing and call clang_createIndexWithOptions() instead.

For example:

Parameters
optionsA bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.

◆ clang_CXIndex_setInvocationEmissionPathOption()

CINDEX_LINKAGE void clang_CXIndex_setInvocationEmissionPathOption ( CXIndex  ,
const char *  Path 
)

Sets the invocation emission path option in a CXIndex.

This function is DEPRECATED. Set CXIndexOptions::InvocationEmissionPath and call clang_createIndexWithOptions() instead.

The invocation emission path specifies a path which will contain log files for certain libclang invocations. A null value (default) implies that libclang invocations are not logged..

◆ clang_disposeIndex()

CINDEX_LINKAGE void clang_disposeIndex ( CXIndex  index)

Destroy the given index.

The index must not be destroyed until all of the translation units created within that index have been destroyed.

◆ clang_getAllSkippedRanges()

CINDEX_LINKAGE CXSourceRangeList * clang_getAllSkippedRanges ( CXTranslationUnit  tu)

Retrieve all ranges from all files that were skipped by the preprocessor.

The preprocessor will skip lines when they are surrounded by an if/ifdef/ifndef directive whose condition does not evaluate to true.

◆ clang_getDiagnostic()

CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic ( CXTranslationUnit  Unit,
unsigned  Index 
)

Retrieve a diagnostic associated with the given translation unit.

Parameters
Unitthe translation unit to query.
Indexthe zero-based diagnostic number to retrieve.
Returns
the requested diagnostic. This diagnostic must be freed via a call to clang_disposeDiagnostic().

◆ clang_getDiagnosticSetFromTU()

CINDEX_LINKAGE CXDiagnosticSet clang_getDiagnosticSetFromTU ( CXTranslationUnit  Unit)

Retrieve the complete set of diagnostics associated with a translation unit.

Parameters
Unitthe translation unit to query.

◆ clang_getFile()

CINDEX_LINKAGE CXFile clang_getFile ( CXTranslationUnit  tu,
const char *  file_name 
)

Retrieve a file handle within the given translation unit.

Parameters
tuthe translation unit
file_namethe name of the file.
Returns
the file handle for the named file in the translation unit tu, or a NULL file handle if the file was not a part of this translation unit.

◆ clang_getFileContents()

CINDEX_LINKAGE const char * clang_getFileContents ( CXTranslationUnit  tu,
CXFile  file,
size_t size 
)

Retrieve the buffer associated with the given file.

Parameters
tuthe translation unit
filethe file for which to retrieve the buffer.
size[out] if non-NULL, will be set to the size of the buffer.
Returns
a pointer to the buffer in memory that holds the contents of file, or a NULL pointer when the file is not loaded.

◆ clang_getLocation()

CINDEX_LINKAGE CXSourceLocation clang_getLocation ( CXTranslationUnit  tu,
CXFile  file,
unsigned  line,
unsigned  column 
)

Retrieves the source location associated with a given file/line/column in a particular translation unit.

◆ clang_getLocationForOffset()

CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset ( CXTranslationUnit  tu,
CXFile  file,
unsigned  offset 
)

Retrieves the source location associated with a given character offset in a particular translation unit.

◆ clang_getNumDiagnostics()

CINDEX_LINKAGE unsigned clang_getNumDiagnostics ( CXTranslationUnit  Unit)

Determine the number of diagnostics produced for the given translation unit.

◆ clang_getSkippedRanges()

CINDEX_LINKAGE CXSourceRangeList * clang_getSkippedRanges ( CXTranslationUnit  tu,
CXFile  file 
)

Retrieve all ranges that were skipped by the preprocessor.

The preprocessor will skip lines when they are surrounded by an if/ifdef/ifndef directive whose condition does not evaluate to true.

◆ clang_isFileMultipleIncludeGuarded()

CINDEX_LINKAGE unsigned clang_isFileMultipleIncludeGuarded ( CXTranslationUnit  tu,
CXFile  file 
)

Determine whether the given header is guarded against multiple inclusions, either with the conventional #ifndef/#define/#endif macro guards or with #pragma once.