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/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp
index da72b18..8e7a792 100644
--- a/lib/CodeGen/CGBlocks.cpp
+++ b/lib/CodeGen/CGBlocks.cpp
@@ -386,7 +386,7 @@
 
 RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E) {
   const BlockPointerType *BPT =
-    E->getCallee()->getType()->getAsBlockPointerType();
+    E->getCallee()->getType()->getAs<BlockPointerType>();
 
   llvm::Value *Callee = EmitScalarExpr(E->getCallee());
 
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp
index 050323a..d6173a0 100644
--- a/lib/CodeGen/CGCXX.cpp
+++ b/lib/CodeGen/CGCXX.cpp
@@ -207,7 +207,7 @@
   assert(Dest && "Must have a destination!");
   
   const CXXRecordDecl *RD = 
-  cast<CXXRecordDecl>(E->getType()->getAsRecordType()->getDecl());
+  cast<CXXRecordDecl>(E->getType()->getAs<RecordType>()->getDecl());
   if (RD->hasTrivialConstructor())
     return;
   
@@ -458,7 +458,7 @@
       llvm::Value *LoadOfThis = LoadCXXThis();
       Type *BaseType = Member->getBaseClass();
       CXXRecordDecl *BaseClassDecl = 
-        cast<CXXRecordDecl>(BaseType->getAsRecordType()->getDecl());
+        cast<CXXRecordDecl>(BaseType->getAs<RecordType>()->getDecl());
       llvm::Value *V = AddressCXXOfBaseClass(LoadOfThis, ClassDecl, 
                                              BaseClassDecl);
       EmitCXXConstructorCall(Member->getConstructor(),
@@ -475,7 +475,7 @@
 
       llvm::Value *LoadOfThis = LoadCXXThis();
       LValue LHS = EmitLValueForField(LoadOfThis, Field, false, 0);
-      if (FieldType->getAsRecordType()) {
+      if (FieldType->getAs<RecordType>()) {
         
           assert(Member->getConstructor() && 
                  "EmitCtorPrologue - no constructor to initialize member");
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index bf3a0ae..8c77f38 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -945,7 +945,7 @@
     assert(E->getBase()->getType()->isVectorType());
     Base = EmitLValue(E->getBase());
   } else {
-    const PointerType *PT = E->getBase()->getType()->getAsPointerType();
+    const PointerType *PT = E->getBase()->getType()->getAs<PointerType>();
     llvm::Value *Ptr = EmitScalarExpr(E->getBase());
     Base = LValue::MakeAddr(Ptr, PT->getPointeeType().getCVRQualifiers(),
                             QualType::GCNone,
@@ -989,7 +989,7 @@
   if (E->isArrow()) {
     BaseValue = EmitScalarExpr(BaseExpr);
     const PointerType *PTy = 
-      BaseExpr->getType()->getAsPointerType();
+      BaseExpr->getType()->getAs<PointerType>();
     if (PTy->getPointeeType()->isUnionType())
       isUnion = true;
     CVRQualifiers = PTy->getPointeeType().getCVRQualifiers();
@@ -1343,7 +1343,7 @@
   assert(CalleeType->isFunctionPointerType() && 
          "Call must have function pointer type!");
 
-  QualType FnType = CalleeType->getAsPointerType()->getPointeeType();
+  QualType FnType = CalleeType->getAs<PointerType>()->getPointeeType();
   QualType ResultType = FnType->getAsFunctionType()->getResultType();
 
   CallArgList Args;
diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp
index 5e81bf2..7dbf2df 100644
--- a/lib/CodeGen/CGExprAgg.cpp
+++ b/lib/CodeGen/CGExprAgg.cpp
@@ -254,7 +254,7 @@
   } else {
     if (CGF.getContext().getLangOptions().NeXTRuntime) {
       QualType LHSTy = E->getLHS()->getType();
-      if (const RecordType *FDTTy = LHSTy.getTypePtr()->getAsRecordType())
+      if (const RecordType *FDTTy = LHSTy.getTypePtr()->getAs<RecordType>())
         if (FDTTy->getDecl()->hasObjectMember()) {
           LValue RHS = CGF.EmitLValue(E->getRHS());
           CGF.CGM.getObjCRuntime().EmitGCMemmoveCollectable(CGF, LHS.getAddress(), 
@@ -442,7 +442,7 @@
   // the disadvantage is that the generated code is more difficult for
   // the optimizer, especially with bitfields.
   unsigned NumInitElements = E->getNumInits();
-  RecordDecl *SD = E->getType()->getAsRecordType()->getDecl();
+  RecordDecl *SD = E->getType()->getAs<RecordType>()->getDecl();
   unsigned CurInitVal = 0;
 
   if (E->getType()->isUnionType()) {
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp
index ec873ff..8e45997 100644
--- a/lib/CodeGen/CGExprConstant.cpp
+++ b/lib/CodeGen/CGExprConstant.cpp
@@ -271,7 +271,7 @@
   }
   
   bool Build(const InitListExpr *ILE) {
-    RecordDecl *RD = ILE->getType()->getAsRecordType()->getDecl();
+    RecordDecl *RD = ILE->getType()->getAs<RecordType>()->getDecl();
     const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(RD);
     
     unsigned FieldNo = 0;
@@ -512,7 +512,7 @@
     // works well enough!
     const llvm::StructType *SType =
         cast<llvm::StructType>(ConvertType(ILE->getType()));
-    RecordDecl *RD = ILE->getType()->getAsRecordType()->getDecl();
+    RecordDecl *RD = ILE->getType()->getAs<RecordType>()->getDecl();
     std::vector<llvm::Constant*> Elts;
 
     // Initialize the whole structure to zero.
@@ -591,7 +591,7 @@
 #ifndef NDEBUG
       // Make sure that it's really an empty and not a failure of
       // semantic analysis.
-      RecordDecl *RD = ILE->getType()->getAsRecordType()->getDecl();
+      RecordDecl *RD = ILE->getType()->getAs<RecordType>()->getDecl();
       for (RecordDecl::field_iterator Field = RD->field_begin(),
                                    FieldEnd = RD->field_end();
            Field != FieldEnd; ++Field)
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index d780824..c9a1276 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -687,7 +687,7 @@
   int AmountVal = isInc ? 1 : -1;
 
   if (ValTy->isPointerType() &&
-      ValTy->getAsPointerType()->isVariableArrayType()) {
+      ValTy->getAs<PointerType>()->isVariableArrayType()) {
     // The amount of the addition/subtraction needs to account for the VLA size
     CGF.ErrorUnsupported(E, "VLA pointer inc/dec");
   }
@@ -1030,13 +1030,13 @@
   }
 
   if (Ops.Ty->isPointerType() &&
-      Ops.Ty->getAsPointerType()->isVariableArrayType()) {
+      Ops.Ty->getAs<PointerType>()->isVariableArrayType()) {
     // The amount of the addition needs to account for the VLA size
     CGF.ErrorUnsupported(Ops.E, "VLA pointer addition");
   }
   Value *Ptr, *Idx;
   Expr *IdxExp;
-  const PointerType *PT = Ops.E->getLHS()->getType()->getAsPointerType();
+  const PointerType *PT = Ops.E->getLHS()->getType()->getAs<PointerType>();
   const ObjCObjectPointerType *OPT = 
     Ops.E->getLHS()->getType()->getAsObjCObjectPointerType();
   if (PT || OPT) {
@@ -1044,7 +1044,7 @@
     Idx = Ops.RHS;
     IdxExp = Ops.E->getRHS();
   } else {  // int + pointer
-    PT = Ops.E->getRHS()->getType()->getAsPointerType();
+    PT = Ops.E->getRHS()->getType()->getAs<PointerType>();
     OPT = Ops.E->getRHS()->getType()->getAsObjCObjectPointerType();
     assert((PT || OPT) && "Invalid add expr");
     Ptr = Ops.RHS;
@@ -1101,7 +1101,7 @@
   }
 
   if (Ops.E->getLHS()->getType()->isPointerType() &&
-      Ops.E->getLHS()->getType()->getAsPointerType()->isVariableArrayType()) {
+      Ops.E->getLHS()->getType()->getAs<PointerType>()->isVariableArrayType()) {
     // The amount of the addition needs to account for the VLA size for
     // ptr-int
     // The amount of the division needs to account for the VLA size for
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 6628d18..1a065fa 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -2997,7 +2997,7 @@
   if (FQT->isObjCObjectPointerType())
     return QualType::Strong;
 
-  if (const PointerType *PT = FQT->getAsPointerType())
+  if (const PointerType *PT = FQT->getAs<PointerType>())
     return GetGCAttrTypeForType(Ctx, PT->getPointeeType());
 
   return QualType::GCNone;
@@ -3065,7 +3065,7 @@
       if (FQT->isUnionType())
         HasUnion = true;
 
-      BuildAggrIvarRecordLayout(FQT->getAsRecordType(), 
+      BuildAggrIvarRecordLayout(FQT->getAs<RecordType>(), 
                                 BytePos + FieldOffset,
                                 ForStrongLayout, HasUnion);
       continue;
@@ -3090,7 +3090,7 @@
         int OldIndex = IvarsInfo.size() - 1;
         int OldSkIndex = SkipIvars.size() -1;
         
-        const RecordType *RT = FQT->getAsRecordType();
+        const RecordType *RT = FQT->getAs<RecordType>();
         BuildAggrIvarRecordLayout(RT, BytePos + FieldOffset,
                                   ForStrongLayout, HasUnion);
                                   
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index 94fd052..28d729c 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -384,7 +384,7 @@
 /// getCGRecordLayout - Return record layout info.
 const CGRecordLayout *CodeGenFunction::getCGRecordLayout(CodeGenTypes &CGT,
                                                          QualType Ty) {
-  const RecordType *RTy = Ty->getAsRecordType();
+  const RecordType *RTy = Ty->getAs<RecordType>();
   assert (RTy && "Unexpected type. RecordType expected here.");
 
   return CGT.getCGRecordLayout(RTy->getDecl());
@@ -494,7 +494,7 @@
     return SizeEntry;
   } else if (const ArrayType *AT = dyn_cast<ArrayType>(Ty)) {
     EmitVLASize(AT->getElementType());
-  } else if (const PointerType *PT = Ty->getAsPointerType())
+  } else if (const PointerType *PT = Ty->getAs<PointerType>())
     EmitVLASize(PT->getPointeeType());
   else {
     assert(0 && "unknown VM type!");
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index bdc0876..f0b90f0 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -1275,7 +1275,7 @@
   }
   
   QualType CFTy = getContext().getCFConstantStringType();
-  RecordDecl *CFRD = CFTy->getAsRecordType()->getDecl();
+  RecordDecl *CFRD = CFTy->getAs<RecordType>()->getDecl();
 
   const llvm::StructType *STy = 
     cast<llvm::StructType>(getTypes().ConvertType(CFTy));
diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp
index 7d9c5fc..f88ed04 100644
--- a/lib/CodeGen/CodeGenTypes.cpp
+++ b/lib/CodeGen/CodeGenTypes.cpp
@@ -107,12 +107,12 @@
 // and all of the argument types are complete.
 static const TagType *VerifyFuncTypeComplete(const Type* T) {
   const FunctionType *FT = cast<FunctionType>(T);
-  if (const TagType* TT = FT->getResultType()->getAsTagType())
+  if (const TagType* TT = FT->getResultType()->getAs<TagType>())
     if (!TT->getDecl()->isDefinition())
       return TT;
   if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(T))
     for (unsigned i = 0; i < FPT->getNumArgs(); i++)
-      if (const TagType* TT = FPT->getArgType(i)->getAsTagType())
+      if (const TagType* TT = FPT->getArgType(i)->getAs<TagType>())
         if (!TT->getDecl()->isDefinition())
           return TT;
   return 0;
@@ -387,7 +387,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());
         ConvertTagDeclType(Base);
       }
     }
diff --git a/lib/CodeGen/TargetABIInfo.cpp b/lib/CodeGen/TargetABIInfo.cpp
index 5c8d5dd..938281e 100644
--- a/lib/CodeGen/TargetABIInfo.cpp
+++ b/lib/CodeGen/TargetABIInfo.cpp
@@ -68,7 +68,7 @@
 /// fields. Note that a structure with a flexible array member is not
 /// considered empty.
 static bool isEmptyRecord(ASTContext &Context, QualType T) {
-  const RecordType *RT = T->getAsRecordType();
+  const RecordType *RT = T->getAs<RecordType>();
   if (!RT)
     return 0;
   const RecordDecl *RD = RT->getDecl();
@@ -168,7 +168,7 @@
         Context.getTypeSize(FD->getType()) >= 128)
       return true;
 
-    if (const RecordType* RT = FD->getType()->getAsRecordType())
+    if (const RecordType* RT = FD->getType()->getAs<RecordType>())
       if (typeContainsSSEVector(RT->getDecl(), Context))
         return true;
   }
@@ -272,7 +272,7 @@
     return shouldReturnTypeInRegister(AT->getElementType(), Context);
 
   // Otherwise, it must be a record type.
-  const RecordType *RT = Ty->getAsRecordType();
+  const RecordType *RT = Ty->getAs<RecordType>();
   if (!RT) return false;
 
   // Structure types are passed in register if all fields would be
@@ -385,7 +385,7 @@
                                                      ASTContext &Context) {
   unsigned Align = Context.getTypeAlign(Ty);
   if (Align < 128) return 0;
-  if (const RecordType* RT = Ty->getAsRecordType())
+  if (const RecordType* RT = Ty->getAs<RecordType>())
     if (typeContainsSSEVector(RT->getDecl(), Context))
       return 16;
   return 0;
@@ -704,7 +704,7 @@
     if (Hi == Memory)
       Lo = Memory;
     assert((Hi != SSEUp || Lo == SSE) && "Invalid SSEUp array classification.");
-  } else if (const RecordType *RT = Ty->getAsRecordType()) {
+  } else if (const RecordType *RT = Ty->getAs<RecordType>()) {
     uint64_t Size = Context.getTypeSize(Ty);
 
     // AMD64-ABI 3.2.3p2: Rule 1. If the size of an object is larger