diff options
Diffstat (limited to 'lib/AST/Type.cpp')
-rw-r--r-- | lib/AST/Type.cpp | 107 |
1 files changed, 78 insertions, 29 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index e304f54..7b45b21 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -50,6 +50,13 @@ void DependentSizedArrayType::Destroy(ASTContext& C) { C.Deallocate(this); } +void DependentSizedExtVectorType::Destroy(ASTContext& C) { + if (SizeExpr) + SizeExpr->Destroy(C); + this->~DependentSizedExtVectorType(); + C.Deallocate(this); +} + /// getArrayElementTypeNoTypeQual - If this is an array type, return the /// element type of the array, potentially with type qualifiers missing. /// This method should never be used when type qualifiers are meaningful. @@ -555,6 +562,12 @@ const ObjCInterfaceType *Type::getAsObjCInterfaceType() const { return dyn_cast<ObjCInterfaceType>(CanonicalType.getUnqualifiedType()); } +const ObjCObjectPointerType *Type::getAsObjCObjectPointerType() const { + // There is no sugar for ObjCObjectPointerType's, just return the + // canonical type pointer if it is the right class. + return dyn_cast<ObjCObjectPointerType>(CanonicalType.getUnqualifiedType()); +} + const ObjCQualifiedInterfaceType * Type::getAsObjCQualifiedInterfaceType() const { // There is no sugar for ObjCQualifiedInterfaceType's, just return the @@ -562,10 +575,14 @@ Type::getAsObjCQualifiedInterfaceType() const { return dyn_cast<ObjCQualifiedInterfaceType>(CanonicalType.getUnqualifiedType()); } -const ObjCQualifiedIdType *Type::getAsObjCQualifiedIdType() const { +const ObjCObjectPointerType *Type::getAsObjCQualifiedIdType() const { // There is no sugar for ObjCQualifiedIdType's, just return the canonical // type pointer if it is the right class. - return dyn_cast<ObjCQualifiedIdType>(CanonicalType.getUnqualifiedType()); + if (const ObjCObjectPointerType *OPT = getAsObjCObjectPointerType()) { + if (OPT->isObjCQualifiedIdType()) + return OPT; + } + return 0; } const TemplateTypeParmType *Type::getAsTemplateTypeParmType() const { @@ -770,7 +787,7 @@ bool Type::isScalarType() const { isa<BlockPointerType>(CanonicalType) || isa<MemberPointerType>(CanonicalType) || isa<ComplexType>(CanonicalType) || - isa<ObjCQualifiedIdType>(CanonicalType); + isa<ObjCObjectPointerType>(CanonicalType); } /// \brief Determines whether the type is a C++ aggregate type or C @@ -857,7 +874,7 @@ bool Type::isPODType() const { case MemberPointer: case Vector: case ExtVector: - case ObjCQualifiedId: + case ObjCObjectPointer: return true; case Enum: @@ -912,7 +929,7 @@ bool Type::isSpecifierType() const { case Typename: case ObjCInterface: case ObjCQualifiedInterface: - case ObjCQualifiedId: + case ObjCObjectPointer: return true; default: return false; @@ -973,28 +990,30 @@ void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID) { getNumExceptions(), exception_begin()); } -void ObjCQualifiedInterfaceType::Profile(llvm::FoldingSetNodeID &ID, - const ObjCInterfaceDecl *Decl, - ObjCProtocolDecl **protocols, - unsigned NumProtocols) { +void ObjCObjectPointerType::Profile(llvm::FoldingSetNodeID &ID, + const ObjCInterfaceDecl *Decl, + ObjCProtocolDecl **protocols, + unsigned NumProtocols) { ID.AddPointer(Decl); for (unsigned i = 0; i != NumProtocols; i++) ID.AddPointer(protocols[i]); } -void ObjCQualifiedInterfaceType::Profile(llvm::FoldingSetNodeID &ID) { +void ObjCObjectPointerType::Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, getDecl(), &Protocols[0], getNumProtocols()); } -void ObjCQualifiedIdType::Profile(llvm::FoldingSetNodeID &ID, - ObjCProtocolDecl **protocols, - unsigned NumProtocols) { +void ObjCQualifiedInterfaceType::Profile(llvm::FoldingSetNodeID &ID, + const ObjCInterfaceDecl *Decl, + ObjCProtocolDecl **protocols, + unsigned NumProtocols) { + ID.AddPointer(Decl); for (unsigned i = 0; i != NumProtocols; i++) ID.AddPointer(protocols[i]); } -void ObjCQualifiedIdType::Profile(llvm::FoldingSetNodeID &ID) { - Profile(ID, &Protocols[0], getNumProtocols()); +void ObjCQualifiedInterfaceType::Profile(llvm::FoldingSetNodeID &ID) { + Profile(ID, getDecl(), &Protocols[0], getNumProtocols()); } /// LookThroughTypedefs - Return the ultimate type this typedef corresponds to @@ -1068,6 +1087,10 @@ anyDependentTemplateArguments(const TemplateArgument *Args, unsigned NumArgs) { Args[Idx].getAsExpr()->isValueDependent()) return true; break; + + case TemplateArgument::Pack: + assert(0 && "FIXME: Implement!"); + break; } } @@ -1352,6 +1375,19 @@ void DependentSizedArrayType::getAsStringInternal(std::string &S, const Printing getElementType().getAsStringInternal(S, Policy); } +void DependentSizedExtVectorType::getAsStringInternal(std::string &S, const PrintingPolicy &Policy) const { + getElementType().getAsStringInternal(S, Policy); + + S += " __attribute__((ext_vector_type("; + if (getSizeExpr()) { + std::string SStr; + llvm::raw_string_ostream s(SStr); + getSizeExpr()->printPretty(s, 0, Policy); + S += s.str(); + } + S += ")))"; +} + void VectorType::getAsStringInternal(std::string &S, const PrintingPolicy &Policy) const { // FIXME: We prefer to print the size directly here, but have no way // to get the size of the type. @@ -1476,6 +1512,9 @@ TemplateSpecializationType::PrintTemplateArgumentList( Args[Arg].getAsExpr()->printPretty(s, 0, Policy); break; } + case TemplateArgument::Pack: + assert(0 && "FIXME: Implement!"); + break; } // If this is the first argument and its string representation @@ -1566,6 +1605,30 @@ void ObjCInterfaceType::getAsStringInternal(std::string &InnerString, const Prin InnerString = getDecl()->getIdentifier()->getName() + InnerString; } +void ObjCObjectPointerType::getAsStringInternal(std::string &InnerString, + const PrintingPolicy &Policy) const { + if (!InnerString.empty()) // Prefix the basic type, e.g. 'typedefname X'. + InnerString = ' ' + InnerString; + + std::string ObjCQIString; + + if (getDecl()) + ObjCQIString = getDecl()->getNameAsString(); + else + ObjCQIString = "id"; + + if (!qual_empty()) { + ObjCQIString += '<'; + for (qual_iterator I = qual_begin(), E = qual_end(); I != E; ++I) { + ObjCQIString += (*I)->getNameAsString(); + if (I+1 != E) + ObjCQIString += ','; + } + ObjCQIString += '>'; + } + InnerString = ObjCQIString + InnerString; +} + void ObjCQualifiedInterfaceType::getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const { @@ -1585,20 +1648,6 @@ ObjCQualifiedInterfaceType::getAsStringInternal(std::string &InnerString, InnerString = ObjCQIString + InnerString; } -void ObjCQualifiedIdType::getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const { - if (!InnerString.empty()) // Prefix the basic type, e.g. 'typedefname X'. - InnerString = ' ' + InnerString; - std::string ObjCQIString = "id"; - ObjCQIString += '<'; - for (qual_iterator I = qual_begin(), E = qual_end(); I != E; ++I) { - ObjCQIString += (*I)->getNameAsString(); - if (I+1 != E) - ObjCQIString += ','; - } - ObjCQIString += '>'; - InnerString = ObjCQIString + InnerString; -} - void TagType::getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const { if (Policy.SuppressTag) return; |