]> granicus.if.org Git - clang/commitdiff
Add member template 'Type::getAs<T>', which converts a Type* to a respective T*.
authorTed Kremenek <kremenek@apple.com>
Thu, 16 Jul 2009 19:58:26 +0000 (19:58 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 16 Jul 2009 19:58:26 +0000 (19:58 +0000)
This method is intended to eventually replace the individual
Type::getAsXXXType<> methods.

The motivation behind this change is twofold:

1) Reduce redundant implementations of Type::getAsXXXType() methods. Most of
them are basically copy-and-paste.

2) By centralizing the implementation of the getAs<Type> logic we can more
smoothly move over to Doug Gregor's proposed canonical type smart pointer
scheme.

Along with this patch:

a) Removed 'Type::getAsPointerType()'; now clients use getAs<PointerType>.
b) Removed 'Type::getAsBlockPointerTypE()'; now clients use getAs<BlockPointerType>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76098 91177308-0d34-0410-b5e6-96231b3b80d8

34 files changed:
include/clang/AST/ExprCXX.h
include/clang/AST/Type.h
include/clang/Analysis/PathSensitive/MemRegion.h
lib/AST/ASTContext.cpp
lib/AST/DeclPrinter.cpp
lib/AST/Expr.cpp
lib/AST/ExprConstant.cpp
lib/AST/Type.cpp
lib/Analysis/BasicStore.cpp
lib/Analysis/CFRefCount.cpp
lib/Analysis/CheckNSError.cpp
lib/Analysis/GRExprEngine.cpp
lib/Analysis/RegionStore.cpp
lib/Analysis/Store.cpp
lib/CodeGen/CGBlocks.cpp
lib/CodeGen/CGExpr.cpp
lib/CodeGen/CGExprScalar.cpp
lib/CodeGen/CGObjCMac.cpp
lib/CodeGen/CodeGenFunction.cpp
lib/Frontend/RewriteBlocks.cpp
lib/Frontend/RewriteObjC.cpp
lib/Sema/SemaChecking.cpp
lib/Sema/SemaDeclAttr.cpp
lib/Sema/SemaDeclCXX.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaExprCXX.cpp
lib/Sema/SemaExprObjC.cpp
lib/Sema/SemaLookup.cpp
lib/Sema/SemaNamedCast.cpp
lib/Sema/SemaOverload.cpp
lib/Sema/SemaStmt.cpp
lib/Sema/SemaTemplate.cpp
lib/Sema/SemaTemplateDeduction.cpp
lib/Sema/SemaType.cpp

index 176786601719fbda0d48b5a69dae35807f04f693..ccfab7418a329c86d633803b6fe01f27bae4c4c3 100644 (file)
@@ -711,7 +711,7 @@ public:
 
   QualType getAllocatedType() const {
     assert(getType()->isPointerType());
-    return getType()->getAsPointerType()->getPointeeType();
+    return getType()->getAs<PointerType>()->getPointeeType();
   }
 
   FunctionDecl *getOperatorNew() const { return OperatorNew; }
index 33770f4f1a1a9c3371443ec8567285b3be27e4d4..3dee933fcfd6a489952897ff5c6e0a99586d0635 100644 (file)
@@ -431,8 +431,6 @@ public:
   const FunctionType *getAsFunctionType() const;
   const FunctionNoProtoType *getAsFunctionNoProtoType() const;
   const FunctionProtoType *getAsFunctionProtoType() const;
-  const PointerType *getAsPointerType() const;
-  const BlockPointerType *getAsBlockPointerType() const;
   const ReferenceType *getAsReferenceType() const;
   const LValueReferenceType *getAsLValueReferenceType() const;
   const RValueReferenceType *getAsRValueReferenceType() const;
@@ -457,6 +455,10 @@ public:
   const ObjCQualifiedInterfaceType *getAsObjCQualifiedInterfaceType() const;
   const TemplateTypeParmType *getAsTemplateTypeParmType() const;
 
+  // Member-template getAs<specific type>'.  This scheme will eventually
+  // replace the specific getAsXXXX methods above.
+  template <typename T> const T *getAs() const;
+  
   const TemplateSpecializationType *
     getAsTemplateSpecializationType() const;
   
@@ -2113,7 +2115,7 @@ inline const TypedefType* Type::getAsTypedefType() const {
   return dyn_cast<TypedefType>(this);
 }
 inline const ObjCInterfaceType *Type::getAsPointerToObjCInterfaceType() const {
-  if (const PointerType *PT = getAsPointerType())
+  if (const PointerType *PT = getAs<PointerType>())
     return PT->getPointeeType()->getAsObjCInterfaceType();
   return 0;
 }
@@ -2142,7 +2144,7 @@ inline bool Type::isRValueReferenceType() const {
   return isa<RValueReferenceType>(CanonicalType.getUnqualifiedType());
 }
 inline bool Type::isFunctionPointerType() const {
-  if (const PointerType* T = getAsPointerType())
+  if (const PointerType* T = getAs<PointerType>())
     return T->getPointeeType()->isFunctionType();
   else
     return false;
@@ -2247,6 +2249,25 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
                   Diagnostic::ak_qualtype);
   return DB;
 }
+  
+/// Member-template getAs<specific type>'.
+template <typename T> const T *Type::getAs() const {
+  // If this is directly a T type, return it.
+  if (const T *Ty = dyn_cast<T>(this))
+    return Ty;
+    
+  // If the canonical form of this type isn't the right kind, reject it.
+  if (!isa<T>(CanonicalType)) {
+    // Look through type qualifiers
+    if (isa<T>(CanonicalType.getUnqualifiedType()))
+      return CanonicalType.getUnqualifiedType()->getAs<T>();
+    return 0;
+  }
+    
+  // If this is a typedef for a pointer type, strip the typedef off without
+  // losing all typedef information.
+  return cast<T>(getDesugaredType());
+}  
 
 }  // end namespace clang
 
index 7f8c5c29037f06ec406206e0df4b01e4f4292dc9..46d01134226ec4460cf053ba4283db3dec269e1d 100644 (file)
@@ -357,7 +357,7 @@ public:
   }
 
   QualType getValueType(ASTContext&) const {
-    const PointerType* PTy = LValueType->getAsPointerType();
+    const PointerType* PTy = LValueType->getAs<PointerType>();
     assert(PTy);
     return PTy->getPointeeType();
   }
index b43aadb62e4ac7188762858bfa032aa6c3fe2fa5..f30927c4ecb2bbb7d097734d89ba9fb98a8be458 100644 (file)
@@ -1092,7 +1092,7 @@ QualType ASTContext::getObjCGCQualType(QualType T,
     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);
@@ -2779,7 +2779,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
     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
@@ -2794,8 +2794,8 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
     }
     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';
@@ -3035,7 +3035,7 @@ void ASTContext::setObjCSelType(QualType T) {
   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();
@@ -3159,7 +3159,7 @@ QualType::GCAttrTypes ASTContext::getObjCGCAttrKind(const QualType &Ty) const {
       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.
@@ -3519,8 +3519,8 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
   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))
@@ -3532,8 +3532,8 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
   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))
index 84ae72977e6e4eb88bd7d949828804187e3bd168..55d39e5cc8f6bb1b7f559499beaa3fc14aad38a5 100644 (file)
@@ -90,7 +90,7 @@ static QualType GetBaseType(QualType T) {
   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();
index 5d22f38770b48c451cc1fa3708a174ac0d6b4f25..74928bcd76aa8dcc2047ec94617ab23f8861afaf 100644 (file)
@@ -279,9 +279,9 @@ unsigned CallExpr::isBuiltinCall(ASTContext &Context) const {
 
 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();
@@ -430,7 +430,7 @@ Expr *InitListExpr::updateInit(unsigned Init, Expr *expr) {
 /// getFunctionType - Return the underlying function type for this block.
 ///
 const FunctionType *BlockExpr::getFunctionType() const {
-  return getType()->getAsBlockPointerType()->
+  return getType()->getAs<BlockPointerType>()->
                     getPointeeType()->getAsFunctionType();
 }
 
@@ -991,7 +991,7 @@ bool Expr::isOBJCGCCandidate(ASTContext &Ctx) const {
       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;
         
     }
@@ -1419,7 +1419,7 @@ bool Expr::isNullPointerConstant(ASTContext &Ctx) const
   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*
index 2c29347c519c5529c6167e0494ee3321ae820596..9473e4f48c1f780948f486b2d9e9854d1b50e460 100644 (file)
@@ -222,7 +222,7 @@ APValue LValueExprEvaluator::VisitMemberExpr(MemberExpr *E) {
   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())
@@ -351,7 +351,7 @@ APValue PointerExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
   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 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
 
       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())
index 18fa76bf25accbda608c4d8b82133ae09647929e..13d0cb03e8fdd2fb924dbc7925d8542c1f276e2a 100644 (file)
@@ -202,7 +202,7 @@ bool Type::isStructureType() const {
   return false;
 }
 bool Type::isVoidPointerType() const {
-  if (const PointerType *PT = getAsPointerType())
+  if (const PointerType *PT = getAs<PointerType>())
     return PT->getPointeeType()->isVoidType();
   return false;
 }
@@ -296,51 +296,15 @@ const FunctionProtoType *Type::getAsFunctionProtoType() const {
 }
 
 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();
 }
 
-const PointerType *Type::getAsPointerType() const {
-  // If this is directly a pointer type, return it.
-  if (const PointerType *PTy = dyn_cast<PointerType>(this))
-    return PTy;
-  
-  // If the canonical form of this type isn't the right kind, reject it.
-  if (!isa<PointerType>(CanonicalType)) {
-    // Look through type qualifiers
-    if (isa<PointerType>(CanonicalType.getUnqualifiedType()))
-      return CanonicalType.getUnqualifiedType()->getAsPointerType();
-    return 0;
-  }
-
-  // If this is a typedef for a pointer type, strip the typedef off without
-  // losing all typedef information.
-  return cast<PointerType>(getDesugaredType());
-}
-
-const BlockPointerType *Type::getAsBlockPointerType() const {
-  // If this is directly a block pointer type, return it.
-  if (const BlockPointerType *PTy = dyn_cast<BlockPointerType>(this))
-    return PTy;
-  
-  // If the canonical form of this type isn't the right kind, reject it.
-  if (!isa<BlockPointerType>(CanonicalType)) {
-    // Look through type qualifiers
-    if (isa<BlockPointerType>(CanonicalType.getUnqualifiedType()))
-      return CanonicalType.getUnqualifiedType()->getAsBlockPointerType();
-    return 0;
-  }
-  
-  // If this is a typedef for a block pointer type, strip the typedef off 
-  // without losing all typedef information.
-  return cast<BlockPointerType>(getDesugaredType());
-}
-
 const ReferenceType *Type::getAsReferenceType() const {
   // If this is directly a reference type, return it.
   if (const ReferenceType *RTy = dyn_cast<ReferenceType>(this))
@@ -429,7 +393,7 @@ bool Type::isVariablyModifiedType() const {
   // 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())
     return RT->getPointeeType()->isVariablyModifiedType();
index 7aa63c1c63012567924b62cf28324d98cfd742cf..99bfac2f50ae9ab54d16b0381421cf267de1d424 100644 (file)
@@ -251,7 +251,7 @@ SVal BasicStoreManager::getLValueElement(const GRState *state,
 static bool isHigherOrderRawPtr(QualType T, ASTContext &C) {
   bool foundPointer = false;
   while (1) {  
-    const PointerType *PT = T->getAsPointerType();
+    const PointerType *PT = T->getAs<PointerType>();
     if (!PT) {
       if (!foundPointer)
         return false;
index 3d2e3ac9a89ab9d00bc85ffaa1d46d248eaa0634..1fa3e57af0c36f9511b2de8a546775b24bc2ecdc 100644 (file)
@@ -248,7 +248,7 @@ static bool isRefType(QualType RetTy, const char* prefix,
     return false;
 
   // Is the type void*?
-  const PointerType* PT = RetTy->getAsPointerType();
+  const PointerType* PT = RetTy->getAs<PointerType>();
   if (!(PT->getPointeeType().getUnqualifiedType() == Ctx->VoidTy))
     return false;
 
@@ -1250,7 +1250,7 @@ RetainSummaryManager::updateSummaryFromAnnotations(RetainSummary &Summ,
       Summ.setRetEffect(RetEffect::MakeOwned(RetEffect::CF, true));
     }
   }
-  else if (RetTy->getAsPointerType()) {
+  else if (RetTy->getAs<PointerType>()) {
     if (FD->getAttr<CFReturnsRetainedAttr>()) {
       Summ.setRetEffect(RetEffect::MakeOwned(RetEffect::CF, true));
     }
@@ -1276,7 +1276,7 @@ RetainSummaryManager::updateSummaryFromAnnotations(RetainSummary &Summ,
   }
   
   if (!isTrackedLoc)
-    isTrackedLoc = MD->getResultType()->getAsPointerType() != NULL;
+    isTrackedLoc = MD->getResultType()->getAs<PointerType>() != NULL;
     
   if (isTrackedLoc && MD->getAttr<CFReturnsRetainedAttr>())
     Summ.setRetEffect(RetEffect::MakeOwned(RetEffect::CF, true));
index c1382d03774cf9bbe01b0220e7cc336402c4d840..4e8ba01e3e24e1bf56d127977219f8b9c7befc2d 100644 (file)
@@ -161,7 +161,7 @@ NSErrorCheck::CheckSignature(FunctionDecl& F, QualType& ResultTy,
 
 bool NSErrorCheck::CheckNSErrorArgument(QualType ArgTy) {
   
-  const PointerType* PPT = ArgTy->getAsPointerType();
+  const PointerType* PPT = ArgTy->getAs<PointerType>();
   if (!PPT)
     return false;
   
@@ -182,7 +182,7 @@ bool NSErrorCheck::CheckNSErrorArgument(QualType ArgTy) {
 
 bool NSErrorCheck::CheckCFErrorArgument(QualType ArgTy) {
   
-  const PointerType* PPT = ArgTy->getAsPointerType();
+  const PointerType* PPT = ArgTy->getAs<PointerType>();
   if (!PPT) return false;
   
   const TypedefType* TT = PPT->getPointeeType()->getAsTypedefType();
index f83e92acb3a686b9aae7bf8faa830047750550e2..b4bec5487757e463a89c7168aa9cb52175ddba03 100644 (file)
@@ -1274,7 +1274,7 @@ static bool EvalOSAtomicCompareAndSwap(ExplodedNodeSet<GRState>& Dst,
     return false;
   
   Expr *theValueExpr = CE->getArg(2);
-  const PointerType *theValueType = theValueExpr->getType()->getAsPointerType();
+  const PointerType *theValueType = theValueExpr->getType()->getAs<PointerType>();
   
   // theValueType not a pointer?
   if (!theValueType)
@@ -1382,7 +1382,7 @@ void GRExprEngine::VisitCall(CallExpr* CE, NodeTy* Pred,
   // Determine the type of function we're calling (if available).
   const FunctionProtoType *Proto = NULL;
   QualType FnType = CE->getCallee()->IgnoreParens()->getType();
-  if (const PointerType *FnTypePtr = FnType->getAsPointerType())
+  if (const PointerType *FnTypePtr = FnType->getAs<PointerType>())
     Proto = FnTypePtr->getPointeeType()->getAsFunctionProtoType();
 
   VisitCallRec(CE, Pred, AI, AE, Dst, Proto, /*ParamIdx=*/0);
index 0d2467f55e0c5b1840eb3e814be8486645714381..31623b998375e5328d707b147cec8ba085c3b3d9 100644 (file)
@@ -365,7 +365,7 @@ static bool isGenericPtr(ASTContext &Ctx, QualType Ty) {
     if (Ty->isVoidType())
       return true;
     
-    if (const PointerType *PT = Ty->getAsPointerType()) {
+    if (const PointerType *PT = Ty->getAs<PointerType>()) {
       Ty = PT->getPointeeType();
       continue;
     }
@@ -680,7 +680,7 @@ SVal RegionStoreManager::EvalBinOp(const GRState *state,
         T = Sym->getType(getContext());
       }
       
-      QualType EleTy = T->getAsPointerType()->getPointeeType();        
+      QualType EleTy = T->getAs<PointerType>()->getPointeeType();        
       SVal ZeroIdx = ValMgr.makeZeroArrayIndex();
       ER = MRMgr.getElementRegion(EleTy, ZeroIdx, SR, getContext());
       break;        
@@ -689,7 +689,7 @@ SVal RegionStoreManager::EvalBinOp(const GRState *state,
       // Get the alloca region's current cast type.
       const AllocaRegion *AR = cast<AllocaRegion>(MR);
       QualType T = *(state->get<RegionCasts>(AR));
-      QualType EleTy = T->getAsPointerType()->getPointeeType();
+      QualType EleTy = T->getAs<PointerType>()->getPointeeType();
       SVal ZeroIdx = ValMgr.makeZeroArrayIndex();
       ER = MRMgr.getElementRegion(EleTy, ZeroIdx, AR, getContext());
       break;      
@@ -865,7 +865,7 @@ SVal RegionStoreManager::Retrieve(const GRState *state, Loc L, QualType T) {
   // symbol value.
   if (const QualType *p = state->get<RegionCasts>(R)) {
     QualType T = *p;
-    RTy = T->getAsPointerType()->getPointeeType();
+    RTy = T->getAs<PointerType>()->getPointeeType();
   }
 
   // All other values are symbolic.
@@ -937,7 +937,7 @@ SVal RegionStoreManager::RetrieveElement(const GRState* state,
   // If the region is already cast to another type, use that type to create the
   // symbol value.
   if (const QualType *p = state->get<RegionCasts>(R))
-    Ty = (*p)->getAsPointerType()->getPointeeType();
+    Ty = (*p)->getAs<PointerType>()->getPointeeType();
 
   return ValMgr.getRegionValueSymbolValOrUnknown(R, Ty);
 }
@@ -976,7 +976,7 @@ SVal RegionStoreManager::RetrieveField(const GRState* state,
   // symbol value.
   if (const QualType *p = state->get<RegionCasts>(R)) {
     QualType tmp = *p;
-    Ty = tmp->getAsPointerType()->getPointeeType();
+    Ty = tmp->getAs<PointerType>()->getPointeeType();
   }
 
   // All other values are symbolic.
@@ -1009,7 +1009,7 @@ SVal RegionStoreManager::RetrieveObjCIvar(const GRState* state,
   // symbol value.
   if (const QualType *p = state->get<RegionCasts>(R)) {
     QualType tmp = *p;
-    Ty = tmp->getAsPointerType()->getPointeeType();
+    Ty = tmp->getAs<PointerType>()->getPointeeType();
   }
   
   // All other values are symbolic.
index b939a0df9ca72a7346367a6ad7318669ea764c41..9147f93eda2ba55db5c7e69f9dc45a94590ae916 100644 (file)
@@ -62,7 +62,7 @@ StoreManager::NewCastRegion(const GRState *state, const MemRegion* R,
 
   // Now assume we are casting from pointer to pointer. Other cases should
   // already be handled.
-  QualType PointeeTy = CastToTy->getAsPointerType()->getPointeeType();
+  QualType PointeeTy = CastToTy->getAs<PointerType>()->getPointeeType();
   
   // Process region cast according to the kind of the region being cast.
   switch (R->getKind()) {
@@ -243,7 +243,7 @@ const GRState *StoreManager::InvalidateRegion(const GRState *state,
   // If the region is cast to another type, use that type.  
   if (const QualType *CastTy = getCastType(state, R)) {
     assert(!(*CastTy)->isObjCObjectPointerType());
-    QualType NewT = (*CastTy)->getAsPointerType()->getPointeeType();    
+    QualType NewT = (*CastTy)->getAs<PointerType>()->getPointeeType();    
 
     // The only exception is if the original region had a location type as its
     // value type we always want to treat the region as binding to a location.
index 73200fe2ca379718565cd21c8bed714315030304..d8d1259587bc4f2fcb167a330e9e8d77107c851f 100644 (file)
@@ -388,7 +388,7 @@ const llvm::Type *BlockModule::getGenericExtendedBlockLiteralType() {
 
 RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E) {
   const BlockPointerType *BPT =
-    E->getCallee()->getType()->getAsBlockPointerType();
+    E->getCallee()->getType()->getAs<BlockPointerType>();
 
   llvm::Value *Callee = EmitScalarExpr(E->getCallee());
 
index 346b6703d371ae7084294b6158c999133702b37f..ab7b70e79301d12144e93a68d32778f8e46488b9 100644 (file)
@@ -934,7 +934,7 @@ EmitExtVectorElementExpr(const ExtVectorElementExpr *E) {
     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());
   }
@@ -976,7 +976,7 @@ LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) {
   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();
@@ -1317,7 +1317,7 @@ RValue CodeGenFunction::EmitCall(llvm::Value *Callee, QualType CalleeType,
   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;
index e18e08b5c5ac2b9a71df56a91eb0c62e1a1a9e4d..0316116631ad8ca48acd3c4a5525fe0a8eefd5da 100644 (file)
@@ -679,7 +679,7 @@ Value *ScalarExprEmitter::VisitPrePostIncDec(const UnaryOperator *E,
   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");
   }
@@ -1002,13 +1002,13 @@ Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &Ops) {
   }
 
   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) {
@@ -1016,7 +1016,7 @@ Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &Ops) {
     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;
@@ -1073,7 +1073,7 @@ Value *ScalarExprEmitter::EmitSub(const BinOpInfo &Ops) {
   }
 
   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
index 661f75a057ca6b77e48fa3aa5a6cd0ca7f3dc922..bb80be961b26b152143e4e1ddfc8431ae3f00754 100644 (file)
@@ -3008,7 +3008,7 @@ static QualType::GCAttrTypes GetGCAttrTypeForType(ASTContext &Ctx,
   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;
index a72f2ae71062c55b44670da8cff9fcfcb58eb4c1..842bf8be49b7ec484b2792e6764253c601defc08 100644 (file)
@@ -490,7 +490,7 @@ llvm::Value *CodeGenFunction::EmitVLASize(QualType Ty)
     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!");
index bc855fa87912d9be91728bc04c691f4772ff3ad3..a7b5e3d6868cac7d3b6c269c4b043de813e90b7c 100644 (file)
@@ -130,7 +130,7 @@ public:
         OCT == Context->getCanonicalType(Context->getObjCClassType()))
       return true;
       
-    if (const PointerType *PT = OCT->getAsPointerType()) {
+    if (const PointerType *PT = OCT->getAs<PointerType>()) {
       if (isa<ObjCInterfaceType>(PT->getPointeeType()) || 
           PT->getPointeeType()->isObjCQualifiedIdType())
         return true;
@@ -684,13 +684,13 @@ std::string RewriteBlocks::SynthesizeBlockCall(CallExpr *Exp) {
   
   if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Exp->getCallee())) {
     closureName = DRE->getDecl()->getNameAsCString();
-    CPT = DRE->getType()->getAsBlockPointerType();
+    CPT = DRE->getType()->getAs<BlockPointerType>();
   } else if (BlockDeclRefExpr *CDRE = dyn_cast<BlockDeclRefExpr>(Exp->getCallee())) {
     closureName = CDRE->getDecl()->getNameAsCString();
-    CPT = CDRE->getType()->getAsBlockPointerType();
+    CPT = CDRE->getType()->getAs<BlockPointerType>();
   } else if (MemberExpr *MExpr = dyn_cast<MemberExpr>(Exp->getCallee())) {
     closureName = MExpr->getMemberDecl()->getNameAsCString();
-    CPT = MExpr->getType()->getAsBlockPointerType();
+    CPT = MExpr->getType()->getAs<BlockPointerType>();
   } else {
     assert(1 && "RewriteBlockClass: Bad type");
   }
@@ -813,11 +813,11 @@ void RewriteBlocks::RewriteBlockPointerFunctionArgs(FunctionDecl *FD) {
 
 bool RewriteBlocks::PointerTypeTakesAnyBlockArguments(QualType QT) {
   const FunctionProtoType *FTP;
-  const PointerType *PT = QT->getAsPointerType();
+  const PointerType *PT = QT->getAs<PointerType>();
   if (PT) {
     FTP = PT->getPointeeType()->getAsFunctionProtoType();
   } else {
-    const BlockPointerType *BPT = QT->getAsBlockPointerType();
+    const BlockPointerType *BPT = QT->getAs<BlockPointerType>();
     assert(BPT && "BlockPointerTypeTakeAnyBlockArguments(): not a block pointer type");
     FTP = BPT->getPointeeType()->getAsFunctionProtoType();
   }
@@ -1068,7 +1068,7 @@ void RewriteBlocks::RewriteFunctionProtoType(QualType funcType, NamedDecl *D) {
 }
 
 void RewriteBlocks::CheckFunctionPointerDecl(QualType funcType, NamedDecl *ND) {
-  const PointerType *PT = funcType->getAsPointerType();
+  const PointerType *PT = funcType->getAs<PointerType>();
   if (PT && PointerTypeTakesAnyBlockArguments(funcType))
     RewriteFunctionProtoType(PT->getPointeeType(), ND);
 }
index 1bc7451a17c24faef2245b9f607e6fff275ca648..de45e1a2bea722f249c853978b3cce6fa1b0820f 100644 (file)
@@ -354,7 +354,7 @@ namespace {
           OCT == Context->getCanonicalType(Context->getObjCClassType()))
         return true;
         
-      if (const PointerType *PT = OCT->getAsPointerType()) {
+      if (const PointerType *PT = OCT->getAs<PointerType>()) {
         if (isa<ObjCInterfaceType>(PT->getPointeeType()) || 
             PT->getPointeeType()->isObjCQualifiedIdType())
           return true;
@@ -394,7 +394,7 @@ void RewriteObjC::RewriteBlocksInFunctionProtoType(QualType funcType,
 }
 
 void RewriteObjC::CheckFunctionPointerDecl(QualType funcType, NamedDecl *ND) {
-  const PointerType *PT = funcType->getAsPointerType();
+  const PointerType *PT = funcType->getAs<PointerType>();
   if (PT && PointerTypeTakesAnyBlockArguments(funcType))
     RewriteBlocksInFunctionProtoType(PT->getPointeeType(), ND);
 }
@@ -864,9 +864,9 @@ void RewriteObjC::RewriteObjCMethodDecl(ObjCMethodDecl *OMD,
     // syntax (where a decaration models use).
     QualType retType = OMD->getResultType();
     QualType PointeeTy;
-    if (const PointerType* PT = retType->getAsPointerType())
+    if (const PointerType* PT = retType->getAs<PointerType>())
       PointeeTy = PT->getPointeeType();
-    else if (const BlockPointerType *BPT = retType->getAsBlockPointerType())
+    else if (const BlockPointerType *BPT = retType->getAs<BlockPointerType>())
       PointeeTy = BPT->getPointeeType();
     if ((FPRetType = PointeeTy->getAsFunctionType())) {
       ResultStr += FPRetType->getResultType().getAsString();
@@ -939,7 +939,7 @@ void RewriteObjC::RewriteObjCMethodDecl(ObjCMethodDecl *OMD,
       std::string Name = PDecl->getNameAsString();
       if (isTopLevelBlockPointerType(PDecl->getType())) {
         // Make sure we convert "t (^)(...)" to "t (*)(...)".
-        const BlockPointerType *BPT = PDecl->getType()->getAsBlockPointerType();
+        const BlockPointerType *BPT = PDecl->getType()->getAs<BlockPointerType>();
         Context->getPointerType(BPT->getPointeeType()).getAsStringInternal(Name,
                                                         Context->PrintingPolicy);
       } else
@@ -1138,7 +1138,7 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
                                           SourceLocation OrigStart) {
   ObjCIvarDecl *D = IV->getDecl();
   if (CurMethodDef) {
-    if (const PointerType *pType = IV->getBase()->getType()->getAsPointerType()) {
+    if (const PointerType *pType = IV->getBase()->getType()->getAs<PointerType>()) {
       ObjCInterfaceType *iFaceDecl =
         dyn_cast<ObjCInterfaceType>(pType->getPointeeType());
       // lookup which class implements the instance variable.
@@ -1184,7 +1184,7 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
       
     // Explicit ivar refs need to have a cast inserted.
     // FIXME: consider sharing some of this code with the code above.
-    if (const PointerType *pType = IV->getBase()->getType()->getAsPointerType()) {
+    if (const PointerType *pType = IV->getBase()->getType()->getAs<PointerType>()) {
       ObjCInterfaceType *iFaceDecl = dyn_cast<ObjCInterfaceType>(pType->getPointeeType());
       // lookup which class implements the instance variable.
       ObjCInterfaceDecl *clsDeclared = 0;
@@ -1608,7 +1608,7 @@ Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {
         buf += "1) { ";
         ReplaceText(startLoc, lParenLoc-startBuf+1, buf.c_str(), buf.size());
         sawIdTypedCatch = true;
-      } else if (const PointerType *pType = t->getAsPointerType()) { 
+      } else if (const PointerType *pType = t->getAs<PointerType>()) { 
         ObjCInterfaceType *cls; // Should be a pointer to a class.
         
         cls = dyn_cast<ObjCInterfaceType>(pType->getPointeeType().getTypePtr());
@@ -1824,7 +1824,7 @@ bool RewriteObjC::needToScanForQualifiers(QualType T) {
   if (T->isObjCQualifiedIdType())
     return true;
   
-  if (const PointerType *pType = T->getAsPointerType()) {
+  if (const PointerType *pType = T->getAs<PointerType>()) {
     Type *pointeeType = pType->getPointeeType().getTypePtr();
     if (isa<ObjCQualifiedInterfaceType>(pointeeType))
       return true; // we have "Class <Protocol> *".
@@ -2485,7 +2485,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
                      : (*PI)->getType();
       // Make sure we convert "t (^)(...)" to "t (*)(...)".
       if (isTopLevelBlockPointerType(t)) {
-        const BlockPointerType *BPT = t->getAsBlockPointerType();
+        const BlockPointerType *BPT = t->getAs<BlockPointerType>();
         t = Context->getPointerType(BPT->getPointeeType());
       }
       ArgTypes.push_back(t);
@@ -3890,13 +3890,13 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp) {
   
   if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Exp->getCallee())) {
     closureName = DRE->getDecl()->getNameAsCString();
-    CPT = DRE->getType()->getAsBlockPointerType();
+    CPT = DRE->getType()->getAs<BlockPointerType>();
   } else if (BlockDeclRefExpr *CDRE = dyn_cast<BlockDeclRefExpr>(Exp->getCallee())) {
     closureName = CDRE->getDecl()->getNameAsCString();
-    CPT = CDRE->getType()->getAsBlockPointerType();
+    CPT = CDRE->getType()->getAs<BlockPointerType>();
   } else if (MemberExpr *MExpr = dyn_cast<MemberExpr>(Exp->getCallee())) {
     closureName = MExpr->getMemberDecl()->getNameAsCString();
-    CPT = MExpr->getType()->getAsBlockPointerType();
+    CPT = MExpr->getType()->getAs<BlockPointerType>();
   } else {
     assert(1 && "RewriteBlockClass: Bad type");
   }
@@ -3922,7 +3922,7 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp) {
       QualType t = *I;
       // Make sure we convert "t (^)(...)" to "t (*)(...)".
       if (isTopLevelBlockPointerType(t)) {
-        const BlockPointerType *BPT = t->getAsBlockPointerType();
+        const BlockPointerType *BPT = t->getAs<BlockPointerType>();
         t = Context->getPointerType(BPT->getPointeeType());
       }
       ArgTypes.push_back(t);
@@ -4063,11 +4063,11 @@ void RewriteObjC::RewriteBlockPointerFunctionArgs(FunctionDecl *FD) {
 
 bool RewriteObjC::PointerTypeTakesAnyBlockArguments(QualType QT) {
   const FunctionProtoType *FTP;
-  const PointerType *PT = QT->getAsPointerType();
+  const PointerType *PT = QT->getAs<PointerType>();
   if (PT) {
     FTP = PT->getPointeeType()->getAsFunctionProtoType();
   } else {
-    const BlockPointerType *BPT = QT->getAsBlockPointerType();
+    const BlockPointerType *BPT = QT->getAs<BlockPointerType>();
     assert(BPT && "BlockPointerTypeTakeAnyBlockArguments(): not a block pointer type");
     FTP = BPT->getPointeeType()->getAsFunctionProtoType();
   }
index 4eed01872246c205b1498b4a089a799749121cdb..6256872b5e6b75de9eea20d9cd33340e6df64270 100644 (file)
@@ -205,7 +205,7 @@ Sema::CheckBlockCall(NamedDecl *NDecl, CallExpr *TheCall) {
       bool HasVAListArg = Format->getFirstArg() == 0;
       if (!HasVAListArg) {
         const FunctionType *FT = 
-          Ty->getAsBlockPointerType()->getPointeeType()->getAsFunctionType();
+          Ty->getAs<BlockPointerType>()->getPointeeType()->getAsFunctionType();
         if (const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FT))
           HasVAListArg = !Proto->isVariadic();
       }
@@ -241,7 +241,7 @@ bool Sema::SemaBuiltinAtomicOverloaded(CallExpr *TheCall) {
     return Diag(DRE->getLocStart(), diag::err_atomic_builtin_must_be_pointer)
              << FirstArg->getType() << FirstArg->getSourceRange();
   
-  QualType ValType = FirstArg->getType()->getAsPointerType()->getPointeeType();
+  QualType ValType = FirstArg->getType()->getAs<PointerType>()->getPointeeType();
   if (!ValType->isIntegerType() && !ValType->isPointerType() && 
       !ValType->isBlockPointerType())
     return Diag(DRE->getLocStart(),
@@ -344,7 +344,7 @@ bool Sema::SemaBuiltinAtomicOverloaded(CallExpr *TheCall) {
                                            TUScope, false, DRE->getLocStart()));
   const FunctionProtoType *BuiltinFT =
     NewBuiltinDecl->getType()->getAsFunctionProtoType();
-  ValType = BuiltinFT->getArgType(0)->getAsPointerType()->getPointeeType();
+  ValType = BuiltinFT->getArgType(0)->getAs<PointerType>()->getPointeeType();
   
   // If the first type needs to be converted (e.g. void** -> int*), do it now.
   if (BuiltinFT->getArgType(0) != FirstArg->getType()) {
@@ -750,7 +750,7 @@ bool Sema::SemaCheckStringLiteral(const Expr *E, const CallExpr *TheCall,
       if (const ArrayType *AT = Context.getAsArrayType(T)) {
         isConstant = AT->getElementType().isConstant(Context);
       }
-      else if (const PointerType *PT = T->getAsPointerType()) {
+      else if (const PointerType *PT = T->getAs<PointerType>()) {
         isConstant = T.isConstant(Context) && 
                      PT->getPointeeType().isConstant(Context);
       }
index 09cb96b900b6f00d14fa8000f6172fe500681da5..5d05b4c444d39f8110c79265515608811b15310c 100644 (file)
@@ -36,9 +36,9 @@ static const FunctionType *getFunctionType(Decl *d, bool blocksToo = true) {
     return 0;
   
   if (Ty->isFunctionPointerType())
-    Ty = Ty->getAsPointerType()->getPointeeType();
+    Ty = Ty->getAs<PointerType>()->getPointeeType();
   else if (blocksToo && Ty->isBlockPointerType())
-    Ty = Ty->getAsBlockPointerType()->getPointeeType();
+    Ty = Ty->getAs<BlockPointerType>()->getPointeeType();
 
   return Ty->getAsFunctionType();
 }
@@ -133,7 +133,7 @@ static inline bool isNSStringType(QualType T, ASTContext &Ctx) {
 }
 
 static inline bool isCFStringType(QualType T, ASTContext &Ctx) {
-  const PointerType *PT = T->getAsPointerType();
+  const PointerType *PT = T->getAs<PointerType>();
   if (!PT)
     return false;
 
@@ -632,7 +632,7 @@ static void HandleObjCNSObject(Decl *D, const AttributeList &Attr, Sema &S) {
   if (TypedefDecl *TD = dyn_cast<TypedefDecl>(D)) {
     QualType T = TD->getUnderlyingType();
     if (!T->isPointerType() ||
-        !T->getAsPointerType()->getPointeeType()->isRecordType()) {
+        !T->getAs<PointerType>()->getPointeeType()->isRecordType()) {
       S.Diag(TD->getLocation(), diag::err_nsobject_attribute);
       return;
     }
@@ -751,7 +751,7 @@ static void HandleSentinelAttr(Decl *d, const AttributeList &Attr, Sema &S) {
     QualType Ty = V->getType();
     if (Ty->isBlockPointerType() || Ty->isFunctionPointerType()) {
       const FunctionType *FT = Ty->isFunctionPointerType() ? getFunctionType(d) 
-        : Ty->getAsBlockPointerType()->getPointeeType()->getAsFunctionType();
+        : Ty->getAs<BlockPointerType>()->getPointeeType()->getAsFunctionType();
       if (!cast<FunctionProtoType>(FT)->isVariadic()) {
         int m = Ty->isFunctionPointerType() ? 0 : 1;
         S.Diag(Attr.getLoc(), diag::warn_attribute_sentinel_not_variadic) << m;
@@ -1147,7 +1147,7 @@ static void HandleFormatArgAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   if (not_nsstring_type &&
       !isCFStringType(Ty, S.Context) &&
       (!Ty->isPointerType() ||
-       !Ty->getAsPointerType()->getPointeeType()->isCharType())) {
+       !Ty->getAs<PointerType>()->getPointeeType()->isCharType())) {
     // FIXME: Should highlight the actual expression that has the wrong type.
     S.Diag(Attr.getLoc(), diag::err_format_attribute_not)
     << (not_nsstring_type ? "a string type" : "an NSString") 
@@ -1158,7 +1158,7 @@ static void HandleFormatArgAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   if (!isNSStringType(Ty, S.Context) &&
       !isCFStringType(Ty, S.Context) &&
       (!Ty->isPointerType() ||
-       !Ty->getAsPointerType()->getPointeeType()->isCharType())) {
+       !Ty->getAs<PointerType>()->getPointeeType()->isCharType())) {
     // FIXME: Should highlight the actual expression that has the wrong type.
     S.Diag(Attr.getLoc(), diag::err_format_attribute_result_not)
     << (not_nsstring_type ? "string type" : "NSString") 
@@ -1266,7 +1266,7 @@ static void HandleFormatAttr(Decl *d, const AttributeList &Attr, Sema &S) {
       return;
     }    
   } else if (!Ty->isPointerType() ||
-             !Ty->getAsPointerType()->getPointeeType()->isCharType()) {
+             !Ty->getAs<PointerType>()->getPointeeType()->isCharType()) {
     // FIXME: Should highlight the actual expression that has the wrong type.
     S.Diag(Attr.getLoc(), diag::err_format_attribute_not)
       << "a string type" << IdxExpr->getSourceRange();
@@ -1703,7 +1703,7 @@ static void HandleNSReturnsRetainedAttr(Decl *d, const AttributeList &Attr,
     return;
   }
   
-  if (!(S.Context.isObjCNSObjectType(RetTy) || RetTy->getAsPointerType()
+  if (!(S.Context.isObjCNSObjectType(RetTy) || RetTy->getAs<PointerType>()
         || RetTy->getAsObjCObjectPointerType())) {
     S.Diag(Attr.getLoc(), diag::warn_ns_attribute_wrong_return_type)
       << Attr.getName();
index c62858ac73028c0994343800bd38c95408570b73..21daa8fc030da2bbaccc946bf63cc24682592a10 100644 (file)
@@ -1009,9 +1009,9 @@ bool Sema::RequireNonAbstractType(SourceLocation Loc, QualType T,
     return RequireNonAbstractType(Loc, AT->getElementType(), DiagID, SelID,
                                   CurrentRD);
   
-  if (const PointerType *PT = T->getAsPointerType()) {
+  if (const PointerType *PT = T->getAs<PointerType>()) {
     // Find the innermost pointer type.
-    while (const PointerType *T = PT->getPointeeType()->getAsPointerType())
+    while (const PointerType *T = PT->getPointeeType()->getAs<PointerType>())
       PT = T;
     
     if (const ArrayType *AT = Context.getAsArrayType(PT->getPointeeType()))
@@ -3079,7 +3079,7 @@ VarDecl *Sema::BuildExceptionDeclaration(Scope *S, QualType ExDeclType,
   QualType BaseType = ExDeclType;
   int Mode = 0; // 0 for direct type, 1 for pointer, 2 for reference
   unsigned DK = diag::err_catch_incomplete;
-  if (const PointerType *Ptr = BaseType->getAsPointerType()) {
+  if (const PointerType *Ptr = BaseType->getAs<PointerType>()) {
     BaseType = Ptr->getPointeeType();
     Mode = 1;
     DK = diag::err_catch_incomplete_ptr;
index 1304558042808a5a37e656644da6412fe8672427..a229791ea96862c19d341f17ffcf35be68c8712c 100644 (file)
@@ -133,8 +133,8 @@ void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
     QualType Ty = V->getType();
     if (Ty->isBlockPointerType() || Ty->isFunctionPointerType()) {
       const FunctionType *FT = Ty->isFunctionPointerType() 
-      ? Ty->getAsPointerType()->getPointeeType()->getAsFunctionType()
-      : Ty->getAsBlockPointerType()->getPointeeType()->getAsFunctionType();
+      ? Ty->getAs<PointerType>()->getPointeeType()->getAsFunctionType()
+      : Ty->getAs<BlockPointerType>()->getPointeeType()->getAsFunctionType();
       if (const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FT)) {
         unsigned NumArgsInProto = Proto->getNumArgs();
         unsigned k;
@@ -756,7 +756,7 @@ Sema::BuildAnonymousStructUnionMemberReference(SourceLocation Loc,
     // 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->getAsPointerType()) {
+    if (const PointerType *ObjectPtr = ObjectType->getAs<PointerType>()) {
       BaseObjectIsPointer = true;
       ObjectType = ObjectPtr->getPointeeType();
     }
@@ -1835,11 +1835,11 @@ Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc,
     BaseExpr = LHSExp;
     IndexExpr = RHSExp;
     ResultType = Context.DependentTy;
-  } else if (const PointerType *PTy = LHSTy->getAsPointerType()) {
+  } else if (const PointerType *PTy = LHSTy->getAs<PointerType>()) {
     BaseExpr = LHSExp;
     IndexExpr = RHSExp;
     ResultType = PTy->getPointeeType();
-  } else if (const PointerType *PTy = RHSTy->getAsPointerType()) {
+  } else if (const PointerType *PTy = RHSTy->getAs<PointerType>()) {
      // Handle the uncommon case of "123[Ptr]".
     BaseExpr = RHSExp;
     IndexExpr = LHSExp;
@@ -1874,7 +1874,7 @@ Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc,
 
     BaseExpr = LHSExp;
     IndexExpr = RHSExp;
-    ResultType = LHSTy->getAsPointerType()->getPointeeType();
+    ResultType = LHSTy->getAs<PointerType>()->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 @@ Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc,
 
     BaseExpr = RHSExp;
     IndexExpr = LHSExp;
-    ResultType = RHSTy->getAsPointerType()->getPointeeType();
+    ResultType = RHSTy->getAs<PointerType>()->getPointeeType();
   } else {
     return ExprError(Diag(LLoc, diag::err_typecheck_subscript_value)
        << LHSExp->getSourceRange() << RHSExp->getSourceRange());
@@ -2098,7 +2098,7 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
                                                          OpLoc, 
                                                      DeclarationName(&Member),
                                                          MemberLoc));
-    else if (const PointerType *PT = BaseType->getAsPointerType())
+    else if (const PointerType *PT = BaseType->getAs<PointerType>())
       BaseType = PT->getPointeeType();
     else if (BaseType->isObjCObjectPointerType())
       ;
@@ -2119,7 +2119,7 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
       // 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->getAsPointerType();
+      const PointerType *PT = BaseType->getAs<PointerType>();
 
       if (!PT || (getLangOptions().ObjC1 && 
                   !PT->getPointeeType()->isRecordType()))
@@ -2500,7 +2500,7 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
   if (BaseType == Context.OverloadTy || 
       BaseType->isFunctionType() ||
       (BaseType->isPointerType() && 
-       BaseType->getAsPointerType()->isFunctionType())) {
+       BaseType->getAs<PointerType>()->isFunctionType())) {
     SourceLocation Loc = PP.getLocForEndOfToken(BaseExpr->getLocEnd());
     Diag(Loc, diag::note_member_reference_needs_call)
       << CodeModificationHint::CreateInsertion(Loc, "()");
@@ -2794,13 +2794,13 @@ Sema::ActOnCallExpr(Scope *S, ExprArg fn, SourceLocation LParenLoc,
   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()->getAsPointerType();
+    const PointerType *PT = Fn->getType()->getAs<PointerType>();
     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()->getAsBlockPointerType()->getPointeeType()->
+    FuncT = Fn->getType()->getAs<BlockPointerType>()->getPointeeType()->
                 getAsFunctionType();
   }
   if (FuncT == 0)
@@ -3131,8 +3131,8 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS,
       return LHSTy;
     }
     // The block pointer types aren't identical, continue checking.
-    QualType lhptee = LHSTy->getAsBlockPointerType()->getPointeeType();
-    QualType rhptee = RHSTy->getAsBlockPointerType()->getPointeeType();
+    QualType lhptee = LHSTy->getAs<BlockPointerType>()->getPointeeType();
+    QualType rhptee = RHSTy->getAs<BlockPointerType>()->getPointeeType();
 
     if (!Context.typesAreCompatible(lhptee.getUnqualifiedType(),
                                     rhptee.getUnqualifiedType())) {
@@ -3206,8 +3206,8 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS,
   // 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->getAsPointerType()->getPointeeType();
-    QualType rhptee = RHSTy->getAsPointerType()->getPointeeType();
+    QualType lhptee = LHSTy->getAs<PointerType>()->getPointeeType();
+    QualType rhptee = RHSTy->getAs<PointerType>()->getPointeeType();
 
     // ignore qualifiers on void (C99 6.5.15p3, clause 6)
     if (lhptee->isVoidType() && rhptee->isIncompleteOrObjectType()) {
@@ -3313,8 +3313,8 @@ Sema::CheckPointerTypesForAssignment(QualType lhsType, QualType rhsType) {
   QualType lhptee, rhptee;
 
   // get the "pointed to" type (ignoring qualifiers at the top level)
-  lhptee = lhsType->getAsPointerType()->getPointeeType();
-  rhptee = rhsType->getAsPointerType()->getPointeeType();
+  lhptee = lhsType->getAs<PointerType>()->getPointeeType();
+  rhptee = rhsType->getAs<PointerType>()->getPointeeType();
 
   return CheckPointeeTypesForAssignment(lhptee, rhptee);
 }
@@ -3396,8 +3396,8 @@ Sema::CheckBlockPointerTypesForAssignment(QualType lhsType,
   QualType lhptee, rhptee;
 
   // get the "pointed to" type (ignoring qualifiers at the top level)
-  lhptee = lhsType->getAsBlockPointerType()->getPointeeType();
-  rhptee = rhsType->getAsBlockPointerType()->getPointeeType();
+  lhptee = lhsType->getAs<BlockPointerType>()->getPointeeType();
+  rhptee = rhsType->getAs<BlockPointerType>()->getPointeeType();
 
   // make sure we operate on the canonical type
   lhptee = Context.getCanonicalType(lhptee);
@@ -3496,12 +3496,12 @@ Sema::CheckAssignmentConstraints(QualType lhsType, QualType rhsType) {
 
     if (isa<ObjCObjectPointerType>(rhsType)) {
       QualType rhptee = rhsType->getAsObjCObjectPointerType()->getPointeeType();
-      QualType lhptee = lhsType->getAsPointerType()->getPointeeType();
+      QualType lhptee = lhsType->getAs<PointerType>()->getPointeeType();
       return CheckPointeeTypesForAssignment(lhptee, rhptee);
     }
 
-    if (rhsType->getAsBlockPointerType()) {
-      if (lhsType->getAsPointerType()->getPointeeType()->isVoidType())
+    if (rhsType->getAs<BlockPointerType>()) {
+      if (lhsType->getAs<PointerType>()->getPointeeType()->isVoidType())
         return Compatible;
 
       // Treat block pointers as objects.
@@ -3522,7 +3522,7 @@ Sema::CheckAssignmentConstraints(QualType lhsType, QualType rhsType) {
     if (rhsType->isBlockPointerType())
       return CheckBlockPointerTypesForAssignment(lhsType, rhsType);
 
-    if (const PointerType *RHSPT = rhsType->getAsPointerType()) {
+    if (const PointerType *RHSPT = rhsType->getAs<PointerType>()) {
       if (RHSPT->getPointeeType()->isVoidType())
         return Compatible;
     }
@@ -3535,7 +3535,7 @@ Sema::CheckAssignmentConstraints(QualType lhsType, QualType rhsType) {
 
     if (isa<PointerType>(rhsType)) {
       QualType lhptee = lhsType->getAsObjCObjectPointerType()->getPointeeType();
-      QualType rhptee = rhsType->getAsPointerType()->getPointeeType();
+      QualType rhptee = rhsType->getAs<PointerType>()->getPointeeType();
       return CheckPointeeTypesForAssignment(lhptee, rhptee);
     }
     if (rhsType->isObjCObjectPointerType()) {
@@ -3545,7 +3545,7 @@ Sema::CheckAssignmentConstraints(QualType lhsType, QualType rhsType) {
       QualType rhptee = rhsType->getAsObjCObjectPointerType()->getPointeeType();
       return CheckPointeeTypesForAssignment(lhptee, rhptee);
     }
-    if (const PointerType *RHSPT = rhsType->getAsPointerType()) {
+    if (const PointerType *RHSPT = rhsType->getAs<PointerType>()) {
       if (RHSPT->getPointeeType()->isVoidType())
         return Compatible;
     }
@@ -3566,7 +3566,7 @@ Sema::CheckAssignmentConstraints(QualType lhsType, QualType rhsType) {
       return CheckPointerTypesForAssignment(lhsType, rhsType);
 
     if (isa<BlockPointerType>(lhsType) &&
-        rhsType->getAsPointerType()->getPointeeType()->isVoidType())
+        rhsType->getAs<PointerType>()->getPointeeType()->isVoidType())
       return Compatible;
     return Incompatible;
   }
@@ -3580,11 +3580,11 @@ Sema::CheckAssignmentConstraints(QualType lhsType, QualType rhsType) {
 
     if (isa<PointerType>(lhsType)) {
       QualType rhptee = lhsType->getAsObjCObjectPointerType()->getPointeeType();
-      QualType lhptee = rhsType->getAsPointerType()->getPointeeType();
+      QualType lhptee = rhsType->getAs<PointerType>()->getPointeeType();
       return CheckPointeeTypesForAssignment(lhptee, rhptee);
     }
     if (isa<BlockPointerType>(lhsType) &&
-        rhsType->getAsPointerType()->getPointeeType()->isVoidType())
+        rhsType->getAs<PointerType>()->getPointeeType()->isVoidType())
       return Compatible;
     return Incompatible;
   }
@@ -3636,7 +3636,7 @@ Sema::CheckTransparentUnionArgumentConstraints(QualType ArgType, Expr *&rExpr) {
       // 1) void pointer
       // 2) null pointer constant
       if (FromType->isPointerType())
-        if (FromType->getAsPointerType()->getPointeeType()->isVoidType()) {
+        if (FromType->getAs<PointerType>()->getPointeeType()->isVoidType()) {
           ImpCastExprToType(rExpr, it->getType());
           InitField = *it;
           break;
@@ -3973,7 +3973,7 @@ QualType Sema::CheckSubtractionOperands(Expr *&lex, Expr *&rex,
     }
 
     // Handle pointer-pointer subtractions.
-    if (const PointerType *RHSPTy = rex->getType()->getAsPointerType()) {
+    if (const PointerType *RHSPTy = rex->getType()->getAs<PointerType>()) {
       QualType rpointee = RHSPTy->getPointeeType();
 
       // RHS must be a completely-type object type.
@@ -4168,9 +4168,9 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
   // errors (when -pedantic-errors is enabled).
   if (lType->isPointerType() && rType->isPointerType()) { // C99 6.5.8p2
     QualType LCanPointeeTy =
-      Context.getCanonicalType(lType->getAsPointerType()->getPointeeType());
+      Context.getCanonicalType(lType->getAs<PointerType>()->getPointeeType());
     QualType RCanPointeeTy =
-      Context.getCanonicalType(rType->getAsPointerType()->getPointeeType());
+      Context.getCanonicalType(rType->getAs<PointerType>()->getPointeeType());
 
     if (isRelational) {
       if (lType->isFunctionPointerType() || rType->isFunctionPointerType()) {
@@ -4240,8 +4240,8 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
   }
   // Handle block pointer types.
   if (!isRelational && lType->isBlockPointerType() && rType->isBlockPointerType()) {
-    QualType lpointee = lType->getAsBlockPointerType()->getPointeeType();
-    QualType rpointee = rType->getAsBlockPointerType()->getPointeeType();
+    QualType lpointee = lType->getAs<BlockPointerType>()->getPointeeType();
+    QualType rpointee = rType->getAs<BlockPointerType>()->getPointeeType();
 
     if (!LHSIsNull && !RHSIsNull &&
         !Context.typesAreCompatible(lpointee, rpointee)) {
@@ -4256,9 +4256,9 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
       && ((lType->isBlockPointerType() && rType->isPointerType())
           || (lType->isPointerType() && rType->isBlockPointerType()))) {
     if (!LHSIsNull && !RHSIsNull) {
-      if (!((rType->isPointerType() && rType->getAsPointerType()
+      if (!((rType->isPointerType() && rType->getAs<PointerType>()
              ->getPointeeType()->isVoidType())
-            || (lType->isPointerType() && lType->getAsPointerType()
+            || (lType->isPointerType() && lType->getAs<PointerType>()
                 ->getPointeeType()->isVoidType())))
         Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
           << lType << rType << lex->getSourceRange() << rex->getSourceRange();
@@ -4269,8 +4269,8 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
 
   if ((lType->isObjCObjectPointerType() || rType->isObjCObjectPointerType())) {
     if (lType->isPointerType() || rType->isPointerType()) {
-      const PointerType *LPT = lType->getAsPointerType();
-      const PointerType *RPT = rType->getAsPointerType();
+      const PointerType *LPT = lType->getAs<PointerType>();
+      const PointerType *RPT = rType->getAs<PointerType>();
       bool LPtrToVoid = LPT ?
         Context.getCanonicalType(LPT->getPointeeType())->isVoidType() : false;
       bool RPtrToVoid = RPT ?
@@ -4798,7 +4798,7 @@ QualType Sema::CheckIndirectionOperand(Expr *Op, SourceLocation OpLoc) {
   // 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->getAsPointerType())
+  if (const PointerType *PT = Ty->getAs<PointerType>())
     return PT->getPointeeType();
 
   if (const ObjCObjectPointerType *OPT = Ty->getAsObjCObjectPointerType())
index 144dc5095f8d63153439d57055bdb5cc77cd933d..b3de60ad8a5381ba90492bc3705b6744b75fddad 100644 (file)
@@ -136,7 +136,7 @@ bool Sema::CheckCXXThrowOperand(SourceLocation ThrowLoc, Expr *&E) {
   //   to an incomplete type other than (cv) void the program is ill-formed.
   QualType Ty = E->getType();
   int isPointer = 0;
-  if (const PointerType* Ptr = Ty->getAsPointerType()) {
+  if (const PointerType* Ptr = Ty->getAs<PointerType>()) {
     Ty = Ptr->getPointeeType();
     isPointer = 1;
   }
@@ -708,7 +708,7 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
       return ExprError(Diag(StartLoc, diag::err_delete_operand)
         << Type << Ex->getSourceRange());
 
-    QualType Pointee = Type->getAsPointerType()->getPointeeType();
+    QualType Pointee = Type->getAs<PointerType>()->getPointeeType();
     if (Pointee->isFunctionType() || Pointee->isVoidType())
       return ExprError(Diag(StartLoc, diag::err_delete_operand)
         << Type << Ex->getSourceRange());
@@ -812,7 +812,7 @@ Sema::IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType) {
   // string literal can be converted to an rvalue of type "pointer
   // to wchar_t" (C++ 4.2p2).
   if (StringLiteral *StrLit = dyn_cast<StringLiteral>(From))
-    if (const PointerType *ToPtrType = ToType->getAsPointerType())
+    if (const PointerType *ToPtrType = ToType->getAs<PointerType>())
       if (const BuiltinType *ToPointeeType 
           = ToPtrType->getPointeeType()->getAsBuiltinType()) {
         // This conversion is considered only when there is an
@@ -1066,7 +1066,7 @@ QualType Sema::CheckPointerToMemberOperands(
   //   such a class]
   QualType LType = lex->getType();
   if (isIndirect) {
-    if (const PointerType *Ptr = LType->getAsPointerType())
+    if (const PointerType *Ptr = LType->getAs<PointerType>())
       LType = Ptr->getPointeeType().getNonReferenceType();
     else {
       Diag(Loc, diag::err_bad_memptr_lhs)
@@ -1515,8 +1515,8 @@ QualType Sema::FindCompositePointerType(Expr *&E1, Expr *&E2) {
   llvm::SmallVector<unsigned, 4> QualifierUnion;
   QualType Composite1 = T1, Composite2 = T2;
   const PointerType *Ptr1, *Ptr2;
-  while ((Ptr1 = Composite1->getAsPointerType()) &&
-         (Ptr2 = Composite2->getAsPointerType())) {
+  while ((Ptr1 = Composite1->getAs<PointerType>()) &&
+         (Ptr2 = Composite2->getAs<PointerType>())) {
     Composite1 = Ptr1->getPointeeType();
     Composite2 = Ptr2->getPointeeType();
     QualifierUnion.push_back(
index 1131a9f0d846a69168bd5b8508e41367aad267fc..c20956827b82c25051325857a94727ccbecf3cfc 100644 (file)
@@ -859,7 +859,7 @@ bool Sema::ObjCQualifiedIdTypesAreCompatible(QualType lhs, QualType rhs,
   if (!lhs->isPointerType())
     return false;
   
-  QualType ltype = lhs->getAsPointerType()->getPointeeType();
+  QualType ltype = lhs->getAs<PointerType>()->getPointeeType();
   if (const ObjCQualifiedInterfaceType *lhsQI =
          ltype->getAsObjCQualifiedInterfaceType()) {
     ObjCObjectPointerType::qual_iterator LHSProtoI = lhsQI->qual_begin();
index c88321e1a355f52ab66222999b5088a1925d58a3..a37be6898f31c2373db3dad502c6e1b5e969cc44 100644 (file)
@@ -1435,7 +1435,7 @@ addAssociatedClassesAndNamespaces(QualType T,
   // We handle this by unwrapping pointer and array types immediately,
   // to avoid unnecessary recursion.
   while (true) {
-    if (const PointerType *Ptr = T->getAsPointerType())
+    if (const PointerType *Ptr = T->getAs<PointerType>())
       T = Ptr->getPointeeType();
     else if (const ArrayType *Ptr = Context.getAsArrayType(T))
       T = Ptr->getElementType();
index daf6800ea0c0ff5dd57bed554cd2dfbb903d9e92..4b58b3d0c7f291e5bf19cf5f1c36b956792ecfe0 100644 (file)
@@ -529,10 +529,10 @@ CheckStaticCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
   // Reverse pointer conversion to void*. C++ 4.10.p2 specifies conversion to
   // void*. C++ 5.2.9p10 specifies additional restrictions, which really is
   // just the usual constness stuff.
-  if (const PointerType *SrcPointer = SrcType->getAsPointerType()) {
+  if (const PointerType *SrcPointer = SrcType->getAs<PointerType>()) {
     QualType SrcPointee = SrcPointer->getPointeeType();
     if (SrcPointee->isVoidType()) {
-      if (const PointerType *DestPointer = DestType->getAsPointerType()) {
+      if (const PointerType *DestPointer = DestType->getAs<PointerType>()) {
         QualType DestPointee = DestPointer->getPointeeType();
         if (DestPointee->isIncompleteOrObjectType()) {
           // This is definitely the intended conversion, but it might fail due
@@ -627,12 +627,12 @@ TryStaticPointerDowncast(Sema &Self, QualType SrcType, QualType DestType,
   // In addition, DR54 clarifies that the base must be accessible in the
   // current context.
 
-  const PointerType *SrcPointer = SrcType->getAsPointerType();
+  const PointerType *SrcPointer = SrcType->getAs<PointerType>();
   if (!SrcPointer) {
     return TSC_NotApplicable;
   }
 
-  const PointerType *DestPointer = DestType->getAsPointerType();
+  const PointerType *DestPointer = DestType->getAs<PointerType>();
   if (!DestPointer) {
     return TSC_NotApplicable;
   }
@@ -828,7 +828,7 @@ CheckDynamicCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
   //   or "pointer to cv void".
 
   QualType DestPointee;
-  const PointerType *DestPointer = DestType->getAsPointerType();
+  const PointerType *DestPointer = DestType->getAs<PointerType>();
   const ReferenceType *DestReference = DestType->getAsReferenceType();
   if (DestPointer) {
     DestPointee = DestPointer->getPointeeType();
@@ -863,7 +863,7 @@ CheckDynamicCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
   QualType SrcType = Self.Context.getCanonicalType(OrigSrcType);
   QualType SrcPointee;
   if (DestPointer) {
-    if (const PointerType *SrcPointer = SrcType->getAsPointerType()) {
+    if (const PointerType *SrcPointer = SrcType->getAs<PointerType>()) {
       SrcPointee = SrcPointer->getPointeeType();
     } else {
       Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_ptr)
index d0d61c6ed1a0e3dc67be8cb35f076fe0ef4a3b1d..dc24a0384dd60f8ea5c78fb0153e404beb0a4f7a 100644 (file)
@@ -173,7 +173,7 @@ isPointerConversionToVoidPointer(ASTContext& Context) const
     FromType = Context.getArrayDecayedType(FromType);
 
   if (Second == ICK_Pointer_Conversion)
-    if (const PointerType* ToPtrType = ToType->getAsPointerType())
+    if (const PointerType* ToPtrType = ToType->getAs<PointerType>())
       return ToPtrType->getPointeeType()->isVoidType();
 
   return false;
@@ -915,7 +915,7 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
 
   // Blocks: Block pointers can be converted to void*.
   if (FromType->isBlockPointerType() && ToType->isPointerType() &&
-      ToType->getAsPointerType()->getPointeeType()->isVoidType()) {
+      ToType->getAs<PointerType>()->getPointeeType()->isVoidType()) {
     ConvertedType = ToType;
     return true;
   }
@@ -933,7 +933,7 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
     return true;
   }
 
-  const PointerType* ToTypePtr = ToType->getAsPointerType();
+  const PointerType* ToTypePtr = ToType->getAs<PointerType>();
   if (!ToTypePtr)
     return false;
 
@@ -944,7 +944,7 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
   }
 
   // Beyond this point, both types need to be pointers.
-  const PointerType *FromTypePtr = FromType->getAsPointerType();
+  const PointerType *FromTypePtr = FromType->getAs<PointerType>();
   if (!FromTypePtr)
     return false;
 
@@ -1042,17 +1042,17 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
   } 
   // Beyond this point, both types need to be C pointers or block pointers.
   QualType ToPointeeType;
-  if (const PointerType *ToCPtr = ToType->getAsPointerType())
+  if (const PointerType *ToCPtr = ToType->getAs<PointerType>())
     ToPointeeType = ToCPtr->getPointeeType();
-  else if (const BlockPointerType *ToBlockPtr = ToType->getAsBlockPointerType())
+  else if (const BlockPointerType *ToBlockPtr = ToType->getAs<BlockPointerType>())
     ToPointeeType = ToBlockPtr->getPointeeType();
   else
     return false;
 
   QualType FromPointeeType;
-  if (const PointerType *FromCPtr = FromType->getAsPointerType())
+  if (const PointerType *FromCPtr = FromType->getAs<PointerType>())
     FromPointeeType = FromCPtr->getPointeeType();
-  else if (const BlockPointerType *FromBlockPtr = FromType->getAsBlockPointerType())
+  else if (const BlockPointerType *FromBlockPtr = FromType->getAs<BlockPointerType>())
     FromPointeeType = FromBlockPtr->getPointeeType();
   else
     return false;
@@ -1142,8 +1142,8 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
 bool Sema::CheckPointerConversion(Expr *From, QualType ToType) {
   QualType FromType = From->getType();
 
-  if (const PointerType *FromPtrType = FromType->getAsPointerType())
-    if (const PointerType *ToPtrType = ToType->getAsPointerType()) {
+  if (const PointerType *FromPtrType = FromType->getAs<PointerType>())
+    if (const PointerType *ToPtrType = ToType->getAs<PointerType>()) {
       QualType FromPointeeType = FromPtrType->getPointeeType(),
                ToPointeeType   = ToPtrType->getPointeeType();
 
@@ -1404,7 +1404,7 @@ bool Sema::IsUserDefinedConversion(Expr *From, QualType ToType,
         User.ConversionFunction = Constructor;
         User.After.setAsIdentityConversion();
         User.After.FromTypePtr 
-          = ThisType->getAsPointerType()->getPointeeType().getAsOpaquePtr();
+          = ThisType->getAs<PointerType>()->getPointeeType().getAsOpaquePtr();
         User.After.ToTypePtr = ToType.getAsOpaquePtr();
         return true;
       } else if (CXXConversionDecl *Conversion
@@ -1579,9 +1579,9 @@ Sema::CompareStandardConversionSequences(const StandardConversionSequence& SCS1,
       FromType2 = Context.getArrayDecayedType(FromType2);
 
     QualType FromPointee1 
-      = FromType1->getAsPointerType()->getPointeeType().getUnqualifiedType();
+      = FromType1->getAs<PointerType>()->getPointeeType().getUnqualifiedType();
     QualType FromPointee2
-      = FromType2->getAsPointerType()->getPointeeType().getUnqualifiedType();
+      = FromType2->getAs<PointerType>()->getPointeeType().getUnqualifiedType();
 
     if (IsDerivedFrom(FromPointee2, FromPointee1))
       return ImplicitConversionSequence::Better;
@@ -1771,13 +1771,13 @@ Sema::CompareDerivedToBaseConversions(const StandardConversionSequence& SCS1,
       FromType1->isPointerType() && FromType2->isPointerType() &&
       ToType1->isPointerType() && ToType2->isPointerType()) {
     QualType FromPointee1 
-      = FromType1->getAsPointerType()->getPointeeType().getUnqualifiedType();
+      = FromType1->getAs<PointerType>()->getPointeeType().getUnqualifiedType();
     QualType ToPointee1 
-      = ToType1->getAsPointerType()->getPointeeType().getUnqualifiedType();
+      = ToType1->getAs<PointerType>()->getPointeeType().getUnqualifiedType();
     QualType FromPointee2
-      = FromType2->getAsPointerType()->getPointeeType().getUnqualifiedType();
+      = FromType2->getAs<PointerType>()->getPointeeType().getUnqualifiedType();
     QualType ToPointee2
-      = ToType2->getAsPointerType()->getPointeeType().getUnqualifiedType();
+      = ToType2->getAs<PointerType>()->getPointeeType().getUnqualifiedType();
 
     const ObjCInterfaceType* FromIface1 = FromPointee1->getAsObjCInterfaceType();
     const ObjCInterfaceType* FromIface2 = FromPointee2->getAsObjCInterfaceType();
@@ -1943,7 +1943,7 @@ Sema::TryObjectArgumentInitialization(Expr *From, CXXMethodDecl *Method) {
 
   // We need to have an object of class type.
   QualType FromType = From->getType();
-  if (const PointerType *PT = FromType->getAsPointerType())
+  if (const PointerType *PT = FromType->getAs<PointerType>())
     FromType = PT->getPointeeType();
 
   assert(FromType->isRecordType());
@@ -1991,9 +1991,9 @@ bool
 Sema::PerformObjectArgumentInitialization(Expr *&From, CXXMethodDecl *Method) {
   QualType FromRecordType, DestType;
   QualType ImplicitParamRecordType  = 
-    Method->getThisType(Context)->getAsPointerType()->getPointeeType();
+    Method->getThisType(Context)->getAs<PointerType>()->getPointeeType();
   
-  if (const PointerType *PT = From->getType()->getAsPointerType()) {
+  if (const PointerType *PT = From->getType()->getAs<PointerType>()) {
     FromRecordType = PT->getPointeeType();
     DestType = Method->getThisType(Context);
   } else {
@@ -2634,7 +2634,7 @@ BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(QualType Ty) {
   if (!PointerTypes.insert(Ty))
     return false;
 
-  if (const PointerType *PointerTy = Ty->getAsPointerType()) {
+  if (const PointerType *PointerTy = Ty->getAs<PointerType>()) {
     QualType PointeeTy = PointerTy->getPointeeType();
     // FIXME: Optimize this so that we don't keep trying to add the same types.
 
@@ -2710,7 +2710,7 @@ BuiltinCandidateTypeSet::AddTypesConvertedFrom(QualType Ty,
   // We don't care about qualifiers on the type.
   Ty = Ty.getUnqualifiedType();
 
-  if (const PointerType *PointerTy = Ty->getAsPointerType()) {
+  if (const PointerType *PointerTy = Ty->getAs<PointerType>()) {
     QualType PointeeTy = PointerTy->getPointeeType();
 
     // Insert our type, and its more-qualified variants, into the set
@@ -2898,7 +2898,7 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
     for (BuiltinCandidateTypeSet::iterator Ptr = CandidateTypes.pointer_begin();
          Ptr != CandidateTypes.pointer_end(); ++Ptr) {
       // Skip pointer types that aren't pointers to object types.
-      if (!(*Ptr)->getAsPointerType()->getPointeeType()->isObjectType())
+      if (!(*Ptr)->getAs<PointerType>()->getPointeeType()->isObjectType())
         continue;
 
       QualType ParamTypes[2] = { 
@@ -2936,7 +2936,7 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
     for (BuiltinCandidateTypeSet::iterator Ptr = CandidateTypes.pointer_begin();
          Ptr != CandidateTypes.pointer_end(); ++Ptr) {
       QualType ParamTy = *Ptr;
-      QualType PointeeTy = ParamTy->getAsPointerType()->getPointeeType();
+      QualType PointeeTy = ParamTy->getAs<PointerType>()->getPointeeType();
       AddBuiltinCandidate(Context.getLValueReferenceType(PointeeTy), 
                           &ParamTy, Args, 1, CandidateSet);
     }
@@ -3336,7 +3336,7 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
     for (BuiltinCandidateTypeSet::iterator Ptr = CandidateTypes.pointer_begin();
          Ptr != CandidateTypes.pointer_end(); ++Ptr) {
       QualType ParamTypes[2] = { *Ptr, Context.getPointerDiffType() };
-      QualType PointeeType = (*Ptr)->getAsPointerType()->getPointeeType();
+      QualType PointeeType = (*Ptr)->getAs<PointerType>()->getPointeeType();
       QualType ResultTy = Context.getLValueReferenceType(PointeeType);
 
       // T& operator[](T*, ptrdiff_t)
@@ -3624,7 +3624,7 @@ Sema::PrintOverloadCandidates(OverloadCandidateSet& CandidateSet,
           FnType = FnTypeRef->getPointeeType();
           isRValueReference = true;
         }
-        if (const PointerType *FnTypePtr = FnType->getAsPointerType()) {
+        if (const PointerType *FnTypePtr = FnType->getAs<PointerType>()) {
           FnType = FnTypePtr->getPointeeType();
           isPointer = true;
         }
@@ -3673,7 +3673,7 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType,
                                          bool Complain) {
   QualType FunctionType = ToType;
   bool IsMember = false;
-  if (const PointerType *ToTypePtr = ToType->getAsPointerType())
+  if (const PointerType *ToTypePtr = ToType->getAs<PointerType>())
     FunctionType = ToTypePtr->getPointeeType();
   else if (const ReferenceType *ToTypeRef = ToType->getAsReferenceType())
     FunctionType = ToTypeRef->getPointeeType();
@@ -4414,7 +4414,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object,
     // Strip the reference type (if any) and then the pointer type (if
     // any) to get down to what might be a function type.
     QualType ConvType = Conv->getConversionType().getNonReferenceType();
-    if (const PointerType *ConvPtrType = ConvType->getAsPointerType())
+    if (const PointerType *ConvPtrType = ConvType->getAs<PointerType>())
       ConvType = ConvPtrType->getPointeeType();
 
     if (const FunctionProtoType *Proto = ConvType->getAsFunctionProtoType())
index bd2b0aef3d365ab8576abfd5749dc57762e6ddf5..0a7ed462f81ed11621591672fb88bc73e6812432 100644 (file)
@@ -1204,7 +1204,7 @@ Sema::ActOnObjCAtThrowStmt(SourceLocation AtLoc, ExprArg expr,Scope *CurScope) {
     QualType ThrowType = ThrowExpr->getType();
     // Make sure the expression type is an ObjC pointer or "void *".
     if (!ThrowType->isObjCObjectPointerType()) {
-      const PointerType *PT = ThrowType->getAsPointerType();
+      const PointerType *PT = ThrowType->getAs<PointerType>();
       if (!PT || !PT->getPointeeType()->isVoidType())
         return StmtError(Diag(AtLoc, diag::error_objc_throw_expects_object)
                         << ThrowExpr->getType() << ThrowExpr->getSourceRange());
@@ -1221,7 +1221,7 @@ Sema::ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, ExprArg SynchExpr,
   // Make sure the expression type is an ObjC pointer or "void *".
   Expr *SyncExpr = static_cast<Expr*>(SynchExpr.get());
   if (!SyncExpr->getType()->isObjCObjectPointerType()) {
-    const PointerType *PT = SyncExpr->getType()->getAsPointerType();
+    const PointerType *PT = SyncExpr->getType()->getAs<PointerType>();
     if (!PT || !PT->getPointeeType()->isVoidType())
       return StmtError(Diag(AtLoc, diag::error_objc_synchronized_expects_object)
                        << SyncExpr->getType() << SyncExpr->getSourceRange());
index 568d68c9a7e82f714c1d1006d0832250051a9702..85d38671f103f58cc7fd1dde751e7d779911be37 100644 (file)
@@ -225,8 +225,8 @@ Sema::CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc) {
   if (T->isIntegralType() || T->isEnumeralType() ||
       //   -- pointer to object or pointer to function, 
       (T->isPointerType() && 
-       (T->getAsPointerType()->getPointeeType()->isObjectType() ||
-        T->getAsPointerType()->getPointeeType()->isFunctionType())) ||
+       (T->getAs<PointerType>()->getPointeeType()->isObjectType() ||
+        T->getAs<PointerType>()->getPointeeType()->isFunctionType())) ||
       //   -- reference to object or reference to function, 
       T->isReferenceType() ||
       //   -- pointer to member.
@@ -1648,7 +1648,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
       //    function is selected from the set (13.4).
       // In C++0x, any std::nullptr_t value can be converted.
       (ParamType->isPointerType() &&
-       ParamType->getAsPointerType()->getPointeeType()->isFunctionType()) ||
+       ParamType->getAs<PointerType>()->getPointeeType()->isFunctionType()) ||
       // -- For a non-type template-parameter of type reference to
       //    function, no conversions apply. If the template-argument
       //    represents a set of overloaded functions, the matching
@@ -1721,7 +1721,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
     //      object, qualification conversions (4.4) and the
     //      array-to-pointer conversion (4.2) are applied.
     // C++0x also allows a value of std::nullptr_t.
-    assert(ParamType->getAsPointerType()->getPointeeType()->isObjectType() &&
+    assert(ParamType->getAs<PointerType>()->getPointeeType()->isObjectType() &&
            "Only object pointers allowed here");
 
     if (ArgType->isNullPtrType()) {
index f6f9d105d95d16d889fae6430ef7917d72073ff8..b304751beb68660f6b80abed058e661d08915388 100644 (file)
@@ -397,7 +397,7 @@ DeduceTemplateArguments(ASTContext &Context,
       
     //     T *
     case Type::Pointer: {
-      const PointerType *PointerArg = Arg->getAsPointerType();
+      const PointerType *PointerArg = Arg->getAs<PointerType>();
       if (!PointerArg)
         return Sema::TDK_NonDeducedMismatch;
       
@@ -1320,7 +1320,7 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
     if (isSimpleTemplateIdType(ParamType) ||
         (isa<PointerType>(ParamType) && 
          isSimpleTemplateIdType(
-                              ParamType->getAsPointerType()->getPointeeType())))
+                              ParamType->getAs<PointerType>()->getPointeeType())))
       TDF |= TDF_DerivedClass;
     
     if (TemplateDeductionResult Result
index 8195aba967a2519b9fd14d3d449611df4efb5633..ee4cd204b99a77f471438c9a134f5618066dec83 100644 (file)
@@ -300,7 +300,7 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS,
     if (TypeQuals & QualType::Restrict) {
       if (Result->isPointerType() || Result->isReferenceType()) {
         QualType EltTy = Result->isPointerType() ? 
-          Result->getAsPointerType()->getPointeeType() :
+          Result->getAs<PointerType>()->getPointeeType() :
           Result->getAsReferenceType()->getPointeeType();
       
         // If we have a pointer or reference, the pointee must have an object
@@ -1185,7 +1185,7 @@ bool Sema::CheckSpecifiedExceptionType(QualType T, const SourceRange &Range) {
   //   an incomplete type a pointer or reference to an incomplete type, other
   //   than (cv) void*.
   int kind;
-  if (const PointerType* IT = T->getAsPointerType()) {
+  if (const PointerType* IT = T->getAs<PointerType>()) {
     T = IT->getPointeeType();
     kind = 1;
   } else if (const ReferenceType* IT = T->getAsReferenceType()) {
@@ -1205,7 +1205,7 @@ bool Sema::CheckSpecifiedExceptionType(QualType T, const SourceRange &Range) {
 /// to member to a function with an exception specification. This means that
 /// it is invalid to add another level of indirection.
 bool Sema::CheckDistantExceptionSpec(QualType T) {
-  if (const PointerType *PT = T->getAsPointerType())
+  if (const PointerType *PT = T->getAs<PointerType>())
     T = PT->getPointeeType();
   else if (const MemberPointerType *PT = T->getAsMemberPointerType())
     T = PT->getPointeeType();
@@ -1287,7 +1287,7 @@ bool Sema::CheckExceptionSpecSubset(unsigned DiagID, unsigned NoteID,
     bool SubIsPointer = false;
     if (const ReferenceType *RefTy = CanonicalSubT->getAsReferenceType())
       CanonicalSubT = RefTy->getPointeeType();
-    if (const PointerType *PtrTy = CanonicalSubT->getAsPointerType()) {
+    if (const PointerType *PtrTy = CanonicalSubT->getAs<PointerType>()) {
       CanonicalSubT = PtrTy->getPointeeType();
       SubIsPointer = true;
     }
@@ -1308,7 +1308,7 @@ bool Sema::CheckExceptionSpecSubset(unsigned DiagID, unsigned NoteID,
       if (const ReferenceType *RefTy = CanonicalSuperT->getAsReferenceType())
         CanonicalSuperT = RefTy->getPointeeType();
       if (SubIsPointer) {
-        if (const PointerType *PtrTy = CanonicalSuperT->getAsPointerType())
+        if (const PointerType *PtrTy = CanonicalSuperT->getAs<PointerType>())
           CanonicalSuperT = PtrTy->getPointeeType();
         else {
           continue;
@@ -1384,8 +1384,8 @@ QualType Sema::ObjCGetTypeForMethodDefinition(DeclPtrTy D) {
 /// be called in a loop that successively "unwraps" pointer and
 /// pointer-to-member types to compare them at each level.
 bool Sema::UnwrapSimilarPointerTypes(QualType& T1, QualType& T2) {
-  const PointerType *T1PtrType = T1->getAsPointerType(),
-                    *T2PtrType = T2->getAsPointerType();
+  const PointerType *T1PtrType = T1->getAs<PointerType>(),
+                    *T2PtrType = T2->getAs<PointerType>();
   if (T1PtrType && T2PtrType) {
     T1 = T1PtrType->getPointeeType();
     T2 = T2PtrType->getPointeeType();