diff options
Diffstat (limited to 'tools/libclang/CXType.cpp')
-rw-r--r-- | tools/libclang/CXType.cpp | 70 |
1 files changed, 68 insertions, 2 deletions
diff --git a/tools/libclang/CXType.cpp b/tools/libclang/CXType.cpp index 1482415..1e2cb18 100644 --- a/tools/libclang/CXType.cpp +++ b/tools/libclang/CXType.cpp @@ -85,7 +85,11 @@ static CXTypeKind GetTypeKind(QualType T) { TKCASE(FunctionNoProto); TKCASE(FunctionProto); TKCASE(ConstantArray); + TKCASE(IncompleteArray); + TKCASE(VariableArray); + TKCASE(DependentSizedArray); TKCASE(Vector); + TKCASE(MemberPointer); default: return CXType_Unexposed; } @@ -107,6 +111,11 @@ CXType cxtype::MakeCXType(QualType T, CXTranslationUnit TU) { else if (Ctx.isObjCSelType(UnqualT)) TK = CXType_ObjCSel; } + + /* Handle decayed types as the original type */ + if (const DecayedType *DT = T->getAs<DecayedType>()) { + return MakeCXType(DT->getOriginalType(), TU); + } } if (TK == CXType_Invalid) TK = GetTypeKind(T); @@ -357,6 +366,9 @@ CXType clang_getPointeeType(CXType CT) { case Type::ObjCObjectPointer: T = cast<ObjCObjectPointerType>(TP)->getPointeeType(); break; + case Type::MemberPointer: + T = cast<MemberPointerType>(TP)->getPointeeType(); + break; default: T = QualType(); break; @@ -466,7 +478,11 @@ CXString clang_getTypeKindSpelling(enum CXTypeKind K) { TKIND(FunctionNoProto); TKIND(FunctionProto); TKIND(ConstantArray); + TKIND(IncompleteArray); + TKIND(VariableArray); + TKIND(DependentSizedArray); TKIND(Vector); + TKIND(MemberPointer); } #undef TKIND return cxstring::createRef(s); @@ -498,12 +514,13 @@ CXCallingConv clang_getFunctionTypeCallingConv(CXType X) { if (const FunctionType *FD = T->getAs<FunctionType>()) { #define TCALLINGCONV(X) case CC_##X: return CXCallingConv_##X switch (FD->getCallConv()) { - TCALLINGCONV(Default); TCALLINGCONV(C); TCALLINGCONV(X86StdCall); TCALLINGCONV(X86FastCall); TCALLINGCONV(X86ThisCall); TCALLINGCONV(X86Pascal); + TCALLINGCONV(X86_64Win64); + TCALLINGCONV(X86_64SysV); TCALLINGCONV(AAPCS); TCALLINGCONV(AAPCS_VFP); TCALLINGCONV(PnaclCall); @@ -590,6 +607,15 @@ CXType clang_getElementType(CXType CT) { case Type::ConstantArray: ET = cast<ConstantArrayType> (TP)->getElementType(); break; + case Type::IncompleteArray: + ET = cast<IncompleteArrayType> (TP)->getElementType(); + break; + case Type::VariableArray: + ET = cast<VariableArrayType> (TP)->getElementType(); + break; + case Type::DependentSizedArray: + ET = cast<DependentSizedArrayType> (TP)->getElementType(); + break; case Type::Vector: ET = cast<VectorType> (TP)->getElementType(); break; @@ -633,6 +659,15 @@ CXType clang_getArrayElementType(CXType CT) { case Type::ConstantArray: ET = cast<ConstantArrayType> (TP)->getElementType(); break; + case Type::IncompleteArray: + ET = cast<IncompleteArrayType> (TP)->getElementType(); + break; + case Type::VariableArray: + ET = cast<VariableArrayType> (TP)->getElementType(); + break; + case Type::DependentSizedArray: + ET = cast<DependentSizedArrayType> (TP)->getElementType(); + break; default: break; } @@ -677,6 +712,17 @@ long long clang_Type_getAlignOf(CXType T) { return Ctx.getTypeAlignInChars(QT).getQuantity(); } +CXType clang_Type_getClassType(CXType CT) { + QualType ET = QualType(); + QualType T = GetQualType(CT); + const Type *TP = T.getTypePtrOrNull(); + + if (TP && TP->getTypeClass() == Type::MemberPointer) { + ET = QualType(cast<MemberPointerType> (TP)->getClass(), 0); + } + return MakeCXType(ET, GetTU(CT)); +} + long long clang_Type_getSizeOf(CXType T) { if (T.kind == CXType_Invalid) return CXTypeLayoutError_Invalid; @@ -733,11 +779,13 @@ long long clang_Type_getOffsetOf(CXType PT, const char *S) { return CXTypeLayoutError_Invalid; const RecordDecl *RD = dyn_cast_or_null<RecordDecl>(cxcursor::getCursorDecl(PC)); - if (!RD) + if (!RD || RD->isInvalidDecl()) return CXTypeLayoutError_Invalid; RD = RD->getDefinition(); if (!RD) return CXTypeLayoutError_Incomplete; + if (RD->isInvalidDecl()) + return CXTypeLayoutError_Invalid; QualType RT = GetQualType(PT); if (RT->isIncompleteType()) return CXTypeLayoutError_Incomplete; @@ -768,6 +816,24 @@ long long clang_Type_getOffsetOf(CXType PT, const char *S) { return CXTypeLayoutError_InvalidFieldName; } +enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T) { + QualType QT = GetQualType(T); + if (QT.isNull()) + return CXRefQualifier_None; + const FunctionProtoType *FD = QT->getAs<FunctionProtoType>(); + if (!FD) + return CXRefQualifier_None; + switch (FD->getRefQualifier()) { + case RQ_None: + return CXRefQualifier_None; + case RQ_LValue: + return CXRefQualifier_LValue; + case RQ_RValue: + return CXRefQualifier_RValue; + } + return CXRefQualifier_None; +} + unsigned clang_Cursor_isBitField(CXCursor C) { if (!clang_isDeclaration(C.kind)) return 0; |