From 66f433a74644fdb4c87990fb76dbb1cada83f520 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Tue, 6 Dec 2011 22:05:01 +0000 Subject: [libclang] API enhancements by Joe Groff! - Exposes a CXType_Vector type kind for vector types. - Adds generalized versions of the clang_getArrayElementType and clang_getArraySize functions, named clang_getElementType and clang_getNumElements, which work on array, vector, or complex types. - Adds additional functions for querying function types. clang_isFunctionTypeVariadic returns true if a function type is variadic. clang_getFunctionCallingConv returns an enumeration value indicating the calling convention of the function type. clang_getNumArgTypes returns the number of static argument types, and clang_getArgType gets the type of an argument. - Adds a clang_getTypedefDeclUnderlyingType function to get the underlying type from a TypedefDecl cursor. - Adds a clang_getEnumDeclIntegerType function to get the integer type from an EnumDecl cursor. - Adds clang_getEnumConstantDeclValue and clang_getEnumConstantDeclUnsignedValue functions to get the value of an EnumConstantDecl as a signed or unsigned long long, respectively. - Exposes a CXCursor_AsmLabelAttr cursor kind for __asm__("label") attributes. - Alters clang_getCursorSpelling to return the label value for AsmLabelAttr-kind cursors. llvm-svn: 145972 --- clang/include/clang-c/Index.h | 111 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 107 insertions(+), 4 deletions(-) (limited to 'clang/include/clang-c') diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h index 564ac56b7f0..52390217b0d 100644 --- a/clang/include/clang-c/Index.h +++ b/clang/include/clang-c/Index.h @@ -1911,7 +1911,8 @@ enum CXCursorKind { CXCursor_CXXFinalAttr = 404, CXCursor_CXXOverrideAttr = 405, CXCursor_AnnotateAttr = 406, - CXCursor_LastAttr = CXCursor_AnnotateAttr, + CXCursor_AsmLabelAttr = 407, + CXCursor_LastAttr = CXCursor_AsmLabelAttr, /* Preprocessing */ CXCursor_PreprocessingDirective = 500, @@ -2383,9 +2384,28 @@ enum CXTypeKind { CXType_ObjCObjectPointer = 109, CXType_FunctionNoProto = 110, CXType_FunctionProto = 111, - CXType_ConstantArray = 112 + CXType_ConstantArray = 112, + CXType_Vector = 113 }; +/** + * \brief Describes the calling convention of a function type + */ +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_Invalid = 100, + CXCallingConv_Unexposed = 200 +}; + + /** * \brief The type of an element in the abstract syntax tree. * @@ -2400,6 +2420,42 @@ typedef struct { */ CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C); +/** + * \brief Retrieve the underlying type of a typedef declaration. + * + * If the cursor does not reference a typedef declaration, an invalid type is + * returned. + */ +CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C); + +/** + * \brief Retrieve the integer type of an enum declaration. + * + * If the cursor does not reference an enum declaration, an invalid type is + * returned. + */ +CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C); + +/** + * \brief 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. + */ +CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C); + +/** + * \brief 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 unsigned long long clang_getEnumConstantDeclUnsignedValue(CXCursor C); + /** * \determine Determine whether two CXTypes represent the same type. * @@ -2457,14 +2513,45 @@ CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C); */ CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K); +/** + * \brief Retrieve the calling convention associated with a function type. + * + * If a non-function type is passed in, CXCallingConv_Invalid is returned. + */ +CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T); + /** * \brief Retrieve the result type associated with a function type. + * + * If a non-function type is passed in, an invalid type is returned. */ CINDEX_LINKAGE CXType clang_getResultType(CXType T); /** - * \brief Retrieve the result type associated with a given cursor. This only - * returns a valid type of the cursor refers to a function or method. + * \brief Retrieve the number of non-variadic arguments associated with a function type. + * + * If a non-function type is passed in, UINT_MAX is returned. + */ +CINDEX_LINKAGE unsigned clang_getNumArgTypes(CXType T); + +/** + * \brief Retrieve the type of an argument 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. + */ +CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i); + +/** + * \brief Return 1 if the CXType is a variadic function type, and 0 otherwise. + * + */ +CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T); + +/** + * \brief Retrieve the result type associated with a given cursor. + * + * This only returns a valid type if the cursor refers to a function or method. */ CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C); @@ -2474,6 +2561,22 @@ CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C); */ CINDEX_LINKAGE unsigned clang_isPODType(CXType T); +/** + * \brief 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 CXType clang_getElementType(CXType T); + +/** + * \brief 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. + */ +CINDEX_LINKAGE long long clang_getNumElements(CXType T); + /** * \brief Return the element type of an array type. * -- cgit v1.2.3