When building types from declarators, instead of building two types (one for
the DeclaratorInfo, one for semantic analysis), just build a single type whose
canonical type will reflect the semantic analysis (assuming the type is
well-formed, of course).

To make that work, make a few changes to the type system:
* allow the nominal pointee type of a reference type to be a (possibly sugared)
  reference type.  Also, preserve the original spelling of the reference type.
  Both of these can be ignored on canonical reference types.
* Remove ObjCProtocolListType and preserve the associated source information on
  the various ObjC TypeLocs.  Preserve the spelling of protocol lists except in
  the canonical form.
* Preserve some level of source type structure on parameter types, but
  canonicalize on the canonical function type.  This is still a WIP.

Drops code size, makes strides towards accurate source location representation,
slight (~1.7%) progression on Cocoa.h because of complexity drop.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84907 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index 5f06ce5..38273dc 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -514,14 +514,6 @@
                                   SourceRange(getDerived().getBaseLocation()));
   }
 
-  /// \brief Rebuild an objective C protocol list type.
-  QualType RebuildObjCProtocolListType(QualType BaseType,
-                                       ObjCProtocolDecl **Protocols,
-                                       unsigned NumProtocols) {
-    return SemaRef.Context.getObjCProtocolListType(BaseType, Protocols,
-                                                   NumProtocols);
-  }
-
   /// \brief Build a new nested-name-specifier given the prefix and an
   /// identifier that names the next step in the nested-name-specifier.
   ///
@@ -2808,50 +2800,16 @@
 QualType
 TreeTransform<Derived>::TransformObjCInterfaceType(TypeLocBuilder &TLB,
                                                    ObjCInterfaceTypeLoc TL) {
-  return TransformTypeSpecType(TLB, TL);
+  assert(false && "TransformObjCInterfaceType unimplemented");
+  return QualType();
 }
 
 template<typename Derived>
 QualType
 TreeTransform<Derived>::TransformObjCObjectPointerType(TypeLocBuilder &TLB,
                                                ObjCObjectPointerTypeLoc TL) {
-  TransformPointerLikeType(ObjCObjectPointerType);
-}
-
-template<typename Derived>
-QualType TreeTransform<Derived>::TransformObjCProtocolListType(
-                                                TypeLocBuilder &TLB,
-                                                ObjCProtocolListTypeLoc TL) {
-  ObjCProtocolListType *T = TL.getTypePtr();
-  QualType BaseType = T->getBaseType();
-  if (!BaseType.isNull()) {
-    BaseType = getDerived().TransformType(TLB, TL.getBaseTypeLoc());
-    if (BaseType.isNull())
-      return QualType();
-  } 
-
-  QualType Result = TL.getType();
-  if (getDerived().AlwaysRebuild() ||
-      BaseType != T->getBaseType()) {
-    // TODO: transform these?
-    llvm::SmallVector<ObjCProtocolDecl*,4> Protocols(T->getNumProtocols());
-    std::copy(T->qual_begin(), T->qual_end(), Protocols.begin());
-    Result = getDerived().RebuildObjCProtocolListType(BaseType,
-                                                      &Protocols[0],
-                                                      T->getNumProtocols());
-    if (Result.isNull())
-      return QualType();
-  }
-
-  ObjCProtocolListTypeLoc NewTL = TLB.push<ObjCProtocolListTypeLoc>(Result);
-  NewTL.setLAngleLoc(TL.getLAngleLoc());
-  NewTL.setRAngleLoc(TL.getRAngleLoc());
-
-  assert(NewTL.getNumProtocols() == TL.getNumProtocols());
-  for (unsigned i = 0, e = TL.getNumProtocols(); i != e; ++i)
-    NewTL.setProtocolLoc(i, TL.getProtocolLoc(i));
-
-  return Result;
+  assert(false && "TransformObjCObjectPointerType unimplemented");
+  return QualType();
 }
 
 //===----------------------------------------------------------------------===//