clang API Documentation

Classes | Modules | Typedefs | Enumerations | Functions
libclang: C Interface to Clang
Collaboration diagram for libclang: C Interface to Clang:

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  CXCursor
 A cursor representing some element in the abstract syntax tree for a translation unit. More...

Modules

 CompilationDatabase functions
 String manipulation routines
 File manipulation routines
 Physical source locations
 Diagnostic reporting
 Translation unit manipulation
 Cursor manipulations
 Mapping between cursors and source code
 Type information for CXCursors
 Information for attributes
 Traversing the AST with cursors
 Cross-referencing in the AST
 Name Mangling API Functions
 Module introspection
 C++ AST introspection
 Token extraction and manipulation
 Debugging facilities
 Code completion
 Miscellaneous utility functions
 Remapping functions
 Higher level API functions

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
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.

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  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_LastExpr = CXCursor_ObjCSelfExpr, 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_LastStmt = CXCursor_OMPTeamsDirective, CXCursor_TranslationUnit = 300, 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_LastAttr = CXCursor_CUDASharedAttr, 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_FirstExtraDecl = CXCursor_ModuleImportDecl, CXCursor_LastExtraDecl = CXCursor_ModuleImportDecl
}
 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 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.

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

typedef void* CXClientData

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

Definition at line 92 of file Index.h.

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 81 of file Index.h.

typedef struct CXTranslationUnitImpl* CXTranslationUnit

A single translation unit, which resides in an index.

Definition at line 86 of file Index.h.

typedef struct CXVersion CXVersion

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


Enumeration Type Documentation

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 125 of file Index.h.

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.

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_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 satement ";": 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_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_LastAttr 
CXCursor_PreprocessingDirective 
CXCursor_MacroDefinition 
CXCursor_MacroExpansion 
CXCursor_MacroInstantiation 
CXCursor_InclusionDirective 
CXCursor_FirstPreprocessing 
CXCursor_LastPreprocessing 
CXCursor_ModuleImportDecl 

A module import declaration.

CXCursor_FirstExtraDecl 
CXCursor_LastExtraDecl 

Definition at line 1525 of file Index.h.

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 220 of file Index.h.


Function Documentation

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'
   clang_visitChildren(clang_getTranslationUnitCursor(TU),
                       TranslationUnitVisitor, 0);
   clang_disposeTranslationUnit(TU);

   // 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);
   clang_visitChildren(clang_getTranslationUnitCursor(TU),
                       TranslationUnitVisitor, 0);
   clang_disposeTranslationUnit(TU);

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).

Gets the general options associated with a CXIndex.

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

Sets general options associated with a CXIndex.

For example:

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

Destroy the given index.

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