Substantially alter the design of the Objective C type AST by introducing
ObjCObjectType, which is basically just a pair of
one of {primitive-id, primitive-Class, user-defined @class}
with
a list of protocols.
An ObjCObjectPointerType is therefore just a pointer which always points to
one of these types (possibly sugared). ObjCInterfaceType is now just a kind
of ObjCObjectType which happens to not carry any protocols.
Alter a rather large number of use sites to use ObjCObjectType instead of
ObjCInterfaceType. Store an ObjCInterfaceType as a pointer on the decl rather
than hashing them in a FoldingSet. Remove some number of methods that are no
longer used, at least after this patch.
By simplifying ObjCObjectPointerType, we are now able to easily remove and apply
pointers to Objective-C types, which is crucial for a certain kind of ObjC++
metaprogramming common in WebKit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103870 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index 3515261..7f756ec 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -2445,31 +2445,15 @@
return QualType();
QualType Result = TL.getType();
- if (PointeeType->isObjCInterfaceType() ||
- PointeeType->isSpecificBuiltinType(BuiltinType::ObjCId)) {
+ if (PointeeType->getAs<ObjCObjectType>()) {
// A dependent pointer type 'T *' has is being transformed such
// that an Objective-C class type is being replaced for 'T'. The
// resulting pointer type is an ObjCObjectPointerType, not a
// PointerType.
- ObjCProtocolDecl **Protocols = 0;
- unsigned NumProtocols = 0;
-
- if (const ObjCInterfaceType *IFace
- = PointeeType->getAs<ObjCInterfaceType>()) {
- Protocols = const_cast<ObjCProtocolDecl**>(IFace->qual_begin());
- NumProtocols = IFace->getNumProtocols();
- }
-
- Result = SemaRef.Context.getObjCObjectPointerType(PointeeType,
- Protocols,
- NumProtocols);
+ Result = SemaRef.Context.getObjCObjectPointerType(PointeeType);
- ObjCObjectPointerTypeLoc NewT = TLB.push<ObjCObjectPointerTypeLoc>(Result);
- NewT.setStarLoc(TL.getSigilLoc());
- NewT.setHasProtocolsAsWritten(false);
- NewT.setLAngleLoc(SourceLocation());
- NewT.setRAngleLoc(SourceLocation());
- NewT.setHasBaseTypeAsWritten(true);
+ ObjCObjectPointerTypeLoc NewT = TLB.push<ObjCObjectPointerTypeLoc>(Result);
+ NewT.setStarLoc(TL.getStarLoc());
return Result;
}
@@ -3327,6 +3311,17 @@
ObjCInterfaceTypeLoc TL,
QualType ObjectType) {
// ObjCInterfaceType is never dependent.
+ TLB.pushFullCopy(TL);
+ return TL.getType();
+}
+
+template<typename Derived>
+QualType
+TreeTransform<Derived>::TransformObjCObjectType(TypeLocBuilder &TLB,
+ ObjCObjectTypeLoc TL,
+ QualType ObjectType) {
+ // ObjCObjectType is never dependent.
+ TLB.pushFullCopy(TL);
return TL.getType();
}
@@ -3336,6 +3331,7 @@
ObjCObjectPointerTypeLoc TL,
QualType ObjectType) {
// ObjCObjectPointerType is never dependent.
+ TLB.pushFullCopy(TL);
return TL.getType();
}