Remove ObjCQualifiedInterfaceType:-)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76321 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 046b27c..c378b8a 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -600,7 +600,6 @@
     // alignment requirements: getPointerInfo should take an AddrSpace.
     return getTypeInfo(QualType(cast<ExtQualType>(T)->getBaseType(), 0));
   case Type::ObjCObjectPointer:
-  case Type::ObjCQualifiedInterface:
     Width = Target.getPointerWidth(0);
     Align = Target.getPointerAlign(0);
     break;
@@ -1703,17 +1702,6 @@
   return QualType(Decl->TypeForDecl, 0);
 }
 
-/// getObjCInterfaceType - Return the unique reference to the type for the
-/// specified ObjC interface decl.
-QualType ASTContext::getObjCInterfaceType(const ObjCInterfaceDecl *Decl) {
-  if (Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0);
-  
-  ObjCInterfaceDecl *OID = const_cast<ObjCInterfaceDecl*>(Decl);
-  Decl->TypeForDecl = new(*this,8) ObjCInterfaceType(Type::ObjCInterface, OID);
-  Types.push_back(Decl->TypeForDecl);
-  return QualType(Decl->TypeForDecl, 0);
-}
-
 /// \brief Retrieve the template type parameter type for a template
 /// parameter or parameter pack with the given depth, index, and (optionally) 
 /// name.
@@ -1896,27 +1884,28 @@
   return QualType(QType, 0);
 }
 
-/// getObjCQualifiedInterfaceType - Return a ObjCQualifiedInterfaceType type for
-/// the given interface decl and the conforming protocol list.
-QualType ASTContext::getObjCQualifiedInterfaceType(ObjCInterfaceDecl *Decl,
+/// getObjCInterfaceType - Return the unique reference to the type for the
+/// specified ObjC interface decl. The list of protocols is optional.
+QualType ASTContext::getObjCInterfaceType(const ObjCInterfaceDecl *Decl,
                        ObjCProtocolDecl **Protocols, unsigned NumProtocols) {
-  // Sort the protocol list alphabetically to canonicalize it.
-  SortAndUniqueProtocols(Protocols, NumProtocols);
+  if (NumProtocols) 
+    // Sort the protocol list alphabetically to canonicalize it.
+    SortAndUniqueProtocols(Protocols, NumProtocols);
   
   llvm::FoldingSetNodeID ID;
-  ObjCQualifiedInterfaceType::Profile(ID, Decl, Protocols, NumProtocols);
+  ObjCInterfaceType::Profile(ID, Decl, Protocols, NumProtocols);
   
   void *InsertPos = 0;
-  if (ObjCQualifiedInterfaceType *QT =
-      ObjCQualifiedInterfaceTypes.FindNodeOrInsertPos(ID, InsertPos))
+  if (ObjCInterfaceType *QT =
+      ObjCInterfaceTypes.FindNodeOrInsertPos(ID, InsertPos))
     return QualType(QT, 0);
   
   // No Match;
-  ObjCQualifiedInterfaceType *QType =
-    new (*this,8) ObjCQualifiedInterfaceType(Decl, Protocols, NumProtocols);
-
+  ObjCInterfaceType *QType =
+    new (*this,8) ObjCInterfaceType(const_cast<ObjCInterfaceDecl*>(Decl), 
+                                    Protocols, NumProtocols);
   Types.push_back(QType);
-  ObjCQualifiedInterfaceTypes.InsertNode(QType, InsertPos);
+  ObjCInterfaceTypes.InsertNode(QType, InsertPos);
   return QualType(QType, 0);
 }
 
@@ -3193,30 +3182,23 @@
   
   // RHS must have a superset of the protocols in the LHS.  If the LHS is not
   // protocol qualified at all, then we are good.
-  if (!isa<ObjCQualifiedInterfaceType>(LHS))
+  if (LHS->getNumProtocols() == 0)
     return true;
   
   // Okay, we know the LHS has protocol qualifiers.  If the RHS doesn't, then it
   // isn't a superset.
-  if (!isa<ObjCQualifiedInterfaceType>(RHS))
+  if (RHS->getNumProtocols() == 0)
     return true;  // FIXME: should return false!
   
-  // Finally, we must have two protocol-qualified interfaces.
-  const ObjCQualifiedInterfaceType *LHSP =cast<ObjCQualifiedInterfaceType>(LHS);
-  const ObjCQualifiedInterfaceType *RHSP =cast<ObjCQualifiedInterfaceType>(RHS);
-  
-  // All LHS protocols must have a presence on the RHS.  
-  assert(LHSP->qual_begin() != LHSP->qual_end() && "Empty LHS protocol list?");
-  
-  for (ObjCQualifiedInterfaceType::qual_iterator LHSPI = LHSP->qual_begin(),
-                                                 LHSPE = LHSP->qual_end();
+  for (ObjCInterfaceType::qual_iterator LHSPI = LHS->qual_begin(),
+                                        LHSPE = LHS->qual_end();
        LHSPI != LHSPE; LHSPI++) {
     bool RHSImplementsProtocol = false;
 
     // If the RHS doesn't implement the protocol on the left, the types
     // are incompatible.
-    for (ObjCQualifiedInterfaceType::qual_iterator RHSPI = RHSP->qual_begin(),
-                                                   RHSPE = RHSP->qual_end();
+    for (ObjCInterfaceType::qual_iterator RHSPI = RHS->qual_begin(),
+                                                  RHSPE = RHS->qual_end();
          RHSPI != RHSPE; RHSPI++) {
       if ((*RHSPI)->lookupProtocolNamed((*LHSPI)->getIdentifier())) {
         RHSImplementsProtocol = true;
@@ -3434,11 +3416,6 @@
   if (LHSClass == Type::ExtVector) LHSClass = Type::Vector;
   if (RHSClass == Type::ExtVector) RHSClass = Type::Vector;
   
-  // Consider qualified interfaces and interfaces the same.
-  // FIXME: Remove (ObjCObjectPointerType should obsolete this funny business).
-  if (LHSClass == Type::ObjCQualifiedInterface) LHSClass = Type::ObjCInterface;
-  if (RHSClass == Type::ObjCQualifiedInterface) RHSClass = Type::ObjCInterface;
-
   // If the canonical type classes don't match.
   if (LHSClass != RHSClass) {
     // C99 6.7.2.2p4: Each enumerated type shall be compatible with char,
@@ -3475,7 +3452,6 @@
   case Type::VariableArray:
   case Type::FunctionProto:
   case Type::ExtVector:
-  case Type::ObjCQualifiedInterface:
     assert(false && "Types are eliminated above");
     return QualType();
 
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index 2f66454..64a090d 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -475,19 +475,26 @@
   return dyn_cast<ObjCInterfaceType>(CanonicalType.getUnqualifiedType());
 }
 
+const ObjCInterfaceType *Type::getAsObjCQualifiedInterfaceType() const {
+  // There is no sugar for ObjCInterfaceType's, just return the canonical
+  // type pointer if it is the right class.  There is no typedef information to
+  // return and these cannot be Address-space qualified.
+  if (const ObjCInterfaceType *OIT = getAsObjCInterfaceType())
+    if (OIT->getNumProtocols())
+      return OIT;
+  return 0;
+}
+
+bool Type::isObjCQualifiedInterfaceType() const {
+  return getAsObjCQualifiedIdType() != 0;
+}
+
 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
-  // canonical type pointer if it is the right class.
-  return dyn_cast<ObjCQualifiedInterfaceType>(CanonicalType.getUnqualifiedType());
-}
-
 const ObjCObjectPointerType *Type::getAsObjCQualifiedIdType() const {
   // There is no sugar for ObjCQualifiedIdType's, just return the canonical
   // type pointer if it is the right class.
@@ -766,7 +773,6 @@
     // An array of unknown size is an incomplete type (C99 6.2.5p22).
     return true;
   case ObjCInterface:
-  case ObjCQualifiedInterface:
     // ObjC interfaces are incomplete if they are @class, not @interface.
     return cast<ObjCInterfaceType>(this)->getDecl()->isForwardDecl();
   }
@@ -849,7 +855,6 @@
   case QualifiedName:
   case Typename:
   case ObjCInterface:
-  case ObjCQualifiedInterface:
   case ObjCObjectPointer:
     return true;
   default:
@@ -931,19 +936,6 @@
     Profile(ID, getPointeeType(), 0, 0);
 }
 
-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 ObjCQualifiedInterfaceType::Profile(llvm::FoldingSetNodeID &ID) {
-  Profile(ID, getDecl(), &Protocols[0], getNumProtocols());
-}
-
 /// LookThroughTypedefs - Return the ultimate type this typedef corresponds to
 /// potentially looking through *all* consequtive typedefs.  This returns the
 /// sum of the type qualifiers, so if you have:
@@ -1566,10 +1558,41 @@
     InnerString = MyString + ' ' + InnerString;
 }
 
-void ObjCInterfaceType::getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const {
+void ObjCInterfaceType::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 ObjCInterfaceType::Profile(llvm::FoldingSetNodeID &ID) {
+  if (getNumProtocols())
+    Profile(ID, getDecl(), &Protocols[0], getNumProtocols());
+  else
+    Profile(ID, getDecl(), 0, 0);
+}
+
+void ObjCInterfaceType::getAsStringInternal(std::string &InnerString,
+                                           const PrintingPolicy &Policy) const {
   if (!InnerString.empty())    // Prefix the basic type, e.g. 'typedefname X'.
     InnerString = ' ' + InnerString;
-  InnerString = getDecl()->getIdentifier()->getName() + InnerString;
+    
+  std::string ObjCQIString = getDecl()->getNameAsString();
+  if (getNumProtocols()) {
+    ObjCQIString += '<';
+    bool isFirst = true;
+    for (qual_iterator I = qual_begin(), E = qual_end(); I != E; ++I) {
+      if (isFirst)
+        isFirst = false;
+      else
+        ObjCQIString += ',';
+      ObjCQIString += (*I)->getNameAsString();
+    }
+    ObjCQIString += '>';
+  }
+  InnerString = ObjCQIString + InnerString;
 }
 
 void ObjCObjectPointerType::getAsStringInternal(std::string &InnerString, 
@@ -1600,25 +1623,6 @@
   InnerString = ObjCQIString + InnerString;
 }
 
-void 
-ObjCQualifiedInterfaceType::getAsStringInternal(std::string &InnerString,
-                                           const PrintingPolicy &Policy) const {
-  if (!InnerString.empty())    // Prefix the basic type, e.g. 'typedefname X'.
-    InnerString = ' ' + InnerString;
-  std::string ObjCQIString = getDecl()->getNameAsString();
-  ObjCQIString += '<';
-  bool isFirst = true;
-  for (qual_iterator I = qual_begin(), E = qual_end(); I != E; ++I) {
-    if (isFirst)
-      isFirst = false;
-    else
-      ObjCQIString += ',';
-    ObjCQIString += (*I)->getNameAsString();
-  }
-  ObjCQIString += '>';
-  InnerString = ObjCQIString + InnerString;
-}
-
 void TagType::getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const {
   if (Policy.SuppressTag)
     return;
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index a5e4b2f..f55998a 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -779,7 +779,6 @@
     return llvm::DIType();
   case Type::ObjCObjectPointer:
     return Slot = CreateType(cast<ObjCObjectPointerType>(Ty), Unit);
-  case Type::ObjCQualifiedInterface:  // Drop protocols from interface.
   case Type::ObjCInterface: 
     return Slot = CreateType(cast<ObjCInterfaceType>(Ty), Unit);
   case Type::Builtin: return Slot = CreateType(cast<BuiltinType>(Ty), Unit);
diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp
index e97cbbd..a391940 100644
--- a/lib/CodeGen/CodeGenTypes.cpp
+++ b/lib/CodeGen/CodeGenTypes.cpp
@@ -341,12 +341,6 @@
     return
       ConvertTypeRecursive(QualType(cast<ExtQualType>(Ty).getBaseType(), 0));
 
-  case Type::ObjCQualifiedInterface: {
-    // Lower foo<P1,P2> just like foo.
-    ObjCInterfaceDecl *ID = cast<ObjCQualifiedInterfaceType>(Ty).getDecl();
-    return ConvertTypeRecursive(Context.getObjCInterfaceType(ID));
-  }
-      
   case Type::ObjCInterface: {
     // Objective-C interfaces are always opaque (outside of the
     // runtime, which can do whatever it likes); we never refine
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp
index 1c3d187..d3c7465 100644
--- a/lib/Frontend/PCHReader.cpp
+++ b/lib/Frontend/PCHReader.cpp
@@ -1918,19 +1918,14 @@
     assert(Record.size() == 1 && "incorrect encoding of enum type");
     return Context->getTypeDeclType(cast<EnumDecl>(GetDecl(Record[0])));
 
-  case pch::TYPE_OBJC_INTERFACE:
-    assert(Record.size() == 1 && "incorrect encoding of objc interface type");
-    return Context->getObjCInterfaceType(
-                                  cast<ObjCInterfaceDecl>(GetDecl(Record[0])));
-
-  case pch::TYPE_OBJC_QUALIFIED_INTERFACE: {
+  case pch::TYPE_OBJC_INTERFACE: {
     unsigned Idx = 0;
     ObjCInterfaceDecl *ItfD = cast<ObjCInterfaceDecl>(GetDecl(Record[Idx++]));
     unsigned NumProtos = Record[Idx++];
     llvm::SmallVector<ObjCProtocolDecl*, 4> Protos;
     for (unsigned I = 0; I != NumProtos; ++I)
       Protos.push_back(cast<ObjCProtocolDecl>(GetDecl(Record[Idx++])));
-    return Context->getObjCQualifiedInterfaceType(ItfD, Protos.data(), NumProtos);
+    return Context->getObjCInterfaceType(ItfD, Protos.data(), NumProtos);
   }
 
   case pch::TYPE_OBJC_OBJECT_POINTER: {
@@ -1995,7 +1990,7 @@
   }
 
   Index -= pch::NUM_PREDEF_TYPE_IDS;
-  assert(Index < TypesLoaded.size() && "Type index out-of-range");
+  //assert(Index < TypesLoaded.size() && "Type index out-of-range");
   if (!TypesLoaded[Index])
     TypesLoaded[Index] = ReadTypeRecord(TypeOffsets[Index]).getTypePtr();
     
diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp
index 6a17f39..0a0202b 100644
--- a/lib/Frontend/PCHWriter.cpp
+++ b/lib/Frontend/PCHWriter.cpp
@@ -239,18 +239,11 @@
 
 void PCHTypeWriter::VisitObjCInterfaceType(const ObjCInterfaceType *T) {
   Writer.AddDeclRef(T->getDecl(), Record);
-  Code = pch::TYPE_OBJC_INTERFACE;
-}
-
-void 
-PCHTypeWriter::VisitObjCQualifiedInterfaceType(
-                                      const ObjCQualifiedInterfaceType *T) {
-  VisitObjCInterfaceType(T);
   Record.push_back(T->getNumProtocols());
   for (ObjCInterfaceType::qual_iterator I = T->qual_begin(),
        E = T->qual_end(); I != E; ++I)
     Writer.AddDeclRef(*I, Record);
-  Code = pch::TYPE_OBJC_QUALIFIED_INTERFACE;
+  Code = pch::TYPE_OBJC_INTERFACE;
 }
 
 void
@@ -433,7 +426,6 @@
   RECORD(TYPE_RECORD);
   RECORD(TYPE_ENUM);
   RECORD(TYPE_OBJC_INTERFACE);
-  RECORD(TYPE_OBJC_QUALIFIED_INTERFACE);
   RECORD(TYPE_OBJC_OBJECT_POINTER);
   // Statements and Exprs can occur in the Types block.
   AddStmtsExprs(Stream, Record);
@@ -1844,6 +1836,18 @@
   WriteSourceManagerBlock(Context.getSourceManager(), PP, isysroot);
   WritePreprocessor(PP);
   WriteComments(Context);  
+  // Write the record of special types.
+  Record.clear();
+  
+  AddTypeRef(Context.getBuiltinVaListType(), Record);
+  AddTypeRef(Context.getObjCIdType(), Record);
+  AddTypeRef(Context.getObjCSelType(), Record);
+  AddTypeRef(Context.getObjCProtoType(), Record);
+  AddTypeRef(Context.getObjCClassType(), Record);
+  AddTypeRef(Context.getRawCFConstantStringType(), Record);
+  AddTypeRef(Context.getRawObjCFastEnumerationStateType(), Record);
+  AddTypeRef(Context.getFILEType(), Record);
+  Stream.EmitRecord(pch::SPECIAL_TYPES, Record);
   
   // Keep writing types and declarations until all types and
   // declarations have been written.
@@ -1883,18 +1887,6 @@
                             (const char *)&DeclOffsets.front(), 
                             DeclOffsets.size() * sizeof(DeclOffsets[0]));
 
-  // Write the record of special types.
-  Record.clear();
-  AddTypeRef(Context.getBuiltinVaListType(), Record);
-  AddTypeRef(Context.getObjCIdType(), Record);
-  AddTypeRef(Context.getObjCSelType(), Record);
-  AddTypeRef(Context.getObjCProtoType(), Record);
-  AddTypeRef(Context.getObjCClassType(), Record);
-  AddTypeRef(Context.getRawCFConstantStringType(), Record);
-  AddTypeRef(Context.getRawObjCFastEnumerationStateType(), Record);
-  AddTypeRef(Context.getFILEType(), Record);
-  Stream.EmitRecord(pch::SPECIAL_TYPES, Record);
-
   // Write the record containing external, unnamed definitions.
   if (!ExternalDefinitions.empty())
     Stream.EmitRecord(pch::EXTERNAL_DEFINITIONS, ExternalDefinitions);
diff --git a/lib/Frontend/RewriteObjC.cpp b/lib/Frontend/RewriteObjC.cpp
index 1bc7451..fa1476a 100644
--- a/lib/Frontend/RewriteObjC.cpp
+++ b/lib/Frontend/RewriteObjC.cpp
@@ -1820,16 +1820,7 @@
 }
 
 bool RewriteObjC::needToScanForQualifiers(QualType T) {
-  
-  if (T->isObjCQualifiedIdType())
-    return true;
-  
-  if (const PointerType *pType = T->getAsPointerType()) {
-    Type *pointeeType = pType->getPointeeType().getTypePtr();
-    if (isa<ObjCQualifiedInterfaceType>(pointeeType))
-      return true; // we have "Class <Protocol> *".
-  }
-  return false;
+  return T->isObjCQualifiedIdType() || T->isObjCQualifiedInterfaceType();
 }
 
 void RewriteObjC::RewriteObjCQualifiedInterfaceTypes(Expr *E) {
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index 1131a9f..1d995b5 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -860,7 +860,7 @@
     return false;
   
   QualType ltype = lhs->getAsPointerType()->getPointeeType();
-  if (const ObjCQualifiedInterfaceType *lhsQI =
+  if (const ObjCInterfaceType *lhsQI =
          ltype->getAsObjCQualifiedInterfaceType()) {
     ObjCObjectPointerType::qual_iterator LHSProtoI = lhsQI->qual_begin();
     ObjCObjectPointerType::qual_iterator LHSProtoE = lhsQI->qual_end();
diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp
index 80e0da1..ac4e4b9 100644
--- a/lib/Sema/SemaTemplateDeduction.cpp
+++ b/lib/Sema/SemaTemplateDeduction.cpp
@@ -1537,7 +1537,6 @@
   case Type::Enum:
   case Type::Typename:
   case Type::ObjCInterface:
-  case Type::ObjCQualifiedInterface:
   case Type::ObjCObjectPointer:
 #define TYPE(Class, Base)
 #define ABSTRACT_TYPE(Class, Base)
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index c50faad..998d6e5 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -735,14 +735,6 @@
   return QualType();
 }
 
-QualType 
-TemplateTypeInstantiator::
-InstantiateObjCQualifiedInterfaceType(
-                                 const ObjCQualifiedInterfaceType *T) const {
-  assert(false && "Objective-C types cannot be dependent");
-  return QualType();
-}
-
 /// \brief The actual implementation of Sema::InstantiateType().
 QualType TemplateTypeInstantiator::Instantiate(QualType T) const {
   // If T is not a dependent type, there is nothing to do.
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 036ccc8..57989a0 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -208,11 +208,12 @@
       // FIXME: Adding a TST_objcInterface clause doesn't seem ideal, so we have
       // this "hack" for now...
       if (const ObjCInterfaceType *Interface = Result->getAsObjCInterfaceType())
-        // FIXME: Remove ObjCQualifiedInterfaceType (by moving the list of
-        // protocols 'up' to ObjCInterfaceType).
-        Result = Context.getObjCQualifiedInterfaceType(Interface->getDecl(),
-                                                       (ObjCProtocolDecl**)PQ,
-                                               DS.getNumProtocolQualifiers());
+        // 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.
+        Result = Context.getObjCInterfaceType(Interface->getDecl(),
+                                              (ObjCProtocolDecl**)PQ,
+                                              DS.getNumProtocolQualifiers());
       else if (Result->isObjCIdType())
         // id<protocol-list>
         Result = Context.getObjCObjectPointerType(QualType(), 
@@ -900,10 +901,10 @@
         // Build the type anyway.
       }
       if (getLangOptions().ObjC1 && T->isObjCInterfaceType()) {
-        const ObjCInterfaceType *OIT = T->getAsObjCInterfaceType();
+        const DeclSpec &DS = D.getDeclSpec();
         T = Context.getObjCObjectPointerType(T,
-                                       (ObjCProtocolDecl **)OIT->qual_begin(),
-                                       OIT->getNumProtocols());
+                                (ObjCProtocolDecl **)DS.getProtocolQualifiers(),
+                                DS.getNumProtocolQualifiers());
         break;
       }
       T = BuildPointerType(T, DeclType.Ptr.TypeQuals, DeclType.Loc, Name);