Per offline discussion with Steve Naroff, add back Type::getAsXXXType() methods
until Doug Gregor's Type smart pointer code lands (or more discussion occurs).
These methods just call the new Type::getAs<XXX> methods, so we still have
reduced implementation redundancy. Having explicit getAsXXXType() methods makes
it easier to set breakpoints in the debugger.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76193 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index ff5ead0..1304558 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -133,8 +133,8 @@
     QualType Ty = V->getType();
     if (Ty->isBlockPointerType() || Ty->isFunctionPointerType()) {
       const FunctionType *FT = Ty->isFunctionPointerType() 
-      ? Ty->getAs<PointerType>()->getPointeeType()->getAsFunctionType()
-      : Ty->getAs<BlockPointerType>()->getPointeeType()->getAsFunctionType();
+      ? Ty->getAsPointerType()->getPointeeType()->getAsFunctionType()
+      : Ty->getAsBlockPointerType()->getPointeeType()->getAsFunctionType();
       if (const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FT)) {
         unsigned NumArgsInProto = Proto->getNumArgs();
         unsigned k;
@@ -756,7 +756,7 @@
     // whether its a pointer and whether it adds any qualifiers to the
     // anonymous struct/union fields we're looking into.
     QualType ObjectType = BaseObjectExpr->getType();
-    if (const PointerType *ObjectPtr = ObjectType->getAs<PointerType>()) {
+    if (const PointerType *ObjectPtr = ObjectType->getAsPointerType()) {
       BaseObjectIsPointer = true;
       ObjectType = ObjectPtr->getPointeeType();
     }
@@ -1073,7 +1073,7 @@
         Ctx = FD->getDeclContext();
         MemberType = FD->getType();
 
-        if (const ReferenceType *RefType = MemberType->getAs<ReferenceType>())
+        if (const ReferenceType *RefType = MemberType->getAsReferenceType())
           MemberType = RefType->getPointeeType();
         else if (!FD->isMutable()) {
           unsigned combinedQualifiers 
@@ -1835,11 +1835,11 @@
     BaseExpr = LHSExp;
     IndexExpr = RHSExp;
     ResultType = Context.DependentTy;
-  } else if (const PointerType *PTy = LHSTy->getAs<PointerType>()) {
+  } else if (const PointerType *PTy = LHSTy->getAsPointerType()) {
     BaseExpr = LHSExp;
     IndexExpr = RHSExp;
     ResultType = PTy->getPointeeType();
-  } else if (const PointerType *PTy = RHSTy->getAs<PointerType>()) {
+  } else if (const PointerType *PTy = RHSTy->getAsPointerType()) {
      // Handle the uncommon case of "123[Ptr]".
     BaseExpr = RHSExp;
     IndexExpr = LHSExp;
@@ -1874,7 +1874,7 @@
 
     BaseExpr = LHSExp;
     IndexExpr = RHSExp;
-    ResultType = LHSTy->getAs<PointerType>()->getPointeeType();
+    ResultType = LHSTy->getAsPointerType()->getPointeeType();
   } else if (RHSTy->isArrayType()) {
     // Same as previous, except for 123[f().a] case
     Diag(RHSExp->getLocStart(), diag::ext_subscript_non_lvalue) <<
@@ -1884,7 +1884,7 @@
 
     BaseExpr = RHSExp;
     IndexExpr = LHSExp;
-    ResultType = RHSTy->getAs<PointerType>()->getPointeeType();
+    ResultType = RHSTy->getAsPointerType()->getPointeeType();
   } else {
     return ExprError(Diag(LLoc, diag::err_typecheck_subscript_value)
        << LHSExp->getSourceRange() << RHSExp->getSourceRange());
@@ -2098,7 +2098,7 @@
                                                          OpLoc, 
                                                      DeclarationName(&Member),
                                                          MemberLoc));
-    else if (const PointerType *PT = BaseType->getAs<PointerType>())
+    else if (const PointerType *PT = BaseType->getAsPointerType())
       BaseType = PT->getPointeeType();
     else if (BaseType->isObjCObjectPointerType())
       ;
@@ -2119,7 +2119,7 @@
       // In Obj-C++, however, the above expression is valid, since it could be
       // accessing the 'f' property if T is an Obj-C interface. The extra check
       // allows this, while still reporting an error if T is a struct pointer.
-      const PointerType *PT = BaseType->getAs<PointerType>();
+      const PointerType *PT = BaseType->getAsPointerType();
 
       if (!PT || (getLangOptions().ObjC1 && 
                   !PT->getPointeeType()->isRecordType()))
@@ -2133,7 +2133,7 @@
 
   // Handle field access to simple records.  This also handles access to fields
   // of the ObjC 'id' struct.
-  if (const RecordType *RTy = BaseType->getAs<RecordType>()) {
+  if (const RecordType *RTy = BaseType->getAsRecordType()) {
     RecordDecl *RDecl = RTy->getDecl();
     if (RequireCompleteType(OpLoc, BaseType,
                                diag::err_typecheck_incomplete_tag,
@@ -2177,7 +2177,7 @@
       // Figure out the type of the member; see C99 6.5.2.3p3, C++ [expr.ref]
       // FIXME: Handle address space modifiers
       QualType MemberType = FD->getType();
-      if (const ReferenceType *Ref = MemberType->getAs<ReferenceType>())
+      if (const ReferenceType *Ref = MemberType->getAsReferenceType())
         MemberType = Ref->getPointeeType();
       else {
         unsigned combinedQualifiers =
@@ -2500,7 +2500,7 @@
   if (BaseType == Context.OverloadTy || 
       BaseType->isFunctionType() ||
       (BaseType->isPointerType() && 
-       BaseType->getAs<PointerType>()->isFunctionType())) {
+       BaseType->getAsPointerType()->isFunctionType())) {
     SourceLocation Loc = PP.getLocForEndOfToken(BaseExpr->getLocEnd());
     Diag(Loc, diag::note_member_reference_needs_call)
       << CodeModificationHint::CreateInsertion(Loc, "()");
@@ -2794,13 +2794,13 @@
   if (!Fn->getType()->isBlockPointerType()) {
     // C99 6.5.2.2p1 - "The expression that denotes the called function shall
     // have type pointer to function".
-    const PointerType *PT = Fn->getType()->getAs<PointerType>();
+    const PointerType *PT = Fn->getType()->getAsPointerType();
     if (PT == 0)
       return ExprError(Diag(LParenLoc, diag::err_typecheck_call_not_function)
         << Fn->getType() << Fn->getSourceRange());
     FuncT = PT->getPointeeType()->getAsFunctionType();
   } else { // This is a block call.
-    FuncT = Fn->getType()->getAs<BlockPointerType>()->getPointeeType()->
+    FuncT = Fn->getType()->getAsBlockPointerType()->getPointeeType()->
                 getAsFunctionType();
   }
   if (FuncT == 0)
@@ -2937,7 +2937,7 @@
         << castType << castExpr->getSourceRange();
     } else if (castType->isUnionType()) {
       // GCC cast to union extension
-      RecordDecl *RD = castType->getAs<RecordType>()->getDecl();
+      RecordDecl *RD = castType->getAsRecordType()->getDecl();
       RecordDecl::field_iterator Field, FieldEnd;
       for (Field = RD->field_begin(), FieldEnd = RD->field_end();
            Field != FieldEnd; ++Field) {
@@ -3078,8 +3078,8 @@
 
   // If both operands are the same structure or union type, the result is that
   // type.
-  if (const RecordType *LHSRT = LHSTy->getAs<RecordType>()) {    // C99 6.5.15p3
-    if (const RecordType *RHSRT = RHSTy->getAs<RecordType>())
+  if (const RecordType *LHSRT = LHSTy->getAsRecordType()) {    // C99 6.5.15p3
+    if (const RecordType *RHSRT = RHSTy->getAsRecordType())
       if (LHSRT->getDecl() == RHSRT->getDecl())
         // "If both the operands have structure or union type, the result has
         // that type."  This implies that CV qualifiers are dropped.
@@ -3131,8 +3131,8 @@
       return LHSTy;
     }
     // The block pointer types aren't identical, continue checking.
-    QualType lhptee = LHSTy->getAs<BlockPointerType>()->getPointeeType();
-    QualType rhptee = RHSTy->getAs<BlockPointerType>()->getPointeeType();
+    QualType lhptee = LHSTy->getAsBlockPointerType()->getPointeeType();
+    QualType rhptee = RHSTy->getAsBlockPointerType()->getPointeeType();
 
     if (!Context.typesAreCompatible(lhptee.getUnqualifiedType(),
                                     rhptee.getUnqualifiedType())) {
@@ -3206,8 +3206,8 @@
   // Check constraints for C object pointers types (C99 6.5.15p3,6).
   if (LHSTy->isPointerType() && RHSTy->isPointerType()) {
     // get the "pointed to" types
-    QualType lhptee = LHSTy->getAs<PointerType>()->getPointeeType();
-    QualType rhptee = RHSTy->getAs<PointerType>()->getPointeeType();
+    QualType lhptee = LHSTy->getAsPointerType()->getPointeeType();
+    QualType rhptee = RHSTy->getAsPointerType()->getPointeeType();
 
     // ignore qualifiers on void (C99 6.5.15p3, clause 6)
     if (lhptee->isVoidType() && rhptee->isIncompleteOrObjectType()) {
@@ -3313,8 +3313,8 @@
   QualType lhptee, rhptee;
 
   // get the "pointed to" type (ignoring qualifiers at the top level)
-  lhptee = lhsType->getAs<PointerType>()->getPointeeType();
-  rhptee = rhsType->getAs<PointerType>()->getPointeeType();
+  lhptee = lhsType->getAsPointerType()->getPointeeType();
+  rhptee = rhsType->getAsPointerType()->getPointeeType();
 
   return CheckPointeeTypesForAssignment(lhptee, rhptee);
 }
@@ -3396,8 +3396,8 @@
   QualType lhptee, rhptee;
 
   // get the "pointed to" type (ignoring qualifiers at the top level)
-  lhptee = lhsType->getAs<BlockPointerType>()->getPointeeType();
-  rhptee = rhsType->getAs<BlockPointerType>()->getPointeeType();
+  lhptee = lhsType->getAsBlockPointerType()->getPointeeType();
+  rhptee = rhsType->getAsBlockPointerType()->getPointeeType();
 
   // make sure we operate on the canonical type
   lhptee = Context.getCanonicalType(lhptee);
@@ -3447,7 +3447,7 @@
   // right-hand side type. The caller is responsible for adjusting
   // lhsType so that the resulting expression does not have reference
   // type.
-  if (const ReferenceType *lhsTypeRef = lhsType->getAs<ReferenceType>()) {
+  if (const ReferenceType *lhsTypeRef = lhsType->getAsReferenceType()) {
     if (Context.typesAreCompatible(lhsTypeRef->getPointeeType(), rhsType))
       return Compatible;
     return Incompatible;
@@ -3496,12 +3496,12 @@
 
     if (isa<ObjCObjectPointerType>(rhsType)) {
       QualType rhptee = rhsType->getAsObjCObjectPointerType()->getPointeeType();
-      QualType lhptee = lhsType->getAs<PointerType>()->getPointeeType();
+      QualType lhptee = lhsType->getAsPointerType()->getPointeeType();
       return CheckPointeeTypesForAssignment(lhptee, rhptee);
     }
 
-    if (rhsType->getAs<BlockPointerType>()) {
-      if (lhsType->getAs<PointerType>()->getPointeeType()->isVoidType())
+    if (rhsType->getAsBlockPointerType()) {
+      if (lhsType->getAsPointerType()->getPointeeType()->isVoidType())
         return Compatible;
 
       // Treat block pointers as objects.
@@ -3522,7 +3522,7 @@
     if (rhsType->isBlockPointerType())
       return CheckBlockPointerTypesForAssignment(lhsType, rhsType);
 
-    if (const PointerType *RHSPT = rhsType->getAs<PointerType>()) {
+    if (const PointerType *RHSPT = rhsType->getAsPointerType()) {
       if (RHSPT->getPointeeType()->isVoidType())
         return Compatible;
     }
@@ -3535,7 +3535,7 @@
 
     if (isa<PointerType>(rhsType)) {
       QualType lhptee = lhsType->getAsObjCObjectPointerType()->getPointeeType();
-      QualType rhptee = rhsType->getAs<PointerType>()->getPointeeType();
+      QualType rhptee = rhsType->getAsPointerType()->getPointeeType();
       return CheckPointeeTypesForAssignment(lhptee, rhptee);
     }
     if (rhsType->isObjCObjectPointerType()) {
@@ -3545,7 +3545,7 @@
       QualType rhptee = rhsType->getAsObjCObjectPointerType()->getPointeeType();
       return CheckPointeeTypesForAssignment(lhptee, rhptee);
     }
-    if (const PointerType *RHSPT = rhsType->getAs<PointerType>()) {
+    if (const PointerType *RHSPT = rhsType->getAsPointerType()) {
       if (RHSPT->getPointeeType()->isVoidType())
         return Compatible;
     }
@@ -3566,7 +3566,7 @@
       return CheckPointerTypesForAssignment(lhsType, rhsType);
 
     if (isa<BlockPointerType>(lhsType) &&
-        rhsType->getAs<PointerType>()->getPointeeType()->isVoidType())
+        rhsType->getAsPointerType()->getPointeeType()->isVoidType())
       return Compatible;
     return Incompatible;
   }
@@ -3580,11 +3580,11 @@
 
     if (isa<PointerType>(lhsType)) {
       QualType rhptee = lhsType->getAsObjCObjectPointerType()->getPointeeType();
-      QualType lhptee = rhsType->getAs<PointerType>()->getPointeeType();
+      QualType lhptee = rhsType->getAsPointerType()->getPointeeType();
       return CheckPointeeTypesForAssignment(lhptee, rhptee);
     }
     if (isa<BlockPointerType>(lhsType) &&
-        rhsType->getAs<PointerType>()->getPointeeType()->isVoidType())
+        rhsType->getAsPointerType()->getPointeeType()->isVoidType())
       return Compatible;
     return Incompatible;
   }
@@ -3636,7 +3636,7 @@
       // 1) void pointer
       // 2) null pointer constant
       if (FromType->isPointerType())
-        if (FromType->getAs<PointerType>()->getPointeeType()->isVoidType()) {
+        if (FromType->getAsPointerType()->getPointeeType()->isVoidType()) {
           ImpCastExprToType(rExpr, it->getType());
           InitField = *it;
           break;
@@ -3973,7 +3973,7 @@
     }
 
     // Handle pointer-pointer subtractions.
-    if (const PointerType *RHSPTy = rex->getType()->getAs<PointerType>()) {
+    if (const PointerType *RHSPTy = rex->getType()->getAsPointerType()) {
       QualType rpointee = RHSPTy->getPointeeType();
 
       // RHS must be a completely-type object type.
@@ -4168,9 +4168,9 @@
   // errors (when -pedantic-errors is enabled).
   if (lType->isPointerType() && rType->isPointerType()) { // C99 6.5.8p2
     QualType LCanPointeeTy =
-      Context.getCanonicalType(lType->getAs<PointerType>()->getPointeeType());
+      Context.getCanonicalType(lType->getAsPointerType()->getPointeeType());
     QualType RCanPointeeTy =
-      Context.getCanonicalType(rType->getAs<PointerType>()->getPointeeType());
+      Context.getCanonicalType(rType->getAsPointerType()->getPointeeType());
 
     if (isRelational) {
       if (lType->isFunctionPointerType() || rType->isFunctionPointerType()) {
@@ -4240,8 +4240,8 @@
   }
   // Handle block pointer types.
   if (!isRelational && lType->isBlockPointerType() && rType->isBlockPointerType()) {
-    QualType lpointee = lType->getAs<BlockPointerType>()->getPointeeType();
-    QualType rpointee = rType->getAs<BlockPointerType>()->getPointeeType();
+    QualType lpointee = lType->getAsBlockPointerType()->getPointeeType();
+    QualType rpointee = rType->getAsBlockPointerType()->getPointeeType();
 
     if (!LHSIsNull && !RHSIsNull &&
         !Context.typesAreCompatible(lpointee, rpointee)) {
@@ -4256,9 +4256,9 @@
       && ((lType->isBlockPointerType() && rType->isPointerType())
           || (lType->isPointerType() && rType->isBlockPointerType()))) {
     if (!LHSIsNull && !RHSIsNull) {
-      if (!((rType->isPointerType() && rType->getAs<PointerType>()
+      if (!((rType->isPointerType() && rType->getAsPointerType()
              ->getPointeeType()->isVoidType())
-            || (lType->isPointerType() && lType->getAs<PointerType>()
+            || (lType->isPointerType() && lType->getAsPointerType()
                 ->getPointeeType()->isVoidType())))
         Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
           << lType << rType << lex->getSourceRange() << rex->getSourceRange();
@@ -4269,8 +4269,8 @@
 
   if ((lType->isObjCObjectPointerType() || rType->isObjCObjectPointerType())) {
     if (lType->isPointerType() || rType->isPointerType()) {
-      const PointerType *LPT = lType->getAs<PointerType>();
-      const PointerType *RPT = rType->getAs<PointerType>();
+      const PointerType *LPT = lType->getAsPointerType();
+      const PointerType *RPT = rType->getAsPointerType();
       bool LPtrToVoid = LPT ?
         Context.getCanonicalType(LPT->getPointeeType())->isVoidType() : false;
       bool RPtrToVoid = RPT ?
@@ -4798,7 +4798,7 @@
   // incomplete type or void.  It would be possible to warn about dereferencing
   // a void pointer, but it's completely well-defined, and such a warning is
   // unlikely to catch any mistakes.
-  if (const PointerType *PT = Ty->getAs<PointerType>())
+  if (const PointerType *PT = Ty->getAsPointerType())
     return PT->getPointeeType();
 
   if (const ObjCObjectPointerType *OPT = Ty->getAsObjCObjectPointerType())
@@ -5256,7 +5256,7 @@
         continue;
       }
 
-      const RecordType *RC = Res->getType()->getAs<RecordType>();
+      const RecordType *RC = Res->getType()->getAsRecordType();
       if (!RC) {
         Res->Destroy(Context);
         return ExprError(Diag(OC.LocEnd, diag::err_offsetof_record_type)