5 cleanups to ObjCObjectPointerType work:
- Remove Sema::CheckPointeeTypesForAssignment(), a temporary API I added to ease migration to ObjCObjectPointerType. Convert Sema::CheckAssignmentConstraints() to no longer depend on the temporary API.
- Sema::ConvertDeclSpecToType(): Replace a couple FIXME's with an important comment/example.
- Sema::GetTypeForDeclarator(): Get the protocol's from the interface, NOT the declspec (to support the following C typedef idiom: "typedef C<P> T; T *obj").
- Sema::ObjCQualifiedIdTypesAreCompatible(): Removed some dead code.
- ASTContext::getObjCEncodingForTypeImpl(): Some minor cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76443 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 57989a0..5fbc8e8 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -205,12 +205,16 @@
Result = QualType::getFromOpaquePtr(DS.getTypeRep());
if (DeclSpec::ProtocolQualifierListTy PQ = DS.getProtocolQualifiers()) {
- // FIXME: Adding a TST_objcInterface clause doesn't seem ideal, so we have
- // this "hack" for now...
if (const ObjCInterfaceType *Interface = Result->getAsObjCInterfaceType())
- // FIXME: Investigate removing the protocol list in ObjCInterfaceType.
- // To simply this, Sema::GetTypeForDeclarator() uses the declspec
- // protocol list, not the list we are storing here.
+ // It would be nice if protocol qualifiers were only stored with the
+ // ObjCObjectPointerType. Unfortunately, this isn't possible due
+ // to the following typedef idiom (which is uncommon, but allowed):
+ //
+ // typedef Foo<P> T;
+ // static void func() {
+ // Foo<P> *yy;
+ // T *zz;
+ // }
Result = Context.getObjCInterfaceType(Interface->getDecl(),
(ObjCProtocolDecl**)PQ,
DS.getNumProtocolQualifiers());
@@ -901,10 +905,10 @@
// Build the type anyway.
}
if (getLangOptions().ObjC1 && T->isObjCInterfaceType()) {
- const DeclSpec &DS = D.getDeclSpec();
+ const ObjCInterfaceType *OIT = T->getAsObjCInterfaceType();
T = Context.getObjCObjectPointerType(T,
- (ObjCProtocolDecl **)DS.getProtocolQualifiers(),
- DS.getNumProtocolQualifiers());
+ (ObjCProtocolDecl **)OIT->qual_begin(),
+ OIT->getNumProtocols());
break;
}
T = BuildPointerType(T, DeclType.Ptr.TypeQuals, DeclType.Loc, Name);