Change all the Type::getAsFoo() methods to specializations of Type::getAs().
Several of the existing methods were identical to their respective
specializations, and so have been removed entirely.  Several more 'leaf'
optimizations were introduced.

The getAsFoo() methods which imposed extra conditions, like
getAsObjCInterfacePointerType(), have been left in place.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82501 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index f701ae4..a12ac20 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -487,7 +487,7 @@
 /// getFloatTypeSemantics - Return the APFloat 'semantics' for the specified
 /// scalar floating point type.
 const llvm::fltSemantics &ASTContext::getFloatTypeSemantics(QualType T) const {
-  const BuiltinType *BT = T->getAsBuiltinType();
+  const BuiltinType *BT = T->getAs<BuiltinType>();
   assert(BT && "Not a floating point type!");
   switch (BT->getKind()) {
   default: assert(0 && "Not a floating point type!");
@@ -782,7 +782,7 @@
   unsigned ABIAlign = getTypeAlign(T);
 
   // Double and long long should be naturally aligned if possible.
-  if (const ComplexType* CT = T->getAsComplexType())
+  if (const ComplexType* CT = T->getAs<ComplexType>())
     T = CT->getElementType().getTypePtr();
   if (T->isSpecificBuiltinType(BuiltinType::Double) ||
       T->isSpecificBuiltinType(BuiltinType::LongLong))
@@ -1120,10 +1120,10 @@
   if (!T->isFunctionType())
     assert(0 && "can't noreturn qualify non-pointer to function or block type");
 
-  if (const FunctionNoProtoType *F = T->getAsFunctionNoProtoType()) {
+  if (const FunctionNoProtoType *F = T->getAs<FunctionNoProtoType>()) {
     return getFunctionNoProtoType(F->getResultType(), true);
   }
-  const FunctionProtoType *F = T->getAsFunctionProtoType();
+  const FunctionProtoType *F = T->getAs<FunctionProtoType>();
   return getFunctionType(F->getResultType(), F->arg_type_begin(),
                          F->getNumArgs(), F->isVariadic(), F->getTypeQuals(),
                          F->hasExceptionSpec(), F->hasAnyExceptionSpec(),
@@ -1887,7 +1887,7 @@
     QualType CanonType = getCanonicalType(QualType(TemplateId, 0));
     if (CanonNNS != NNS || CanonType != QualType(TemplateId, 0)) {
       const TemplateSpecializationType *CanonTemplateId
-        = CanonType->getAsTemplateSpecializationType();
+        = CanonType->getAs<TemplateSpecializationType>();
       assert(CanonTemplateId &&
              "Canonical type must also be a template specialization type");
       Canon = getTypenameType(CanonNNS, CanonTemplateId);
@@ -2454,11 +2454,11 @@
 /// getFloatingRank - Return a relative rank for floating point types.
 /// This routine will assert if passed a built-in type that isn't a float.
 static FloatingRank getFloatingRank(QualType T) {
-  if (const ComplexType *CT = T->getAsComplexType())
+  if (const ComplexType *CT = T->getAs<ComplexType>())
     return getFloatingRank(CT->getElementType());
 
-  assert(T->getAsBuiltinType() && "getFloatingRank(): not a floating type");
-  switch (T->getAsBuiltinType()->getKind()) {
+  assert(T->getAs<BuiltinType>() && "getFloatingRank(): not a floating type");
+  switch (T->getAs<BuiltinType>()->getKind()) {
   default: assert(0 && "getFloatingRank(): not a floating type");
   case BuiltinType::Float:      return FloatRank;
   case BuiltinType::Double:     return DoubleRank;
@@ -2911,7 +2911,7 @@
 ///
 void ASTContext::getLegacyIntegralTypeEncoding (QualType &PointeeTy) const {
   if (isa<TypedefType>(PointeeTy.getTypePtr())) {
-    if (const BuiltinType *BT = PointeeTy->getAsBuiltinType()) {
+    if (const BuiltinType *BT = PointeeTy->getAs<BuiltinType>()) {
       if (BT->getKind() == BuiltinType::ULong &&
           ((const_cast<ASTContext *>(this))->getIntWidth(PointeeTy) == 32))
         PointeeTy = UnsignedIntTy;
@@ -2949,7 +2949,7 @@
                                             const FieldDecl *FD,
                                             bool OutermostType,
                                             bool EncodingProperty) {
-  if (const BuiltinType *BT = T->getAsBuiltinType()) {
+  if (const BuiltinType *BT = T->getAs<BuiltinType>()) {
     if (FD && FD->isBitField())
       return EncodeBitField(this, S, FD);
     char encoding;
@@ -2986,7 +2986,7 @@
     return;
   }
 
-  if (const ComplexType *CT = T->getAsComplexType()) {
+  if (const ComplexType *CT = T->getAs<ComplexType>()) {
     S += 'j';
     getObjCEncodingForTypeImpl(CT->getElementType(), S, false, false, 0, false,
                                false);
@@ -3085,7 +3085,7 @@
     return;
   }
 
-  if (T->getAsFunctionType()) {
+  if (T->getAs<FunctionType>()) {
     S += '?';
     return;
   }
@@ -3141,7 +3141,7 @@
 
   if (T->isObjCInterfaceType()) {
     // @encode(class_name)
-    ObjCInterfaceDecl *OI = T->getAsObjCInterfaceType()->getDecl();
+    ObjCInterfaceDecl *OI = T->getAs<ObjCInterfaceType>()->getDecl();
     S += '{';
     const IdentifierInfo *II = OI->getIdentifier();
     S += II->getName();
@@ -3160,7 +3160,7 @@
     return;
   }
 
-  if (const ObjCObjectPointerType *OPT = T->getAsObjCObjectPointerType()) {
+  if (const ObjCObjectPointerType *OPT = T->getAs<ObjCObjectPointerType>()) {
     if (OPT->isObjCIdType()) {
       S += '@';
       return;
@@ -3250,7 +3250,7 @@
 void ASTContext::setObjCSelType(QualType T) {
   ObjCSelType = T;
 
-  const TypedefType *TT = T->getAsTypedefType();
+  const TypedefType *TT = T->getAs<TypedefType>();
   if (!TT)
     return;
   TypedefDecl *TD = TT->getDecl();
@@ -3462,7 +3462,7 @@
     return true;
 
   if (const ObjCObjectPointerType *lhsQID = lhs->getAsObjCQualifiedIdType()) {
-    const ObjCObjectPointerType *rhsOPT = rhs->getAsObjCObjectPointerType();
+    const ObjCObjectPointerType *rhsOPT = rhs->getAs<ObjCObjectPointerType>();
 
     if (!rhsOPT) return false;
 
@@ -3635,8 +3635,8 @@
 
 bool ASTContext::areComparableObjCPointerTypes(QualType LHS, QualType RHS) {
   // get the "pointed to" types
-  const ObjCObjectPointerType *LHSOPT = LHS->getAsObjCObjectPointerType();
-  const ObjCObjectPointerType *RHSOPT = RHS->getAsObjCObjectPointerType();
+  const ObjCObjectPointerType *LHSOPT = LHS->getAs<ObjCObjectPointerType>();
+  const ObjCObjectPointerType *RHSOPT = RHS->getAs<ObjCObjectPointerType>();
 
   if (!LHSOPT || !RHSOPT)
     return false;
@@ -3654,8 +3654,8 @@
 }
 
 QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs) {
-  const FunctionType *lbase = lhs->getAsFunctionType();
-  const FunctionType *rbase = rhs->getAsFunctionType();
+  const FunctionType *lbase = lhs->getAs<FunctionType>();
+  const FunctionType *rbase = rhs->getAs<FunctionType>();
   const FunctionProtoType *lproto = dyn_cast<FunctionProtoType>(lbase);
   const FunctionProtoType *rproto = dyn_cast<FunctionProtoType>(rbase);
   bool allLTypes = true;
@@ -3847,11 +3847,11 @@
   if (LHSClass != RHSClass) {
     // C99 6.7.2.2p4: Each enumerated type shall be compatible with char,
     // a signed integer type, or an unsigned integer type.
-    if (const EnumType* ETy = LHS->getAsEnumType()) {
+    if (const EnumType* ETy = LHS->getAs<EnumType>()) {
       if (ETy->getDecl()->getIntegerType() == RHSCan.getUnqualifiedType())
         return RHS;
     }
-    if (const EnumType* ETy = RHS->getAsEnumType()) {
+    if (const EnumType* ETy = RHS->getAs<EnumType>()) {
       if (ETy->getDecl()->getIntegerType() == LHSCan.getUnqualifiedType())
         return LHS;
     }
@@ -3963,15 +3963,15 @@
     return QualType();
   case Type::Vector:
     // FIXME: The merged type should be an ExtVector!
-    if (areCompatVectorTypes(LHS->getAsVectorType(), RHS->getAsVectorType()))
+    if (areCompatVectorTypes(LHS->getAs<VectorType>(), RHS->getAs<VectorType>()))
       return LHS;
     return QualType();
   case Type::ObjCInterface: {
     // Check if the interfaces are assignment compatible.
     // FIXME: This should be type compatibility, e.g. whether
     // "LHS x; RHS x;" at global scope is legal.
-    const ObjCInterfaceType* LHSIface = LHS->getAsObjCInterfaceType();
-    const ObjCInterfaceType* RHSIface = RHS->getAsObjCInterfaceType();
+    const ObjCInterfaceType* LHSIface = LHS->getAs<ObjCInterfaceType>();
+    const ObjCInterfaceType* RHSIface = RHS->getAs<ObjCInterfaceType>();
     if (LHSIface && RHSIface &&
         canAssignObjCInterfaces(LHSIface, RHSIface))
       return LHS;
@@ -3979,8 +3979,8 @@
     return QualType();
   }
   case Type::ObjCObjectPointer: {
-    if (canAssignObjCInterfaces(LHS->getAsObjCObjectPointerType(),
-                                RHS->getAsObjCObjectPointerType()))
+    if (canAssignObjCInterfaces(LHS->getAs<ObjCObjectPointerType>(),
+                                RHS->getAs<ObjCObjectPointerType>()))
       return LHS;
 
     return QualType();
@@ -4040,9 +4040,9 @@
 
 QualType ASTContext::getCorrespondingUnsignedType(QualType T) {
   assert(T->isSignedIntegerType() && "Unexpected type");
-  if (const EnumType* ETy = T->getAsEnumType())
+  if (const EnumType* ETy = T->getAs<EnumType>())
     T = ETy->getDecl()->getIntegerType();
-  const BuiltinType* BTy = T->getAsBuiltinType();
+  const BuiltinType* BTy = T->getAs<BuiltinType>();
   assert (BTy && "Unexpected signed integer type");
   switch (BTy->getKind()) {
   case BuiltinType::Char_S:
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 77c085a..1a7aaac 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -542,7 +542,7 @@
 /// based on its FunctionType.  This is the length of the PararmInfo array
 /// after it has been created.
 unsigned FunctionDecl::getNumParams() const {
-  const FunctionType *FT = getType()->getAsFunctionType();
+  const FunctionType *FT = getType()->getAs<FunctionType>();
   if (isa<FunctionNoProtoType>(FT))
     return 0;
   return cast<FunctionProtoType>(FT)->getNumArgs();
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
index 53e2b84..f3ea043 100644
--- a/lib/AST/DeclCXX.cpp
+++ b/lib/AST/DeclCXX.cpp
@@ -194,7 +194,7 @@
       continue;
     // TODO: Skip templates? Or is this implicitly done due to parameter types?
     const FunctionProtoType *FnType =
-      Method->getType()->getAsFunctionProtoType();
+      Method->getType()->getAs<FunctionProtoType>();
     assert(FnType && "Overloaded operator has no prototype.");
     // Don't assert on this; an invalid decl might have been left in the AST.
     if (FnType->getNumArgs() != 1 || FnType->isVariadic())
@@ -256,7 +256,7 @@
 void CXXRecordDecl::addedAssignmentOperator(ASTContext &Context,
                                             CXXMethodDecl *OpDecl) {
   // We're interested specifically in copy assignment operators.
-  const FunctionProtoType *FnType = OpDecl->getType()->getAsFunctionProtoType();
+  const FunctionProtoType *FnType = OpDecl->getType()->getAs<FunctionProtoType>();
   assert(FnType && "Overloaded operator has no proto function type.");
   assert(FnType->getNumArgs() == 1 && !FnType->isVariadic());
   QualType ArgType = FnType->getArgType(0);
@@ -616,7 +616,7 @@
     return false;
 
   return (getNumParams() == 0 &&
-          getType()->getAsFunctionProtoType()->isVariadic()) ||
+          getType()->getAs<FunctionProtoType>()->isVariadic()) ||
          (getNumParams() == 1) ||
          (getNumParams() > 1 && getParamDecl(1)->hasDefaultArg());
 }
diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp
index 8aae742..f448144 100644
--- a/lib/AST/DeclPrinter.cpp
+++ b/lib/AST/DeclPrinter.cpp
@@ -97,9 +97,9 @@
       BaseType = PTy->getPointeeType();
     else if (const ArrayType* ATy = dyn_cast<ArrayType>(BaseType))
       BaseType = ATy->getElementType();
-    else if (const FunctionType* FTy = BaseType->getAsFunctionType())
+    else if (const FunctionType* FTy = BaseType->getAs<FunctionType>())
       BaseType = FTy->getResultType();
-    else if (const VectorType *VTy = BaseType->getAsVectorType())
+    else if (const VectorType *VTy = BaseType->getAs<VectorType>())
       BaseType = VTy->getElementType();
     else
       assert(0 && "Unknown declarator!");
@@ -332,7 +332,7 @@
   SubPolicy.SuppressSpecifiers = false;
   std::string Proto = D->getNameAsString();
   if (isa<FunctionType>(D->getType().getTypePtr())) {
-    const FunctionType *AFT = D->getType()->getAsFunctionType();
+    const FunctionType *AFT = D->getType()->getAs<FunctionType>();
 
     const FunctionProtoType *FT = 0;
     if (D->hasWrittenPrototype())
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 60458b4..6e46c4f 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -51,7 +51,7 @@
 
     std::string Proto = FD->getQualifiedNameAsString(Policy);
 
-    const FunctionType *AFT = FD->getType()->getAsFunctionType();
+    const FunctionType *AFT = FD->getType()->getAs<FunctionType>();
     const FunctionProtoType *FT = 0;
     if (FD->hasWrittenPrototype())
       FT = dyn_cast<FunctionProtoType>(AFT);
@@ -335,7 +335,7 @@
   else if (const BlockPointerType *BPT = CalleeType->getAs<BlockPointerType>())
     CalleeType = BPT->getPointeeType();
 
-  const FunctionType *FnType = CalleeType->getAsFunctionType();
+  const FunctionType *FnType = CalleeType->getAs<FunctionType>();
   return FnType->getResultType();
 }
 
@@ -575,7 +575,7 @@
 ///
 const FunctionType *BlockExpr::getFunctionType() const {
   return getType()->getAs<BlockPointerType>()->
-                    getPointeeType()->getAsFunctionType();
+                    getPointeeType()->getAs<FunctionType>();
 }
 
 SourceLocation BlockExpr::getCaretLocation() const {
@@ -1693,7 +1693,7 @@
 }
 
 unsigned ExtVectorElementExpr::getNumElements() const {
-  if (const VectorType *VT = getType()->getAsVectorType())
+  if (const VectorType *VT = getType()->getAs<VectorType>())
     return VT->getNumElements();
   return 1;
 }
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index 8df52c9..9c34547 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -487,7 +487,7 @@
 }
 
 APValue VectorExprEvaluator::VisitCastExpr(const CastExpr* E) {
-  const VectorType *VTy = E->getType()->getAsVectorType();
+  const VectorType *VTy = E->getType()->getAs<VectorType>();
   QualType EltTy = VTy->getElementType();
   unsigned NElts = VTy->getNumElements();
   unsigned EltWidth = Info.Ctx.getTypeSize(EltTy);
@@ -566,7 +566,7 @@
 
 APValue
 VectorExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
-  const VectorType *VT = E->getType()->getAsVectorType();
+  const VectorType *VT = E->getType()->getAs<VectorType>();
   unsigned NumInits = E->getNumInits();
   unsigned NumElements = VT->getNumElements();
 
@@ -599,7 +599,7 @@
 
 APValue
 VectorExprEvaluator::GetZeroVector(QualType T) {
-  const VectorType *VT = T->getAsVectorType();
+  const VectorType *VT = T->getAs<VectorType>();
   QualType EltTy = VT->getElementType();
   APValue ZeroElement;
   if (EltTy->isIntegerType())
@@ -1575,7 +1575,7 @@
 
   APValue VisitCastExpr(CastExpr *E) {
     Expr* SubExpr = E->getSubExpr();
-    QualType EltType = E->getType()->getAsComplexType()->getElementType();
+    QualType EltType = E->getType()->getAs<ComplexType>()->getElementType();
     QualType SubType = SubExpr->getType();
 
     if (SubType->isRealFloatingType()) {
@@ -1612,7 +1612,7 @@
         Zero = 0;
         return APValue(Result, Zero);
       }
-    } else if (const ComplexType *CT = SubType->getAsComplexType()) {
+    } else if (const ComplexType *CT = SubType->getAs<ComplexType>()) {
       APValue Src;
 
       if (!EvaluateComplex(SubExpr, Src, Info))
diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp
index a6f2b82..05d0c26 100644
--- a/lib/AST/StmtPrinter.cpp
+++ b/lib/AST/StmtPrinter.cpp
@@ -595,7 +595,7 @@
   OS << Node->getValue().toString(10, isSigned);
 
   // Emit suffixes.  Integer literals are always a builtin integer type.
-  switch (Node->getType()->getAsBuiltinType()->getKind()) {
+  switch (Node->getType()->getAs<BuiltinType>()->getKind()) {
   default: assert(0 && "Unexpected type for integer literal!");
   case BuiltinType::Int:       break; // no suffix.
   case BuiltinType::UInt:      OS << 'U'; break;
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index 1a6ea0a..2783211 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -159,7 +159,7 @@
       return QualType(this, 0);
 
     QualType Canon = Spec->getCanonicalTypeInternal();
-    if (Canon->getAsTemplateSpecializationType())
+    if (Canon->getAs<TemplateSpecializationType>())
       return QualType(this, 0);
     return Canon->getDesugaredType();
   }
@@ -276,54 +276,10 @@
   return cast<ComplexType>(getDesugaredType());
 }
 
-const BuiltinType *Type::getAsBuiltinType() const {
-  // If this is directly a builtin type, return it.
-  if (const BuiltinType *BTy = dyn_cast<BuiltinType>(this))
-    return BTy;
-
-  // If the canonical form of this type isn't a builtin type, reject it.
-  if (!isa<BuiltinType>(CanonicalType)) {
-    // Look through type qualifiers (e.g. ExtQualType's).
-    if (isa<BuiltinType>(CanonicalType.getUnqualifiedType()))
-      return CanonicalType.getUnqualifiedType()->getAsBuiltinType();
-    return 0;
-  }
-
-  // If this is a typedef for a builtin type, strip the typedef off without
-  // losing all typedef information.
-  return cast<BuiltinType>(getDesugaredType());
-}
-
-const FunctionType *Type::getAsFunctionType() const {
-  // If this is directly a function type, return it.
-  if (const FunctionType *FTy = dyn_cast<FunctionType>(this))
-    return FTy;
-
-  // If the canonical form of this type isn't the right kind, reject it.
-  if (!isa<FunctionType>(CanonicalType)) {
-    // Look through type qualifiers
-    if (isa<FunctionType>(CanonicalType.getUnqualifiedType()))
-      return CanonicalType.getUnqualifiedType()->getAsFunctionType();
-    return 0;
-  }
-
-  // If this is a typedef for a function type, strip the typedef off without
-  // losing all typedef information.
-  return cast<FunctionType>(getDesugaredType());
-}
-
-const FunctionNoProtoType *Type::getAsFunctionNoProtoType() const {
-  return dyn_cast_or_null<FunctionNoProtoType>(getAsFunctionType());
-}
-
-const FunctionProtoType *Type::getAsFunctionProtoType() const {
-  return dyn_cast_or_null<FunctionProtoType>(getAsFunctionType());
-}
-
 QualType Type::getPointeeType() const {
   if (const PointerType *PT = getAs<PointerType>())
     return PT->getPointeeType();
-  if (const ObjCObjectPointerType *OPT = getAsObjCObjectPointerType())
+  if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>())
     return OPT->getPointeeType();
   if (const BlockPointerType *BPT = getAs<BlockPointerType>())
     return BPT->getPointeeType();
@@ -357,7 +313,7 @@
   // This one isn't completely obvious, but it follows from the
   // definition in C99 6.7.5p3. Because of this rule, it's
   // illegal to declare a function returning a variably modified type.
-  if (const FunctionType *FT = getAsFunctionType())
+  if (const FunctionType *FT = getAs<FunctionType>())
     return FT->getResultType()->isVariablyModifiedType();
 
   return false;
@@ -408,79 +364,11 @@
   return 0;
 }
 
-const EnumType *Type::getAsEnumType() const {
-  // Check the canonicalized unqualified type directly; the more complex
-  // version is unnecessary because there isn't any typedef information
-  // to preserve.
-  return dyn_cast<EnumType>(CanonicalType.getUnqualifiedType());
-}
-
-const ComplexType *Type::getAsComplexType() const {
-  // Are we directly a complex type?
-  if (const ComplexType *CTy = dyn_cast<ComplexType>(this))
-    return CTy;
-
-  // If the canonical form of this type isn't the right kind, reject it.
-  if (!isa<ComplexType>(CanonicalType)) {
-    // Look through type qualifiers
-    if (isa<ComplexType>(CanonicalType.getUnqualifiedType()))
-      return CanonicalType.getUnqualifiedType()->getAsComplexType();
-    return 0;
-  }
-
-  // If this is a typedef for a complex type, strip the typedef off without
-  // losing all typedef information.
-  return cast<ComplexType>(getDesugaredType());
-}
-
-const VectorType *Type::getAsVectorType() const {
-  // Are we directly a vector type?
-  if (const VectorType *VTy = dyn_cast<VectorType>(this))
-    return VTy;
-
-  // If the canonical form of this type isn't the right kind, reject it.
-  if (!isa<VectorType>(CanonicalType)) {
-    // Look through type qualifiers
-    if (isa<VectorType>(CanonicalType.getUnqualifiedType()))
-      return CanonicalType.getUnqualifiedType()->getAsVectorType();
-    return 0;
-  }
-
-  // If this is a typedef for a vector type, strip the typedef off without
-  // losing all typedef information.
-  return cast<VectorType>(getDesugaredType());
-}
-
-const ExtVectorType *Type::getAsExtVectorType() const {
-  // Are we directly an OpenCU vector type?
-  if (const ExtVectorType *VTy = dyn_cast<ExtVectorType>(this))
-    return VTy;
-
-  // If the canonical form of this type isn't the right kind, reject it.
-  if (!isa<ExtVectorType>(CanonicalType)) {
-    // Look through type qualifiers
-    if (isa<ExtVectorType>(CanonicalType.getUnqualifiedType()))
-      return CanonicalType.getUnqualifiedType()->getAsExtVectorType();
-    return 0;
-  }
-
-  // If this is a typedef for an extended vector type, strip the typedef off
-  // without losing all typedef information.
-  return cast<ExtVectorType>(getDesugaredType());
-}
-
-const ObjCInterfaceType *Type::getAsObjCInterfaceType() 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.
-  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 (const ObjCInterfaceType *OIT = getAs<ObjCInterfaceType>())
     if (OIT->getNumProtocols())
       return OIT;
   return 0;
@@ -490,16 +378,10 @@
   return getAsObjCQualifiedInterfaceType() != 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 ObjCObjectPointerType *Type::getAsObjCQualifiedIdType() const {
   // There is no sugar for ObjCQualifiedIdType's, just return the canonical
   // type pointer if it is the right class.
-  if (const ObjCObjectPointerType *OPT = getAsObjCObjectPointerType()) {
+  if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>()) {
     if (OPT->isObjCQualifiedIdType())
       return OPT;
   }
@@ -507,20 +389,13 @@
 }
 
 const ObjCObjectPointerType *Type::getAsObjCInterfacePointerType() const {
-  if (const ObjCObjectPointerType *OPT = getAsObjCObjectPointerType()) {
+  if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>()) {
     if (OPT->getInterfaceType())
       return OPT;
   }
   return 0;
 }
 
-const TemplateTypeParmType *Type::getAsTemplateTypeParmType() const {
-  // There is no sugar for template type parameters, so just return
-  // the canonical type pointer if it is the right class.
-  // FIXME: can these be address-space qualified?
-  return dyn_cast<TemplateTypeParmType>(CanonicalType);
-}
-
 const CXXRecordDecl *Type::getCXXRecordDeclForPointerType() const {
   if (const PointerType *PT = getAs<PointerType>())
     if (const RecordType *RT = PT->getPointeeType()->getAs<RecordType>())
@@ -528,13 +403,6 @@
   return 0;
 }
 
-const TemplateSpecializationType *
-Type::getAsTemplateSpecializationType() const {
-  // There is no sugar for class template specialization types, so
-  // just return the canonical type pointer if it is the right class.
-  return this->getAs<TemplateSpecializationType>();
-}
-
 bool Type::isIntegerType() const {
   if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
     return BT->getKind() >= BuiltinType::Bool &&
@@ -826,7 +694,7 @@
 }
 
 bool Type::isPromotableIntegerType() const {
-  if (const BuiltinType *BT = getAsBuiltinType())
+  if (const BuiltinType *BT = getAs<BuiltinType>())
     switch (BT->getKind()) {
     case BuiltinType::Bool:
     case BuiltinType::Char_S:
@@ -843,7 +711,7 @@
 }
 
 bool Type::isNullPtrType() const {
-  if (const BuiltinType *BT = getAsBuiltinType())
+  if (const BuiltinType *BT = getAs<BuiltinType>())
     return BT->getKind() == BuiltinType::NullPtr;
   return false;
 }