return T->getAsStructureType() == SelStructType;
}
+ //===--------------------------------------------------------------------===//
+ // Serialization
+ //===--------------------------------------------------------------------===//
+
+ void Emit(llvm::Serializer& S) const;
+ static ASTContext* Create(llvm::Deserializer& D);
+
private:
ASTContext(const ASTContext&); // DO NOT IMPLEMENT
void operator=(const ASTContext&); // DO NOT IMPLEMENT
void InitBuiltinTypes();
void InitBuiltinType(QualType &R, BuiltinType::Kind K);
-
+
/// helper function for Objective-C specific type checking.
bool interfaceTypesAreCompatible(QualType, QualType);
-
- //===--------------------------------------------------------------------===//
- // Serialization
- //===--------------------------------------------------------------------===//
-
-public:
- void Emit(llvm::Serializer& S) const;
- static ASTContext* Create(llvm::Deserializer& D);
};
} // end namespace clang
class FunctionType;
class OCUVectorType;
class BuiltinType;
+ class ObjCInterfaceType;
+ class ObjCQualifiedIdType;
class ObjCQualifiedInterfaceType;
class StmtIteratorBase;
void dump(const char *s = 0) const;
+//private:
/// getCanonicalType - Return the canonical version of this type, with the
/// appropriate type qualifiers on it.
inline QualType getCanonicalType() const;
+public:
/// getAddressSpace - Return the address space of this type.
inline unsigned getAddressSpace() const;
bool isRecordType() const;
bool isStructureType() const;
bool isUnionType() const;
- bool isComplexIntegerType() const; // GCC complex int type.
- bool isVectorType() const; // GCC vector type.
- bool isOCUVectorType() const; // OCU vector type.
- bool isObjCInterfaceType() const; // includes conforming protocol type
- bool isObjCQualifiedIdType() const; // id includes conforming protocol type
+ bool isComplexIntegerType() const; // GCC _Complex integer type.
+ bool isVectorType() const; // GCC vector type.
+ bool isOCUVectorType() const; // OCU vector type.
+ bool isObjCInterfaceType() const; // NSString or NSString<foo>
+ bool isObjCQualifiedInterfaceType() const; // NSString<foo>
+ bool isObjCQualifiedIdType() const; // id<foo>
// Type Checking Functions: Check to see if this type is structurally the
// specified type, ignoring typedefs and qualifiers, and return a pointer to
const ComplexType *getAsComplexType() const;
const ComplexType *getAsComplexIntegerType() const; // GCC complex int type.
const OCUVectorType *getAsOCUVectorType() const; // OCU vector type.
+ const ObjCInterfaceType *getAsObjCInterfaceType() const;
+ const ObjCQualifiedInterfaceType *getAsObjCQualifiedInterfaceType() const;
+ const ObjCQualifiedIdType *getAsObjCQualifiedIdType() const;
+
/// getDesugaredType - Return the specified type with any "sugar" removed from
/// type type. This takes off typedefs, typeof's etc. If the outer level of
virtual void getAsStringInternal(std::string &InnerString) const;
static bool classof(const Type *T) {
- return T->getTypeClass() == ObjCInterface;
+ return T->getTypeClass() == ObjCInterface ||
+ T->getTypeClass() == ObjCQualifiedInterface;
}
static bool classof(const ObjCInterfaceType *) { return true; }
};
return isa<OCUVectorType>(CanonicalType.getUnqualifiedType());
}
inline bool Type::isObjCInterfaceType() const {
- return isa<ObjCInterfaceType>(CanonicalType)
- || isa<ObjCQualifiedInterfaceType>(CanonicalType);
+ return isa<ObjCInterfaceType>(CanonicalType);
+}
+inline bool Type::isObjCQualifiedInterfaceType() const {
+ return isa<ObjCQualifiedInterfaceType>(CanonicalType);
}
inline bool Type::isObjCQualifiedIdType() const {
return isa<ObjCQualifiedIdType>(CanonicalType);
return true;
else if (isObjCIdType(lhs) && rhs->isObjCInterfaceType())
return true;
- if (ObjCInterfaceType *lhsIT =
- dyn_cast<ObjCInterfaceType>(lhs.getCanonicalType().getTypePtr())) {
- ObjCQualifiedInterfaceType *rhsQI =
- dyn_cast<ObjCQualifiedInterfaceType>(rhs.getCanonicalType().getTypePtr());
- return rhsQI && (lhsIT->getDecl() == rhsQI->getDecl());
+
+ if (const ObjCInterfaceType *lhsIT = lhs->getAsObjCInterfaceType()) {
+ const ObjCQualifiedInterfaceType *rhsQI =
+ rhs->getAsObjCQualifiedInterfaceType();
+ if (!isa<ObjCQualifiedInterfaceType>(lhsIT))
+ return rhsQI && (lhsIT->getDecl() == rhsQI->getDecl());
}
- else if (ObjCInterfaceType *rhsIT =
- dyn_cast<ObjCInterfaceType>(rhs.getCanonicalType().getTypePtr())) {
- ObjCQualifiedInterfaceType *lhsQI =
- dyn_cast<ObjCQualifiedInterfaceType>(lhs.getCanonicalType().getTypePtr());
- return lhsQI && (rhsIT->getDecl() == lhsQI->getDecl());
+ if (const ObjCInterfaceType *rhsIT = rhs->getAsObjCInterfaceType()) {
+ const ObjCQualifiedInterfaceType *lhsQI =
+ lhs->getAsObjCQualifiedInterfaceType();
+ if (!isa<ObjCQualifiedInterfaceType>(rhsIT))
+ return lhsQI && (rhsIT->getDecl() == lhsQI->getDecl());
}
return false;
}
return getDesugaredType()->getAsOCUVectorType();
}
+const ObjCInterfaceType *Type::getAsObjCInterfaceType() const {
+ // Are we directly an ObjCInterface type?
+ if (const ObjCInterfaceType *VTy = dyn_cast<ObjCInterfaceType>(this))
+ return VTy;
+
+ // If the canonical form of this type isn't the right kind, reject it.
+ if (!isa<ObjCInterfaceType>(CanonicalType)) {
+ // Look through type qualifiers
+ if (isa<ObjCInterfaceType>(CanonicalType.getUnqualifiedType()))
+ return CanonicalType.getUnqualifiedType()->getAsObjCInterfaceType();
+ return 0;
+ }
+
+ // If this is a typedef for an objc interface type, strip the typedef off
+ // without losing all typedef information.
+ return getDesugaredType()->getAsObjCInterfaceType();
+}
+
+const ObjCQualifiedInterfaceType *
+Type::getAsObjCQualifiedInterfaceType() const {
+ // Are we directly an ObjCQualifiedInterfaceType?
+ if (const ObjCQualifiedInterfaceType *VTy =
+ dyn_cast<ObjCQualifiedInterfaceType>(this))
+ return VTy;
+
+ // If the canonical form of this type isn't the right kind, reject it.
+ if (!isa<ObjCQualifiedInterfaceType>(CanonicalType)) {
+ // Look through type qualifiers
+ if (isa<ObjCQualifiedInterfaceType>(CanonicalType.getUnqualifiedType()))
+ return CanonicalType.getUnqualifiedType()->
+ getAsObjCQualifiedInterfaceType();
+ return 0;
+ }
+
+ // If this is a typedef for an objc qual interface type, strip the typedef off
+ // without losing all typedef information.
+ return getDesugaredType()->getAsObjCQualifiedInterfaceType();
+}
+
+
bool Type::isIntegerType() const {
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
return BT->getKind() >= BuiltinType::Bool &&