clang API Documentation
![]() |
Classes | |
struct | CXType |
The type of an element in the abstract syntax tree. More... | |
Enumerations | |
enum | CXTypeKind { CXType_Invalid = 0, CXType_Unexposed = 1, CXType_Void = 2, CXType_Bool = 3, CXType_Char_U = 4, CXType_UChar = 5, CXType_Char16 = 6, CXType_Char32 = 7, CXType_UShort = 8, CXType_UInt = 9, CXType_ULong = 10, CXType_ULongLong = 11, CXType_UInt128 = 12, CXType_Char_S = 13, CXType_SChar = 14, CXType_WChar = 15, CXType_Short = 16, CXType_Int = 17, CXType_Long = 18, CXType_LongLong = 19, CXType_Int128 = 20, CXType_Float = 21, CXType_Double = 22, CXType_LongDouble = 23, CXType_NullPtr = 24, CXType_Overload = 25, CXType_Dependent = 26, CXType_ObjCId = 27, CXType_ObjCClass = 28, CXType_ObjCSel = 29, CXType_FirstBuiltin = CXType_Void, CXType_LastBuiltin = CXType_ObjCSel, CXType_Complex = 100, CXType_Pointer = 101, CXType_BlockPointer = 102, CXType_LValueReference = 103, CXType_RValueReference = 104, CXType_Record = 105, CXType_Enum = 106, CXType_Typedef = 107, CXType_ObjCInterface = 108, CXType_ObjCObjectPointer = 109, CXType_FunctionNoProto = 110, CXType_FunctionProto = 111, CXType_ConstantArray = 112, CXType_Vector = 113, CXType_IncompleteArray = 114, CXType_VariableArray = 115, CXType_DependentSizedArray = 116, CXType_MemberPointer = 117 } |
Describes the kind of type. More... | |
enum | CXCallingConv { CXCallingConv_Default = 0, CXCallingConv_C = 1, CXCallingConv_X86StdCall = 2, CXCallingConv_X86FastCall = 3, CXCallingConv_X86ThisCall = 4, CXCallingConv_X86Pascal = 5, CXCallingConv_AAPCS = 6, CXCallingConv_AAPCS_VFP = 7, CXCallingConv_PnaclCall = 8, CXCallingConv_IntelOclBicc = 9, CXCallingConv_X86_64Win64 = 10, CXCallingConv_X86_64SysV = 11, CXCallingConv_X86VectorCall = 12, CXCallingConv_Invalid = 100, CXCallingConv_Unexposed = 200 } |
Describes the calling convention of a function type. More... | |
enum | CXTemplateArgumentKind { CXTemplateArgumentKind_Null, CXTemplateArgumentKind_Type, CXTemplateArgumentKind_Declaration, CXTemplateArgumentKind_NullPtr, CXTemplateArgumentKind_Integral, CXTemplateArgumentKind_Template, CXTemplateArgumentKind_TemplateExpansion, CXTemplateArgumentKind_Expression, CXTemplateArgumentKind_Pack, CXTemplateArgumentKind_Invalid } |
Describes the kind of a template argument. More... | |
enum | CXTypeLayoutError { CXTypeLayoutError_Invalid = -1, CXTypeLayoutError_Incomplete = -2, CXTypeLayoutError_Dependent = -3, CXTypeLayoutError_NotConstantSize = -4, CXTypeLayoutError_InvalidFieldName = -5 } |
List the possible error codes for clang_Type_getSizeOf , clang_Type_getAlignOf , clang_Type_getOffsetOf and clang_Cursor_getOffsetOf . More... | |
enum | CXRefQualifierKind { CXRefQualifier_None = 0, CXRefQualifier_LValue, CXRefQualifier_RValue } |
enum | CX_CXXAccessSpecifier { CX_CXXInvalidAccessSpecifier, CX_CXXPublic, CX_CXXProtected, CX_CXXPrivate } |
Represents the C++ access control level to a base class for a cursor with kind CX_CXXBaseSpecifier. More... | |
enum | CX_StorageClass { CX_SC_Invalid, CX_SC_None, CX_SC_Extern, CX_SC_Static, CX_SC_PrivateExtern, CX_SC_OpenCLWorkGroupLocal, CX_SC_Auto, CX_SC_Register } |
Represents the storage classes as declared in the source. CX_SC_Invalid was added for the clase that the passed cursor in not a declaration. More... | |
Functions | |
CINDEX_LINKAGE CXType | clang_getCursorType (CXCursor C) |
Retrieve the type of a CXCursor (if any). | |
CINDEX_LINKAGE CXString | clang_getTypeSpelling (CXType CT) |
Pretty-print the underlying type using the rules of the language of the translation unit from which it came. | |
CINDEX_LINKAGE CXType | clang_getTypedefDeclUnderlyingType (CXCursor C) |
Retrieve the underlying type of a typedef declaration. | |
CINDEX_LINKAGE CXType | clang_getEnumDeclIntegerType (CXCursor C) |
Retrieve the integer type of an enum declaration. | |
CINDEX_LINKAGE long long | clang_getEnumConstantDeclValue (CXCursor C) |
Retrieve the integer value of an enum constant declaration as a signed long long. | |
CINDEX_LINKAGE unsigned long long | clang_getEnumConstantDeclUnsignedValue (CXCursor C) |
Retrieve the integer value of an enum constant declaration as an unsigned long long. | |
CINDEX_LINKAGE int | clang_getFieldDeclBitWidth (CXCursor C) |
Retrieve the bit width of a bit field declaration as an integer. | |
CINDEX_LINKAGE int | clang_Cursor_getNumArguments (CXCursor C) |
Retrieve the number of non-variadic arguments associated with a given cursor. | |
CINDEX_LINKAGE CXCursor | clang_Cursor_getArgument (CXCursor C, unsigned i) |
Retrieve the argument cursor of a function or method. | |
CINDEX_LINKAGE int | clang_Cursor_getNumTemplateArguments (CXCursor C) |
Returns the number of template args of a function decl representing a template specialization. | |
CINDEX_LINKAGE enum CXTemplateArgumentKind | clang_Cursor_getTemplateArgumentKind (CXCursor C, unsigned I) |
Retrieve the kind of the I'th template argument of the CXCursor C. | |
CINDEX_LINKAGE CXType | clang_Cursor_getTemplateArgumentType (CXCursor C, unsigned I) |
Retrieve a CXType representing the type of a TemplateArgument of a function decl representing a template specialization. | |
CINDEX_LINKAGE long long | clang_Cursor_getTemplateArgumentValue (CXCursor C, unsigned I) |
Retrieve the value of an Integral TemplateArgument (of a function decl representing a template specialization) as a signed long long. | |
CINDEX_LINKAGE unsigned long long | clang_Cursor_getTemplateArgumentUnsignedValue (CXCursor C, unsigned I) |
Retrieve the value of an Integral TemplateArgument (of a function decl representing a template specialization) as an unsigned long long. | |
CINDEX_LINKAGE unsigned | clang_equalTypes (CXType A, CXType B) |
Determine whether two CXTypes represent the same type. | |
CINDEX_LINKAGE CXType | clang_getCanonicalType (CXType T) |
Return the canonical type for a CXType. | |
CINDEX_LINKAGE unsigned | clang_isConstQualifiedType (CXType T) |
Determine whether a CXType has the "const" qualifier set, without looking through typedefs that may have added "const" at a different level. | |
CINDEX_LINKAGE unsigned | clang_isVolatileQualifiedType (CXType T) |
Determine whether a CXType has the "volatile" qualifier set, without looking through typedefs that may have added "volatile" at a different level. | |
CINDEX_LINKAGE unsigned | clang_isRestrictQualifiedType (CXType T) |
Determine whether a CXType has the "restrict" qualifier set, without looking through typedefs that may have added "restrict" at a different level. | |
CINDEX_LINKAGE CXType | clang_getPointeeType (CXType T) |
For pointer types, returns the type of the pointee. | |
CINDEX_LINKAGE CXCursor | clang_getTypeDeclaration (CXType T) |
Return the cursor for the declaration of the given type. | |
CINDEX_LINKAGE CXString | clang_getDeclObjCTypeEncoding (CXCursor C) |
CINDEX_LINKAGE CXString | clang_getTypeKindSpelling (enum CXTypeKind K) |
Retrieve the spelling of a given CXTypeKind. | |
CINDEX_LINKAGE enum CXCallingConv | clang_getFunctionTypeCallingConv (CXType T) |
Retrieve the calling convention associated with a function type. | |
CINDEX_LINKAGE CXType | clang_getResultType (CXType T) |
Retrieve the return type associated with a function type. | |
CINDEX_LINKAGE int | clang_getNumArgTypes (CXType T) |
Retrieve the number of non-variadic parameters associated with a function type. | |
CINDEX_LINKAGE CXType | clang_getArgType (CXType T, unsigned i) |
Retrieve the type of a parameter of a function type. | |
CINDEX_LINKAGE unsigned | clang_isFunctionTypeVariadic (CXType T) |
Return 1 if the CXType is a variadic function type, and 0 otherwise. | |
CINDEX_LINKAGE CXType | clang_getCursorResultType (CXCursor C) |
Retrieve the return type associated with a given cursor. | |
CINDEX_LINKAGE unsigned | clang_isPODType (CXType T) |
Return 1 if the CXType is a POD (plain old data) type, and 0 otherwise. | |
CINDEX_LINKAGE CXType | clang_getElementType (CXType T) |
Return the element type of an array, complex, or vector type. | |
CINDEX_LINKAGE long long | clang_getNumElements (CXType T) |
Return the number of elements of an array or vector type. | |
CINDEX_LINKAGE CXType | clang_getArrayElementType (CXType T) |
Return the element type of an array type. | |
CINDEX_LINKAGE long long | clang_getArraySize (CXType T) |
Return the array size of a constant array. | |
CINDEX_LINKAGE long long | clang_Type_getAlignOf (CXType T) |
Return the alignment of a type in bytes as per C++[expr.alignof] standard. | |
CINDEX_LINKAGE CXType | clang_Type_getClassType (CXType T) |
Return the class type of an member pointer type. | |
CINDEX_LINKAGE long long | clang_Type_getSizeOf (CXType T) |
Return the size of a type in bytes as per C++[expr.sizeof] standard. | |
CINDEX_LINKAGE long long | clang_Type_getOffsetOf (CXType T, const char *S) |
Return the offset of a field named S in a record of type T in bits as it would be returned by __offsetof__ as per C++11[18.2p4]. | |
CINDEX_LINKAGE int | clang_Type_getNumTemplateArguments (CXType T) |
Returns the number of template arguments for given class template specialization, or -1 if type T is not a class template specialization. | |
CINDEX_LINKAGE CXType | clang_Type_getTemplateArgumentAsType (CXType T, unsigned i) |
Returns the type template argument of a template class specialization at given index. | |
CINDEX_LINKAGE enum CXRefQualifierKind | clang_Type_getCXXRefQualifier (CXType T) |
Retrieve the ref-qualifier kind of a function or method. | |
CINDEX_LINKAGE unsigned | clang_Cursor_isBitField (CXCursor C) |
Returns non-zero if the cursor specifies a Record member that is a bitfield. | |
CINDEX_LINKAGE unsigned | clang_isVirtualBase (CXCursor) |
Returns 1 if the base class specified by the cursor with kind CX_CXXBaseSpecifier is virtual. | |
CINDEX_LINKAGE enum CX_CXXAccessSpecifier | clang_getCXXAccessSpecifier (CXCursor) |
Returns the access control level for the referenced object. | |
CINDEX_LINKAGE enum CX_StorageClass | clang_Cursor_getStorageClass (CXCursor) |
Returns the storage class for a function or variable declaration. | |
CINDEX_LINKAGE unsigned | clang_getNumOverloadedDecls (CXCursor cursor) |
Determine the number of overloaded declarations referenced by a CXCursor_OverloadedDeclRef cursor. | |
CINDEX_LINKAGE CXCursor | clang_getOverloadedDecl (CXCursor cursor, unsigned index) |
Retrieve a cursor for one of the overloaded declarations referenced by a CXCursor_OverloadedDeclRef cursor. |
enum CX_StorageClass |
enum CXCallingConv |
Describes the calling convention of a function type.
enum CXRefQualifierKind |
Describes the kind of a template argument.
See the definition of llvm::clang::TemplateArgument::ArgKind for full element descriptions.
enum CXTypeKind |
Describes the kind of type.
enum CXTypeLayoutError |
List the possible error codes for clang_Type_getSizeOf
, clang_Type_getAlignOf
, clang_Type_getOffsetOf
and clang_Cursor_getOffsetOf
.
A value of this enumeration type can be returned if the target type is not a valid argument to sizeof, alignof or offsetof.
Retrieve the argument cursor of a function or method.
The argument cursor can be determined for calls as well as for declarations of functions or methods. For other cursors and for invalid indices, an invalid cursor is returned.
Retrieve the number of non-variadic arguments associated with a given cursor.
The number of arguments can be determined for calls as well as for declarations of functions or methods. For other cursors -1 is returned.
Returns the number of template args of a function decl representing a template specialization.
If the argument cursor cannot be converted into a template function declaration, -1 is returned.
For example, for the following declaration and specialization: template <typename T, int kInt, bool kBool> void foo() { ... }
template <> void foo<float, -7, true>();
The value 3 would be returned from this call.
Returns the storage class for a function or variable declaration.
If the passed in Cursor is not a function or variable declaration, CX_SC_Invalid is returned else the storage class.
CINDEX_LINKAGE enum CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind | ( | CXCursor | C, |
unsigned | I | ||
) |
Retrieve the kind of the I'th template argument of the CXCursor C.
If the argument CXCursor does not represent a FunctionDecl, an invalid template argument kind is returned.
For example, for the following declaration and specialization: template <typename T, int kInt, bool kBool> void foo() { ... }
template <> void foo<float, -7, true>();
For I = 0, 1, and 2, Type, Integral, and Integral will be returned, respectively.
Retrieve a CXType representing the type of a TemplateArgument of a function decl representing a template specialization.
If the argument CXCursor does not represent a FunctionDecl whose I'th template argument has a kind of CXTemplateArgKind_Integral, an invalid type is returned.
For example, for the following declaration and specialization: template <typename T, int kInt, bool kBool> void foo() { ... }
template <> void foo<float, -7, true>();
If called with I = 0, "float", will be returned. Invalid types will be returned for I == 1 or 2.
CINDEX_LINKAGE unsigned long long clang_Cursor_getTemplateArgumentUnsignedValue | ( | CXCursor | C, |
unsigned | I | ||
) |
Retrieve the value of an Integral TemplateArgument (of a function decl representing a template specialization) as an unsigned long long.
It is undefined to call this function on a CXCursor that does not represent a FunctionDecl or whose I'th template argument is not an integral value.
For example, for the following declaration and specialization: template <typename T, int kInt, bool kBool> void foo() { ... }
template <> void foo<float, 2147483649, true>();
If called with I = 1 or 2, 2147483649 or true will be returned, respectively. For I == 0, this function's behavior is undefined.
CINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue | ( | CXCursor | C, |
unsigned | I | ||
) |
Retrieve the value of an Integral TemplateArgument (of a function decl representing a template specialization) as a signed long long.
It is undefined to call this function on a CXCursor that does not represent a FunctionDecl or whose I'th template argument is not an integral value.
For example, for the following declaration and specialization: template <typename T, int kInt, bool kBool> void foo() { ... }
template <> void foo<float, -7, true>();
If called with I = 1 or 2, -7 or true will be returned, respectively. For I == 0, this function's behavior is undefined.
Returns non-zero if the cursor specifies a Record member that is a bitfield.
CINDEX_LINKAGE unsigned clang_equalTypes | ( | CXType | A, |
CXType | B | ||
) |
Determine whether two CXTypes represent the same type.
CINDEX_LINKAGE CXType clang_getArgType | ( | CXType | T, |
unsigned | i | ||
) |
Retrieve the type of a parameter of a function type.
If a non-function type is passed in or the function does not have enough parameters, an invalid type is returned.
Return the element type of an array type.
If a non-array type is passed in, an invalid type is returned.
CINDEX_LINKAGE long long clang_getArraySize | ( | CXType | T | ) |
Return the array size of a constant array.
If a non-array type is passed in, -1 is returned.
Return the canonical type for a CXType.
Clang's type system explicitly models typedefs and all the ways a specific type can be represented. The canonical type is the underlying type with all the "sugar" removed. For example, if 'T' is a typedef for 'int', the canonical type for 'T' would be 'int'.
Retrieve the return type associated with a given cursor.
This only returns a valid type if the cursor refers to a function or method.
Retrieve the type of a CXCursor (if any).
Returns the access control level for the referenced object.
If the cursor refers to a C++ declaration, its access control level within its parent scope is returned. Otherwise, if the cursor refers to a base specifier or access specifier, the specifier itself is returned.
Returns the Objective-C type encoding for the specified declaration.
Return the element type of an array, complex, or vector type.
If a type is passed in that is not an array, complex, or vector type, an invalid type is returned.
CINDEX_LINKAGE unsigned long long clang_getEnumConstantDeclUnsignedValue | ( | CXCursor | C | ) |
Retrieve the integer value of an enum constant declaration as an unsigned long long.
If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned. Since this is also potentially a valid constant value, the kind of the cursor must be verified before calling this function.
CINDEX_LINKAGE long long clang_getEnumConstantDeclValue | ( | CXCursor | C | ) |
Retrieve the integer value of an enum constant declaration as a signed long long.
If the cursor does not reference an enum constant declaration, LLONG_MIN is returned. Since this is also potentially a valid constant value, the kind of the cursor must be verified before calling this function.
Retrieve the integer type of an enum declaration.
If the cursor does not reference an enum declaration, an invalid type is returned.
Retrieve the bit width of a bit field declaration as an integer.
If a cursor that is not a bit field declaration is passed in, -1 is returned.
Retrieve the calling convention associated with a function type.
If a non-function type is passed in, CXCallingConv_Invalid is returned.
CINDEX_LINKAGE int clang_getNumArgTypes | ( | CXType | T | ) |
Retrieve the number of non-variadic parameters associated with a function type.
If a non-function type is passed in, -1 is returned.
CINDEX_LINKAGE long long clang_getNumElements | ( | CXType | T | ) |
Return the number of elements of an array or vector type.
If a type is passed in that is not an array or vector type, -1 is returned.
Determine the number of overloaded declarations referenced by a CXCursor_OverloadedDeclRef
cursor.
cursor | The cursor whose overloaded declarations are being queried. |
cursor
. If it is not a CXCursor_OverloadedDeclRef
cursor, returns 0. CINDEX_LINKAGE CXCursor clang_getOverloadedDecl | ( | CXCursor | cursor, |
unsigned | index | ||
) |
Retrieve a cursor for one of the overloaded declarations referenced by a CXCursor_OverloadedDeclRef
cursor.
cursor | The cursor whose overloaded declarations are being queried. |
index | The zero-based index into the set of overloaded declarations in the cursor. |
cursor
at the specified index
. If the cursor does not have an associated set of overloaded declarations, or if the index is out of bounds, returns clang_getNullCursor()
; For pointer types, returns the type of the pointee.
Retrieve the return type associated with a function type.
If a non-function type is passed in, an invalid type is returned.
Return the cursor for the declaration of the given type.
Retrieve the underlying type of a typedef declaration.
If the cursor does not reference a typedef declaration, an invalid type is returned.
Retrieve the spelling of a given CXTypeKind.
Pretty-print the underlying type using the rules of the language of the translation unit from which it came.
If the type is invalid, an empty string is returned.
Determine whether a CXType has the "const" qualifier set, without looking through typedefs that may have added "const" at a different level.
Return 1 if the CXType is a variadic function type, and 0 otherwise.
Return 1 if the CXType is a POD (plain old data) type, and 0 otherwise.
Determine whether a CXType has the "restrict" qualifier set, without looking through typedefs that may have added "restrict" at a different level.
Returns 1 if the base class specified by the cursor with kind CX_CXXBaseSpecifier is virtual.
Determine whether a CXType has the "volatile" qualifier set, without looking through typedefs that may have added "volatile" at a different level.
CINDEX_LINKAGE long long clang_Type_getAlignOf | ( | CXType | T | ) |
Return the alignment of a type in bytes as per C++[expr.alignof] standard.
If the type declaration is invalid, CXTypeLayoutError_Invalid is returned. If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete is returned. If the type declaration is a dependent type, CXTypeLayoutError_Dependent is returned. If the type declaration is not a constant size type, CXTypeLayoutError_NotConstantSize is returned.
Return the class type of an member pointer type.
If a non-member-pointer type is passed in, an invalid type is returned.
Retrieve the ref-qualifier kind of a function or method.
The ref-qualifier is returned for C++ functions or methods. For other types or non-C++ declarations, CXRefQualifier_None is returned.
Returns the number of template arguments for given class template specialization, or -1 if type T
is not a class template specialization.
Variadic argument packs count as only one argument, and can not be inspected further.
CINDEX_LINKAGE long long clang_Type_getOffsetOf | ( | CXType | T, |
const char * | S | ||
) |
Return the offset of a field named S in a record of type T in bits as it would be returned by __offsetof__ as per C++11[18.2p4].
If the cursor is not a record field declaration, CXTypeLayoutError_Invalid is returned. If the field's type declaration is an incomplete type, CXTypeLayoutError_Incomplete is returned. If the field's type declaration is a dependent type, CXTypeLayoutError_Dependent is returned. If the field's name S is not found, CXTypeLayoutError_InvalidFieldName is returned.
CINDEX_LINKAGE long long clang_Type_getSizeOf | ( | CXType | T | ) |
Return the size of a type in bytes as per C++[expr.sizeof] standard.
If the type declaration is invalid, CXTypeLayoutError_Invalid is returned. If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete is returned. If the type declaration is a dependent type, CXTypeLayoutError_Dependent is returned.
Returns the type template argument of a template class specialization at given index.
This function only returns template type arguments and does not handle template template arguments or variadic packs.