Change uses of:
  Type::getAsReferenceType() -> Type::getAs<ReferenceType>()
  Type::getAsRecordType() -> Type::getAs<RecordType>()
  Type::getAsPointerType() -> Type::getAs<PointerType>()
  Type::getAsBlockPointerType() -> Type::getAs<BlockPointerType>()
  Type::getAsLValueReferenceType() -> Type::getAs<LValueReferenceType>()
  Type::getAsRValueReferenceType() -> Type::getAs<RValueReferenceType>()
  Type::getAsMemberPointerType() -> Type::getAs<MemberPointerType>()
  Type::getAsReferenceType() -> Type::getAs<ReferenceType>()
  Type::getAsTagType() -> Type::getAs<TagType>()
  
And remove Type::getAsReferenceType(), etc.

This change is similar to one I made a couple weeks ago, but that was partly
reverted pending some additional design discussion. With Doug's pending smart
pointer changes for Types, it seemed natural to take this approach.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77510 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index cda55e2..66aa363 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -468,7 +468,7 @@
 
   if (const ValueDecl *VD = dyn_cast<ValueDecl>(D)) {
     QualType T = VD->getType();
-    if (const ReferenceType* RT = T->getAsReferenceType()) {
+    if (const ReferenceType* RT = T->getAs<ReferenceType>()) {
       unsigned AS = RT->getPointeeType().getAddressSpace();
       Align = Target.getPointerAlign(AS);
     } else if (!T->isIncompleteType() && !T->isFunctionType()) {
@@ -994,7 +994,7 @@
     return T;
   
   if (T->isPointerType()) {
-    QualType Pointee = T->getAsPointerType()->getPointeeType();
+    QualType Pointee = T->getAs<PointerType>()->getPointeeType();
     if (Pointee->isAnyPointerType()) {
       QualType ResultType = getObjCGCQualType(Pointee, GCAttr);
       return getPointerType(ResultType);
@@ -1045,14 +1045,14 @@
   QualifierSet qs;
   qs.strip(T);
   if (T->isPointerType()) {
-    QualType Pointee = T->getAsPointerType()->getPointeeType();
+    QualType Pointee = T->getAs<PointerType>()->getPointeeType();
     QualType ResultType = getNoReturnType(Pointee);
     ResultType = getPointerType(ResultType);
     ResultType.setCVRQualifiers(T.getCVRQualifiers());
     return qs.apply(ResultType, *this);
   }
   if (T->isBlockPointerType()) {
-    QualType Pointee = T->getAsBlockPointerType()->getPointeeType();
+    QualType Pointee = T->getAs<BlockPointerType>()->getPointeeType();
     QualType ResultType = getNoReturnType(Pointee);
     ResultType = getBlockPointerType(ResultType);
     ResultType.setCVRQualifiers(T.getCVRQualifiers());
@@ -2434,7 +2434,7 @@
 }
 
 void ASTContext::setCFConstantStringType(QualType T) {
-  const RecordType *Rec = T->getAsRecordType();
+  const RecordType *Rec = T->getAs<RecordType>();
   assert(Rec && "Invalid CFConstantStringType");
   CFConstantStringTypeDecl = Rec->getDecl();
 }
@@ -2470,7 +2470,7 @@
 }
 
 void ASTContext::setObjCFastEnumerationStateType(QualType T) {
-  const RecordType *Rec = T->getAsRecordType();
+  const RecordType *Rec = T->getAs<RecordType>();
   assert(Rec && "Invalid ObjCFAstEnumerationStateType");
   ObjCFastEnumerationStateTypeDecl = Rec->getDecl();
 }
@@ -2751,7 +2751,7 @@
     return;
   }
   
-  if (const PointerType *PT = T->getAsPointerType()) {
+  if (const PointerType *PT = T->getAs<PointerType>()) {
     QualType PointeeTy = PT->getPointeeType();
     bool isReadOnly = false;
     // For historical/compatibility reasons, the read-only qualifier of the
@@ -2766,8 +2766,8 @@
     }
     else if (OutermostType) {
       QualType P = PointeeTy;
-      while (P->getAsPointerType())
-        P = P->getAsPointerType()->getPointeeType();
+      while (P->getAs<PointerType>())
+        P = P->getAs<PointerType>()->getPointeeType();
       if (P.isConstQualified()) {
         isReadOnly = true;
         S += 'r';
@@ -2796,7 +2796,7 @@
         S += '*';
         return;
       }
-    } else if (const RecordType *RTy = PointeeTy->getAsRecordType()) {
+    } else if (const RecordType *RTy = PointeeTy->getAs<RecordType>()) {
       // GCC binary compat: Need to convert "struct objc_class *" to "#".
       if (RTy->getDecl()->getIdentifier() == &Idents.get("objc_class")) {
         S += '#';
@@ -2849,7 +2849,7 @@
     return;
   }
   
-  if (const RecordType *RTy = T->getAsRecordType()) {
+  if (const RecordType *RTy = T->getAs<RecordType>()) {
     RecordDecl *RDecl = RTy->getDecl();
     S += RDecl->isUnion() ? '(' : '{';
     // Anonymous structures print as '?'
@@ -3015,7 +3015,7 @@
   TypedefDecl *TD = TT->getDecl();
 
   // typedef struct objc_selector *SEL;
-  const PointerType *ptr = TD->getUnderlyingType()->getAsPointerType();
+  const PointerType *ptr = TD->getUnderlyingType()->getAs<PointerType>();
   if (!ptr)
     return;
   const RecordType *rec = ptr->getPointeeType()->getAsStructureType();
@@ -3158,7 +3158,7 @@
       if (Ty->isObjCObjectPointerType())
         GCAttrs = QualType::Strong;
       else if (Ty->isPointerType())
-        return getObjCGCAttrKind(Ty->getAsPointerType()->getPointeeType());
+        return getObjCGCAttrKind(Ty->getAs<PointerType>()->getPointeeType());
     }
     // Non-pointers have none gc'able attribute regardless of the attribute
     // set on them.
@@ -3557,9 +3557,9 @@
   // enough that they should be handled separately.
   // FIXME: Merging of lvalue and rvalue references is incorrect. C++ *really*
   // shouldn't be going through here!
-  if (const ReferenceType *RT = LHS->getAsReferenceType())
+  if (const ReferenceType *RT = LHS->getAs<ReferenceType>())
     LHS = RT->getPointeeType();
-  if (const ReferenceType *RT = RHS->getAsReferenceType())
+  if (const ReferenceType *RT = RHS->getAs<ReferenceType>())
     RHS = RT->getPointeeType();
 
   QualType LHSCan = getCanonicalType(LHS),
@@ -3688,8 +3688,8 @@
   case Type::Pointer:
   {
     // Merge two pointer types, while trying to preserve typedef info
-    QualType LHSPointee = LHS->getAsPointerType()->getPointeeType();
-    QualType RHSPointee = RHS->getAsPointerType()->getPointeeType();
+    QualType LHSPointee = LHS->getAs<PointerType>()->getPointeeType();
+    QualType RHSPointee = RHS->getAs<PointerType>()->getPointeeType();
     QualType ResultType = mergeTypes(LHSPointee, RHSPointee);
     if (ResultType.isNull()) return QualType();
     if (getCanonicalType(LHSPointee) == getCanonicalType(ResultType))
@@ -3701,8 +3701,8 @@
   case Type::BlockPointer:
   {
     // Merge two block pointer types, while trying to preserve typedef info
-    QualType LHSPointee = LHS->getAsBlockPointerType()->getPointeeType();
-    QualType RHSPointee = RHS->getAsBlockPointerType()->getPointeeType();
+    QualType LHSPointee = LHS->getAs<BlockPointerType>()->getPointeeType();
+    QualType RHSPointee = RHS->getAs<BlockPointerType>()->getPointeeType();
     QualType ResultType = mergeTypes(LHSPointee, RHSPointee);
     if (ResultType.isNull()) return QualType();
     if (getCanonicalType(LHSPointee) == getCanonicalType(ResultType))
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 9701f6c..a15e135 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -157,7 +157,7 @@
   if (!isImplicit() || getDeclName())
     return false;
   
-  if (const RecordType *Record = getType()->getAsRecordType())
+  if (const RecordType *Record = getType()->getAs<RecordType>())
     return Record->getDecl()->isAnonymousStructOrUnion();
 
   return false;
@@ -670,24 +670,24 @@
 }
 
 void TagDecl::startDefinition() {
-  TagType *TagT = const_cast<TagType *>(TypeForDecl->getAsTagType());
+  TagType *TagT = const_cast<TagType *>(TypeForDecl->getAs<TagType>());
   TagT->decl.setPointer(this);
-  TagT->getAsTagType()->decl.setInt(1);
+  TagT->getAs<TagType>()->decl.setInt(1);
 }
 
 void TagDecl::completeDefinition() {
   assert((!TypeForDecl || 
-          TypeForDecl->getAsTagType()->decl.getPointer() == this) &&
+          TypeForDecl->getAs<TagType>()->decl.getPointer() == this) &&
          "Attempt to redefine a tag definition?");
   IsDefinition = true;
-  TagType *TagT = const_cast<TagType *>(TypeForDecl->getAsTagType());
+  TagType *TagT = const_cast<TagType *>(TypeForDecl->getAs<TagType>());
   TagT->decl.setPointer(this);
   TagT->decl.setInt(0);
 }
 
 TagDecl* TagDecl::getDefinition(ASTContext& C) const {
   QualType T = C.getTypeDeclType(const_cast<TagDecl*>(this));
-  TagDecl* D = cast<TagDecl>(T->getAsTagType()->getDecl());
+  TagDecl* D = cast<TagDecl>(T->getAs<TagType>()->getDecl());
   return D->isDefinition() ? D : 0;
 }
 
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index 96ba19b..2d27661 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -473,7 +473,7 @@
     if (DeclKind >= Decl::TagFirst && DeclKind <= Decl::TagLast) {
       // If this is a tag type that has a definition or is currently
       // being defined, that definition is our primary context.
-      if (const TagType *TagT =cast<TagDecl>(this)->TypeForDecl->getAsTagType())
+      if (const TagType *TagT =cast<TagDecl>(this)->TypeForDecl->getAs<TagType>())
         if (TagT->isBeingDefined() || 
             (TagT->getDecl() && TagT->getDecl()->isDefinition()))
           return TagT->getDecl();
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
index 8988098..57897b0 100644
--- a/lib/AST/DeclCXX.cpp
+++ b/lib/AST/DeclCXX.cpp
@@ -85,7 +85,7 @@
     if (BaseType->isDependentType())
       continue;
     CXXRecordDecl *BaseClassDecl
-      = cast<CXXRecordDecl>(BaseType->getAsRecordType()->getDecl());
+      = cast<CXXRecordDecl>(BaseType->getAs<RecordType>()->getDecl());
     if (Base->isVirtual())
       hasDirectVirtualBase = true;
     for (CXXRecordDecl::base_class_iterator VBase = 
@@ -129,7 +129,7 @@
     for (int i = 0; i < vbaseCount; i++) {
       QualType QT = UniqueVbases[i]->getType();
       CXXRecordDecl *VBaseClassDecl
-        = cast<CXXRecordDecl>(QT->getAsRecordType()->getDecl());
+        = cast<CXXRecordDecl>(QT->getAs<RecordType>()->getDecl());
       this->VBases[i] = 
         CXXBaseSpecifier(VBaseClassDecl->getSourceRange(), true,
                          VBaseClassDecl->getTagKind() == RecordDecl::TK_class,
@@ -188,7 +188,7 @@
       continue;
     bool AcceptsConst = true;
     QualType ArgType = FnType->getArgType(0);
-    if (const LValueReferenceType *Ref = ArgType->getAsLValueReferenceType()) {
+    if (const LValueReferenceType *Ref = ArgType->getAs<LValueReferenceType>()) {
       ArgType = Ref->getPointeeType();
       // Is it a non-const lvalue reference?
       if (!ArgType.isConstQualified())
@@ -247,7 +247,7 @@
   assert(FnType && "Overloaded operator has no proto function type.");
   assert(FnType->getNumArgs() == 1 && !FnType->isVariadic());
   QualType ArgType = FnType->getArgType(0);
-  if (const LValueReferenceType *Ref = ArgType->getAsLValueReferenceType())
+  if (const LValueReferenceType *Ref = ArgType->getAs<LValueReferenceType>())
     ArgType = Ref->getPointeeType();
 
   ArgType = ArgType.getUnqualifiedType();
@@ -453,7 +453,7 @@
 
   // Do we have a reference type? Rvalue references don't count.
   const LValueReferenceType *ParamRefType =
-    Param->getType()->getAsLValueReferenceType();
+    Param->getType()->getAs<LValueReferenceType>();
   if (!ParamRefType)
     return false;
 
@@ -512,7 +512,7 @@
        E = ClassDecl->vbases_end(); VBase != E; ++VBase) {
     // Skip over virtual bases which have trivial destructors.
     CXXRecordDecl *BaseClassDecl
-      = cast<CXXRecordDecl>(VBase->getType()->getAsRecordType()->getDecl());
+      = cast<CXXRecordDecl>(VBase->getType()->getAs<RecordType>()->getDecl());
     if (BaseClassDecl->hasTrivialDestructor())
       continue;
     uintptr_t Member = 
@@ -526,7 +526,7 @@
       continue;
     // Skip over virtual bases which have trivial destructors.
     CXXRecordDecl *BaseClassDecl
-      = cast<CXXRecordDecl>(Base->getType()->getAsRecordType()->getDecl());
+      = cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
     if (BaseClassDecl->hasTrivialDestructor())
       continue;
     
@@ -540,7 +540,7 @@
        E = ClassDecl->field_end(); Field != E; ++Field) {
     QualType FieldType = C.getBaseElementType((*Field)->getType());
     
-    if (const RecordType* RT = FieldType->getAsRecordType()) {
+    if (const RecordType* RT = FieldType->getAs<RecordType>()) {
       // Skip over virtual bases which have trivial destructors.
       CXXRecordDecl *BaseClassDecl = cast<CXXRecordDecl>(RT->getDecl());
       if (BaseClassDecl->hasTrivialDestructor())
@@ -576,7 +576,7 @@
   for (unsigned i = 0; i < NumInitializers; i++) {
     CXXBaseOrMemberInitializer *Member = Initializers[i];
     if (Member->isBaseInitializer())
-      AllBaseFields[Member->getBaseClass()->getAsRecordType()] = Member;
+      AllBaseFields[Member->getBaseClass()->getAs<RecordType>()] = Member;
     else
      AllBaseFields[Member->getMember()] = Member;
   }
@@ -586,11 +586,11 @@
        ClassDecl->vbases_begin(),
        E = ClassDecl->vbases_end(); VBase != E; ++VBase) {
     if (CXXBaseOrMemberInitializer *Value = 
-        AllBaseFields.lookup(VBase->getType()->getAsRecordType()))
+        AllBaseFields.lookup(VBase->getType()->getAs<RecordType>()))
       AllToInit.push_back(Value);
     else {
       CXXRecordDecl *VBaseDecl = 
-        cast<CXXRecordDecl>(VBase->getType()->getAsRecordType()->getDecl());
+        cast<CXXRecordDecl>(VBase->getType()->getAs<RecordType>()->getDecl());
       assert(VBaseDecl && "setBaseOrMemberInitializers - VBaseDecl null");
       if (!VBaseDecl->getDefaultConstructor(C) && 
           !VBase->getType()->isDependentType())
@@ -610,11 +610,11 @@
     if (Base->isVirtual())
       continue;
     if (CXXBaseOrMemberInitializer *Value = 
-        AllBaseFields.lookup(Base->getType()->getAsRecordType()))
+        AllBaseFields.lookup(Base->getType()->getAs<RecordType>()))
       AllToInit.push_back(Value);
     else {
       CXXRecordDecl *BaseDecl = 
-        cast<CXXRecordDecl>(Base->getType()->getAsRecordType()->getDecl());
+        cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
       assert(BaseDecl && "setBaseOrMemberInitializers - BaseDecl null");
       if (!BaseDecl->getDefaultConstructor(C) && 
           !Base->getType()->isDependentType())
@@ -636,7 +636,7 @@
     }
 
     QualType FT = C.getBaseElementType((*Field)->getType());
-    if (const RecordType* RT = FT->getAsRecordType()) {
+    if (const RecordType* RT = FT->getAs<RecordType>()) {
       CXXConstructorDecl *Ctor =
         cast<CXXRecordDecl>(RT->getDecl())->getDefaultConstructor(C);
       if (!Ctor && !FT->isDependentType())
diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp
index e5bf59f..90cd07a 100644
--- a/lib/AST/DeclPrinter.cpp
+++ b/lib/AST/DeclPrinter.cpp
@@ -90,7 +90,7 @@
   while (!BaseType->isSpecifierType()) {
     if (isa<TypedefType>(BaseType))
       break;
-    else if (const PointerType* PTy = BaseType->getAsPointerType())
+    else if (const PointerType* PTy = BaseType->getAs<PointerType>())
       BaseType = PTy->getPointeeType();
     else if (const ArrayType* ATy = dyn_cast<ArrayType>(BaseType))
       BaseType = ATy->getElementType();
@@ -356,7 +356,7 @@
           }
           else // FIXME. skip dependent types for now.
             if (const RecordType *RT = 
-                BMInitializer->getBaseClass()->getAsRecordType()) {
+                BMInitializer->getBaseClass()->getAs<RecordType>()) {
               const CXXRecordDecl *BaseDecl = 
                 cast<CXXRecordDecl>(RT->getDecl());
               Out << BaseDecl->getNameAsString();
@@ -397,7 +397,7 @@
           else // FIXME. skip dependent types for now.
             if (const RecordType *RT = 
                   DDecl->getAnyBaseClassToDestroy(BaseOrMember)
-                    ->getAsRecordType()) {
+                    ->getAs<RecordType>()) {
               const CXXRecordDecl *BaseDecl = 
                 cast<CXXRecordDecl>(RT->getDecl());
               Proto += "~";
diff --git a/lib/AST/DeclarationName.cpp b/lib/AST/DeclarationName.cpp
index a17abde..a55b363 100644
--- a/lib/AST/DeclarationName.cpp
+++ b/lib/AST/DeclarationName.cpp
@@ -135,7 +135,7 @@
 
   case CXXConstructorName: {
     QualType ClassType = getCXXNameType();
-    if (const RecordType *ClassRec = ClassType->getAsRecordType())
+    if (const RecordType *ClassRec = ClassType->getAs<RecordType>())
       return ClassRec->getDecl()->getNameAsString();
     return ClassType.getAsString();
   }
@@ -143,7 +143,7 @@
   case CXXDestructorName: {
     std::string Result = "~";
     QualType Type = getCXXNameType();
-    if (const RecordType *Rec = Type->getAsRecordType())
+    if (const RecordType *Rec = Type->getAs<RecordType>())
       Result += Rec->getDecl()->getNameAsString();
     else
       Result += Type.getAsString();
@@ -170,7 +170,7 @@
   case CXXConversionFunctionName: {
     std::string Result = "operator ";
     QualType Type = getCXXNameType();
-    if (const RecordType *Rec = Type->getAsRecordType())
+    if (const RecordType *Rec = Type->getAs<RecordType>())
       Result += Rec->getDecl()->getNameAsString();
     else
       Result += Type.getAsString();
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 79ebb54..842caa8 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -288,9 +288,9 @@
 
 QualType CallExpr::getCallReturnType() const {
   QualType CalleeType = getCallee()->getType();
-  if (const PointerType *FnTypePtr = CalleeType->getAsPointerType())
+  if (const PointerType *FnTypePtr = CalleeType->getAs<PointerType>())
     CalleeType = FnTypePtr->getPointeeType();
-  else if (const BlockPointerType *BPT = CalleeType->getAsBlockPointerType())
+  else if (const BlockPointerType *BPT = CalleeType->getAs<BlockPointerType>())
     CalleeType = BPT->getPointeeType();
   
   const FunctionType *FnType = CalleeType->getAsFunctionType();
@@ -439,7 +439,7 @@
 /// getFunctionType - Return the underlying function type for this block.
 ///
 const FunctionType *BlockExpr::getFunctionType() const {
-  return getType()->getAsBlockPointerType()->
+  return getType()->getAs<BlockPointerType>()->
                     getPointeeType()->getAsFunctionType();
 }
 
@@ -923,7 +923,7 @@
   if (CT->isIncompleteType())
     return MLV_IncompleteType;
     
-  if (const RecordType *r = CT->getAsRecordType()) {
+  if (const RecordType *r = CT->getAs<RecordType>()) {
     if (r->hasConstFields()) 
       return MLV_ConstQualified;
   }
@@ -999,7 +999,7 @@
       QualType T = VD->getType();
       // dereferencing to an object pointer is always a gc'able candidate
       if (T->isPointerType() && 
-          T->getAsPointerType()->getPointeeType()->isObjCObjectPointerType())
+          T->getAs<PointerType>()->getPointeeType()->isObjCObjectPointerType())
         return true;
         
     }
@@ -1427,7 +1427,7 @@
   if (const ExplicitCastExpr *CE = dyn_cast<ExplicitCastExpr>(this)) {
     if (!Ctx.getLangOptions().CPlusPlus) {
       // Check that it is a cast to void*.
-      if (const PointerType *PT = CE->getType()->getAsPointerType()) {
+      if (const PointerType *PT = CE->getType()->getAs<PointerType>()) {
         QualType Pointee = PT->getPointeeType();
         if (Pointee.getCVRQualifiers() == 0 && 
             Pointee->isVoidType() &&                              // to void*
diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp
index fbefcd1..df67bea 100644
--- a/lib/AST/ExprCXX.cpp
+++ b/lib/AST/ExprCXX.cpp
@@ -219,20 +219,20 @@
   case UTT_IsPOD: return QueriedType->isPODType();
   case UTT_IsClass: // Fallthrough
   case UTT_IsUnion:
-    if (const RecordType *Record = QueriedType->getAsRecordType()) {
+    if (const RecordType *Record = QueriedType->getAs<RecordType>()) {
       bool Union = Record->getDecl()->isUnion();
       return UTT == UTT_IsUnion ? Union : !Union;
     }
     return false;
   case UTT_IsEnum: return QueriedType->isEnumeralType();
   case UTT_IsPolymorphic:
-    if (const RecordType *Record = QueriedType->getAsRecordType()) {
+    if (const RecordType *Record = QueriedType->getAs<RecordType>()) {
       // Type traits are only parsed in C++, so we've got CXXRecords.
       return cast<CXXRecordDecl>(Record->getDecl())->isPolymorphic();
     }
     return false;
   case UTT_IsAbstract:
-    if (const RecordType *RT = QueriedType->getAsRecordType())
+    if (const RecordType *RT = QueriedType->getAs<RecordType>())
       return cast<CXXRecordDecl>(RT->getDecl())->isAbstract();
     return false;
   case UTT_HasTrivialConstructor:
@@ -243,7 +243,7 @@
     if (QueriedType->isPODType())
       return true;
     if (const RecordType *RT =
-          C.getBaseElementType(QueriedType)->getAsRecordType())
+          C.getBaseElementType(QueriedType)->getAs<RecordType>())
       return cast<CXXRecordDecl>(RT->getDecl())->hasTrivialConstructor();
     return false;
   case UTT_HasTrivialCopy:
@@ -254,7 +254,7 @@
     //   is true, else it is false.
     if (QueriedType->isPODType() || QueriedType->isReferenceType())
       return true;
-    if (const RecordType *RT = QueriedType->getAsRecordType())
+    if (const RecordType *RT = QueriedType->getAs<RecordType>())
       return cast<CXXRecordDecl>(RT->getDecl())->hasTrivialCopyConstructor();
     return false;
   case UTT_HasTrivialAssign:
@@ -274,7 +274,7 @@
       return false;
     if (QueriedType->isPODType())
       return true;
-    if (const RecordType *RT = QueriedType->getAsRecordType())
+    if (const RecordType *RT = QueriedType->getAs<RecordType>())
       return cast<CXXRecordDecl>(RT->getDecl())->hasTrivialCopyAssignment();
     return false;
   case UTT_HasTrivialDestructor:
@@ -287,7 +287,7 @@
     if (QueriedType->isPODType() || QueriedType->isReferenceType())
       return true;
     if (const RecordType *RT =
-          C.getBaseElementType(QueriedType)->getAsRecordType())
+          C.getBaseElementType(QueriedType)->getAs<RecordType>())
       return cast<CXXRecordDecl>(RT->getDecl())->hasTrivialDestructor();
     return false;
   }
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index 0291f6a..2844ab4 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -222,7 +222,7 @@
   if (E->isArrow()) {
     if (!EvaluatePointer(E->getBase(), result, Info))
       return APValue();
-    Ty = E->getBase()->getType()->getAsPointerType()->getPointeeType();
+    Ty = E->getBase()->getType()->getAs<PointerType>()->getPointeeType();
   } else {
     result = Visit(E->getBase());
     if (result.isUninit())
@@ -230,7 +230,7 @@
     Ty = E->getBase()->getType();
   }
 
-  RecordDecl *RD = Ty->getAsRecordType()->getDecl();
+  RecordDecl *RD = Ty->getAs<RecordType>()->getDecl();
   const ASTRecordLayout &RL = Info.Ctx.getASTRecordLayout(RD);
 
   FieldDecl *FD = dyn_cast<FieldDecl>(E->getMemberDecl());
@@ -351,7 +351,7 @@
   if (!EvaluateInteger(IExp, AdditionalOffset, Info))
     return APValue();
 
-  QualType PointeeType = PExp->getType()->getAsPointerType()->getPointeeType();
+  QualType PointeeType = PExp->getType()->getAs<PointerType>()->getPointeeType();
   uint64_t SizeOfPointee;
   
   // Explicitly handle GNU void* and function pointer arithmetic extensions.
@@ -1029,7 +1029,7 @@
 
       if (E->getOpcode() == BinaryOperator::Sub) {
         const QualType Type = E->getLHS()->getType();
-        const QualType ElementType = Type->getAsPointerType()->getPointeeType();
+        const QualType ElementType = Type->getAs<PointerType>()->getPointeeType();
 
         uint64_t D = LHSValue.getLValueOffset() - RHSValue.getLValueOffset();
         if (!ElementType->isVoidType() && !ElementType->isFunctionType())
diff --git a/lib/AST/InheritViz.cpp b/lib/AST/InheritViz.cpp
index 1188ba5..3e5dd1a 100644
--- a/lib/AST/InheritViz.cpp
+++ b/lib/AST/InheritViz.cpp
@@ -90,7 +90,7 @@
 
   // Display the base classes.
   const CXXRecordDecl *Decl 
-    = static_cast<const CXXRecordDecl *>(Type->getAsRecordType()->getDecl());
+    = static_cast<const CXXRecordDecl *>(Type->getAs<RecordType>()->getDecl());
   for (CXXRecordDecl::base_class_const_iterator Base = Decl->bases_begin();
        Base != Decl->bases_end(); ++Base) {
     QualType CanonBaseType = Context.getCanonicalType(Base->getType());
diff --git a/lib/AST/RecordLayoutBuilder.cpp b/lib/AST/RecordLayoutBuilder.cpp
index b09901d..e3581d8 100644
--- a/lib/AST/RecordLayoutBuilder.cpp
+++ b/lib/AST/RecordLayoutBuilder.cpp
@@ -33,7 +33,7 @@
        e = RD->bases_end(); i != e; ++i) {
     if (!i->isVirtual()) {
       const CXXRecordDecl *Base = 
-        cast<CXXRecordDecl>(i->getType()->getAsRecordType()->getDecl());
+        cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
       LayoutNonVirtualBase(Base);
     }
   }
@@ -172,7 +172,7 @@
       FieldSize = 0;
       const ArrayType* ATy = Ctx.getAsArrayType(D->getType());
       FieldAlign = Ctx.getTypeAlign(ATy->getElementType());
-    } else if (const ReferenceType *RT = D->getType()->getAsReferenceType()) {
+    } else if (const ReferenceType *RT = D->getType()->getAs<ReferenceType>()) {
       unsigned AS = RT->getPointeeType().getAddressSpace();
       FieldSize = Ctx.Target.getPointerWidth(AS);
       FieldAlign = Ctx.Target.getPointerAlign(AS);
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index f937d15..789bac3 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -195,23 +195,23 @@
 }
 
 bool Type::isClassType() const {
-  if (const RecordType *RT = getAsRecordType())
+  if (const RecordType *RT = getAs<RecordType>())
     return RT->getDecl()->isClass();
   return false;
 }
 bool Type::isStructureType() const {
-  if (const RecordType *RT = getAsRecordType())
+  if (const RecordType *RT = getAs<RecordType>())
     return RT->getDecl()->isStruct();
   return false;
 }
 bool Type::isVoidPointerType() const {
-  if (const PointerType *PT = getAsPointerType())
+  if (const PointerType *PT = getAs<PointerType>())
     return PT->getPointeeType()->isVoidType();
   return false;
 }
 
 bool Type::isUnionType() const {
-  if (const RecordType *RT = getAsRecordType())
+  if (const RecordType *RT = getAs<RecordType>())
     return RT->getDecl()->isUnion();
   return false;
 }
@@ -299,11 +299,11 @@
 }
 
 QualType Type::getPointeeType() const {
-  if (const PointerType *PT = getAsPointerType())
+  if (const PointerType *PT = getAs<PointerType>())
     return PT->getPointeeType();
   if (const ObjCObjectPointerType *OPT = getAsObjCObjectPointerType())
     return OPT->getPointeeType();
-  if (const BlockPointerType *BPT = getAsBlockPointerType())
+  if (const BlockPointerType *BPT = getAs<BlockPointerType>())
     return BPT->getPointeeType();
   return QualType();
 }
@@ -324,11 +324,11 @@
   // Also, C++ references and member pointers can point to a variably modified
   // type, where VLAs appear as an extension to C++, and should be treated
   // correctly.
-  if (const PointerType *PT = getAsPointerType())
+  if (const PointerType *PT = getAs<PointerType>())
     return PT->getPointeeType()->isVariablyModifiedType();
-  if (const ReferenceType *RT = getAsReferenceType())
+  if (const ReferenceType *RT = getAs<ReferenceType>())
     return RT->getPointeeType()->isVariablyModifiedType();
-  if (const MemberPointerType *PT = getAsMemberPointerType())
+  if (const MemberPointerType *PT = getAs<MemberPointerType>())
     return PT->getPointeeType()->isVariablyModifiedType();
 
   // A function can return a variably modified type
@@ -341,30 +341,6 @@
   return false;
 }
 
-const PointerType *Type::getAsPointerType() const {
-  return getAs<PointerType>();
-}
-const BlockPointerType *Type::getAsBlockPointerType() const {
-  return getAs<BlockPointerType>();
-}
-const ReferenceType *Type::getAsReferenceType() const {
-  return getAs<ReferenceType>();
-}
-const LValueReferenceType *Type::getAsLValueReferenceType() const {
-  return getAs<LValueReferenceType>();
-}
-const RValueReferenceType *Type::getAsRValueReferenceType() const {
-  return getAs<RValueReferenceType>();
-}
-const MemberPointerType *Type::getAsMemberPointerType() const {
-  return getAs<MemberPointerType>();
-}
-const TagType *Type::getAsTagType() const {
-  return getAs<TagType>();
-}
-const RecordType *Type::getAsRecordType() const {
-  return getAs<RecordType>();
-}
 const RecordType *Type::getAsStructureType() const {
   // If this is directly a structure type, return it.
   if (const RecordType *RT = dyn_cast<RecordType>(this)) {
@@ -524,8 +500,8 @@
 }
 
 const CXXRecordDecl *Type::getCXXRecordDeclForPointerType() const {
-  if (const PointerType *PT = getAsPointerType())
-    if (const RecordType *RT = PT->getPointeeType()->getAsRecordType())
+  if (const PointerType *PT = getAs<PointerType>())
+    if (const RecordType *RT = PT->getPointeeType()->getAs<RecordType>())
       return dyn_cast<CXXRecordDecl>(RT->getDecl());
   return 0;
 }