[cfe-commits] r76098 - in /cfe/trunk: include/clang/AST/ include/clang/Analysis/PathSensitive/ lib/AST/ lib/Analysis/ lib/CodeGen/ lib/Frontend/ lib/Sema/

Ted Kremenek kremenek at apple.com
Thu Jul 16 12:58:32 PDT 2009


Author: kremenek
Date: Thu Jul 16 14:58:26 2009
New Revision: 76098

URL: http://llvm.org/viewvc/llvm-project?rev=76098&view=rev
Log:
Add member template 'Type::getAs<T>', which converts a Type* to a respective T*.
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>.


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

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Thu Jul 16 14:58:26 2009
@@ -711,7 +711,7 @@
 
   QualType getAllocatedType() const {
     assert(getType()->isPointerType());
-    return getType()->getAsPointerType()->getPointeeType();
+    return getType()->getAs<PointerType>()->getPointeeType();
   }
 
   FunctionDecl *getOperatorNew() const { return OperatorNew; }

Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Thu Jul 16 14:58:26 2009
@@ -431,8 +431,6 @@
   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 @@
   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 @@
   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 @@
   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 @@
                   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
 

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h Thu Jul 16 14:58:26 2009
@@ -357,7 +357,7 @@
   }
 
   QualType getValueType(ASTContext&) const {
-    const PointerType* PTy = LValueType->getAsPointerType();
+    const PointerType* PTy = LValueType->getAs<PointerType>();
     assert(PTy);
     return PTy->getPointeeType();
   }

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Jul 16 14:58:26 2009
@@ -1092,7 +1092,7 @@
     return T;
   
   if (T->isPointerType()) {
-    QualType Pointee = T->getAsPointerType()->getPointeeType();
+    QualType Pointee = T->getAs<PointerType>()->getPointeeType();
     if (Pointee->isAnyPointerType()) {
       QualType ResultType = getObjCGCQualType(Pointee, GCAttr);
       return getPointerType(ResultType);
@@ -2779,7 +2779,7 @@
     return;
   }
   
-  if (const PointerType *PT = T->getAsPointerType()) {
+  if (const PointerType *PT = T->getAs<PointerType>()) {
     QualType PointeeTy = PT->getPointeeType();
     bool isReadOnly = false;
     // For historical/compatibility reasons, the read-only qualifier of the
@@ -2794,8 +2794,8 @@
     }
     else if (OutermostType) {
       QualType P = PointeeTy;
-      while (P->getAsPointerType())
-        P = P->getAsPointerType()->getPointeeType();
+      while (P->getAs<PointerType>())
+        P = P->getAs<PointerType>()->getPointeeType();
       if (P.isConstQualified()) {
         isReadOnly = true;
         S += 'r';
@@ -3035,7 +3035,7 @@
   TypedefDecl *TD = TT->getDecl();
 
   // typedef struct objc_selector *SEL;
-  const PointerType *ptr = TD->getUnderlyingType()->getAsPointerType();
+  const PointerType *ptr = TD->getUnderlyingType()->getAs<PointerType>();
   if (!ptr)
     return;
   const RecordType *rec = ptr->getPointeeType()->getAsStructureType();
@@ -3159,7 +3159,7 @@
       if (Ty->isObjCObjectPointerType())
         GCAttrs = QualType::Strong;
       else if (Ty->isPointerType())
-        return getObjCGCAttrKind(Ty->getAsPointerType()->getPointeeType());
+        return getObjCGCAttrKind(Ty->getAs<PointerType>()->getPointeeType());
     }
     // Non-pointers have none gc'able attribute regardless of the attribute
     // set on them.
@@ -3519,8 +3519,8 @@
   case Type::Pointer:
   {
     // Merge two pointer types, while trying to preserve typedef info
-    QualType LHSPointee = LHS->getAsPointerType()->getPointeeType();
-    QualType RHSPointee = RHS->getAsPointerType()->getPointeeType();
+    QualType LHSPointee = LHS->getAs<PointerType>()->getPointeeType();
+    QualType RHSPointee = RHS->getAs<PointerType>()->getPointeeType();
     QualType ResultType = mergeTypes(LHSPointee, RHSPointee);
     if (ResultType.isNull()) return QualType();
     if (getCanonicalType(LHSPointee) == getCanonicalType(ResultType))
@@ -3532,8 +3532,8 @@
   case Type::BlockPointer:
   {
     // Merge two block pointer types, while trying to preserve typedef info
-    QualType LHSPointee = LHS->getAsBlockPointerType()->getPointeeType();
-    QualType RHSPointee = RHS->getAsBlockPointerType()->getPointeeType();
+    QualType LHSPointee = LHS->getAs<BlockPointerType>()->getPointeeType();
+    QualType RHSPointee = RHS->getAs<BlockPointerType>()->getPointeeType();
     QualType ResultType = mergeTypes(LHSPointee, RHSPointee);
     if (ResultType.isNull()) return QualType();
     if (getCanonicalType(LHSPointee) == getCanonicalType(ResultType))

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Thu Jul 16 14:58:26 2009
@@ -90,7 +90,7 @@
   while (!BaseType->isSpecifierType()) {
     if (isa<TypedefType>(BaseType))
       break;
-    else if (const PointerType* PTy = BaseType->getAsPointerType())
+    else if (const PointerType* PTy = BaseType->getAs<PointerType>())
       BaseType = PTy->getPointeeType();
     else if (const ArrayType* ATy = dyn_cast<ArrayType>(BaseType))
       BaseType = ATy->getElementType();

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Thu Jul 16 14:58:26 2009
@@ -279,9 +279,9 @@
 
 QualType CallExpr::getCallReturnType() const {
   QualType CalleeType = getCallee()->getType();
-  if (const PointerType *FnTypePtr = CalleeType->getAsPointerType())
+  if (const PointerType *FnTypePtr = CalleeType->getAs<PointerType>())
     CalleeType = FnTypePtr->getPointeeType();
-  else if (const BlockPointerType *BPT = CalleeType->getAsBlockPointerType())
+  else if (const BlockPointerType *BPT = CalleeType->getAs<BlockPointerType>())
     CalleeType = BPT->getPointeeType();
   
   const FunctionType *FnType = CalleeType->getAsFunctionType();
@@ -430,7 +430,7 @@
 /// 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 @@
       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 @@
   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*

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Jul 16 14:58:26 2009
@@ -222,7 +222,7 @@
   if (E->isArrow()) {
     if (!EvaluatePointer(E->getBase(), result, Info))
       return APValue();
-    Ty = E->getBase()->getType()->getAsPointerType()->getPointeeType();
+    Ty = E->getBase()->getType()->getAs<PointerType>()->getPointeeType();
   } else {
     result = Visit(E->getBase());
     if (result.isUninit())
@@ -351,7 +351,7 @@
   if (!EvaluateInteger(IExp, AdditionalOffset, Info))
     return APValue();
 
-  QualType PointeeType = PExp->getType()->getAsPointerType()->getPointeeType();
+  QualType PointeeType = PExp->getType()->getAs<PointerType>()->getPointeeType();
   uint64_t SizeOfPointee;
   
   // Explicitly handle GNU void* and function pointer arithmetic extensions.
@@ -1029,7 +1029,7 @@
 
       if (E->getOpcode() == BinaryOperator::Sub) {
         const QualType Type = E->getLHS()->getType();
-        const QualType ElementType = Type->getAsPointerType()->getPointeeType();
+        const QualType ElementType = Type->getAs<PointerType>()->getPointeeType();
 
         uint64_t D = LHSValue.getLValueOffset() - RHSValue.getLValueOffset();
         if (!ElementType->isVoidType() && !ElementType->isFunctionType())

Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Thu Jul 16 14:58:26 2009
@@ -202,7 +202,7 @@
   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 @@
 }
 
 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 @@
   // 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();

Modified: cfe/trunk/lib/Analysis/BasicStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BasicStore.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/BasicStore.cpp (original)
+++ cfe/trunk/lib/Analysis/BasicStore.cpp Thu Jul 16 14:58:26 2009
@@ -251,7 +251,7 @@
 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;

Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Thu Jul 16 14:58:26 2009
@@ -248,7 +248,7 @@
     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 @@
       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 @@
   }
   
   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));

Modified: cfe/trunk/lib/Analysis/CheckNSError.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CheckNSError.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/CheckNSError.cpp (original)
+++ cfe/trunk/lib/Analysis/CheckNSError.cpp Thu Jul 16 14:58:26 2009
@@ -161,7 +161,7 @@
 
 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::CheckCFErrorArgument(QualType ArgTy) {
   
-  const PointerType* PPT = ArgTy->getAsPointerType();
+  const PointerType* PPT = ArgTy->getAs<PointerType>();
   if (!PPT) return false;
   
   const TypedefType* TT = PPT->getPointeeType()->getAsTypedefType();

Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Thu Jul 16 14:58:26 2009
@@ -1274,7 +1274,7 @@
     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 @@
   // 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);

Modified: cfe/trunk/lib/Analysis/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RegionStore.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Thu Jul 16 14:58:26 2009
@@ -365,7 +365,7 @@
     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 @@
         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 @@
       // 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 @@
   // 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 @@
   // 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 @@
   // 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 @@
   // 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.

Modified: cfe/trunk/lib/Analysis/Store.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/Store.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/Store.cpp (original)
+++ cfe/trunk/lib/Analysis/Store.cpp Thu Jul 16 14:58:26 2009
@@ -62,7 +62,7 @@
 
   // 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 @@
   // 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.

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Jul 16 14:58:26 2009
@@ -388,7 +388,7 @@
 
 RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E) {
   const BlockPointerType *BPT =
-    E->getCallee()->getType()->getAsBlockPointerType();
+    E->getCallee()->getType()->getAs<BlockPointerType>();
 
   llvm::Value *Callee = EmitScalarExpr(E->getCallee());
 

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Jul 16 14:58:26 2009
@@ -934,7 +934,7 @@
     assert(E->getBase()->getType()->isVectorType());
     Base = EmitLValue(E->getBase());
   } else {
-    const PointerType *PT = E->getBase()->getType()->getAsPointerType();
+    const PointerType *PT = E->getBase()->getType()->getAs<PointerType>();
     llvm::Value *Ptr = EmitScalarExpr(E->getBase());
     Base = LValue::MakeAddr(Ptr, PT->getPointeeType().getCVRQualifiers());
   }
@@ -976,7 +976,7 @@
   if (E->isArrow()) {
     BaseValue = EmitScalarExpr(BaseExpr);
     const PointerType *PTy = 
-      BaseExpr->getType()->getAsPointerType();
+      BaseExpr->getType()->getAs<PointerType>();
     if (PTy->getPointeeType()->isUnionType())
       isUnion = true;
     CVRQualifiers = PTy->getPointeeType().getCVRQualifiers();
@@ -1317,7 +1317,7 @@
   assert(CalleeType->isFunctionPointerType() && 
          "Call must have function pointer type!");
 
-  QualType FnType = CalleeType->getAsPointerType()->getPointeeType();
+  QualType FnType = CalleeType->getAs<PointerType>()->getPointeeType();
   QualType ResultType = FnType->getAsFunctionType()->getResultType();
 
   CallArgList Args;

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Thu Jul 16 14:58:26 2009
@@ -679,7 +679,7 @@
   int AmountVal = isInc ? 1 : -1;
 
   if (ValTy->isPointerType() &&
-      ValTy->getAsPointerType()->isVariableArrayType()) {
+      ValTy->getAs<PointerType>()->isVariableArrayType()) {
     // The amount of the addition/subtraction needs to account for the VLA size
     CGF.ErrorUnsupported(E, "VLA pointer inc/dec");
   }
@@ -1002,13 +1002,13 @@
   }
 
   if (Ops.Ty->isPointerType() &&
-      Ops.Ty->getAsPointerType()->isVariableArrayType()) {
+      Ops.Ty->getAs<PointerType>()->isVariableArrayType()) {
     // The amount of the addition needs to account for the VLA size
     CGF.ErrorUnsupported(Ops.E, "VLA pointer addition");
   }
   Value *Ptr, *Idx;
   Expr *IdxExp;
-  const PointerType *PT = Ops.E->getLHS()->getType()->getAsPointerType();
+  const PointerType *PT = Ops.E->getLHS()->getType()->getAs<PointerType>();
   const ObjCObjectPointerType *OPT = 
     Ops.E->getLHS()->getType()->getAsObjCObjectPointerType();
   if (PT || OPT) {
@@ -1016,7 +1016,7 @@
     Idx = Ops.RHS;
     IdxExp = Ops.E->getRHS();
   } else {  // int + pointer
-    PT = Ops.E->getRHS()->getType()->getAsPointerType();
+    PT = Ops.E->getRHS()->getType()->getAs<PointerType>();
     OPT = Ops.E->getRHS()->getType()->getAsObjCObjectPointerType();
     assert((PT || OPT) && "Invalid add expr");
     Ptr = Ops.RHS;
@@ -1073,7 +1073,7 @@
   }
 
   if (Ops.E->getLHS()->getType()->isPointerType() &&
-      Ops.E->getLHS()->getType()->getAsPointerType()->isVariableArrayType()) {
+      Ops.E->getLHS()->getType()->getAs<PointerType>()->isVariableArrayType()) {
     // The amount of the addition needs to account for the VLA size for
     // ptr-int
     // The amount of the division needs to account for the VLA size for

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Thu Jul 16 14:58:26 2009
@@ -3008,7 +3008,7 @@
   if (FQT->isObjCObjectPointerType())
     return QualType::Strong;
 
-  if (const PointerType *PT = FQT->getAsPointerType())
+  if (const PointerType *PT = FQT->getAs<PointerType>())
     return GetGCAttrTypeForType(Ctx, PT->getPointeeType());
 
   return QualType::GCNone;

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Jul 16 14:58:26 2009
@@ -490,7 +490,7 @@
     return SizeEntry;
   } else if (const ArrayType *AT = dyn_cast<ArrayType>(Ty)) {
     EmitVLASize(AT->getElementType());
-  } else if (const PointerType *PT = Ty->getAsPointerType())
+  } else if (const PointerType *PT = Ty->getAs<PointerType>())
     EmitVLASize(PT->getPointeeType());
   else {
     assert(0 && "unknown VM type!");

Modified: cfe/trunk/lib/Frontend/RewriteBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/RewriteBlocks.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/RewriteBlocks.cpp (original)
+++ cfe/trunk/lib/Frontend/RewriteBlocks.cpp Thu Jul 16 14:58:26 2009
@@ -130,7 +130,7 @@
         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 @@
   
   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 @@
 
 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::CheckFunctionPointerDecl(QualType funcType, NamedDecl *ND) {
-  const PointerType *PT = funcType->getAsPointerType();
+  const PointerType *PT = funcType->getAs<PointerType>();
   if (PT && PointerTypeTakesAnyBlockArguments(funcType))
     RewriteFunctionProtoType(PT->getPointeeType(), ND);
 }

Modified: cfe/trunk/lib/Frontend/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/RewriteObjC.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/RewriteObjC.cpp (original)
+++ cfe/trunk/lib/Frontend/RewriteObjC.cpp Thu Jul 16 14:58:26 2009
@@ -354,7 +354,7 @@
           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::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 @@
     // 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 @@
       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 @@
                                           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 @@
       
     // 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 @@
         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 @@
   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 @@
                      : (*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 @@
   
   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 @@
       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 @@
 
 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();
   }

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Jul 16 14:58:26 2009
@@ -205,7 +205,7 @@
       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 @@
     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 @@
                                            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 @@
       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);
       }

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Jul 16 14:58:26 2009
@@ -36,9 +36,9 @@
     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 isCFStringType(QualType T, ASTContext &Ctx) {
-  const PointerType *PT = T->getAsPointerType();
+  const PointerType *PT = T->getAs<PointerType>();
   if (!PT)
     return false;
 
@@ -632,7 +632,7 @@
   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 @@
     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 @@
   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 @@
   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 @@
       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 @@
     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();

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Jul 16 14:58:26 2009
@@ -1009,9 +1009,9 @@
     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 @@
   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;

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Jul 16 14:58:26 2009
@@ -133,8 +133,8 @@
     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 @@
     // 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 @@
     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 @@
 
     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 @@
 
     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 @@
                                                          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 @@
       // 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 @@
   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 @@
   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 @@
       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 @@
   // 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 @@
   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 @@
   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 @@
 
     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 @@
     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 @@
 
     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 @@
       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 @@
       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 @@
 
     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 @@
       // 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 @@
     }
 
     // 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 @@
   // 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 @@
   }
   // 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 @@
       && ((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 @@
 
   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 @@
   // 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())

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Jul 16 14:58:26 2009
@@ -136,7 +136,7 @@
   //   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 @@
       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 @@
   // 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 @@
   //   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 @@
   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(

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Thu Jul 16 14:58:26 2009
@@ -859,7 +859,7 @@
   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();

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Thu Jul 16 14:58:26 2009
@@ -1435,7 +1435,7 @@
   // 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();

Modified: cfe/trunk/lib/Sema/SemaNamedCast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaNamedCast.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaNamedCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaNamedCast.cpp Thu Jul 16 14:58:26 2009
@@ -529,10 +529,10 @@
   // 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 @@
   // 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 @@
   //   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 @@
   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)

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Jul 16 14:58:26 2009
@@ -173,7 +173,7 @@
     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 @@
 
   // 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 @@
     return true;
   }
 
-  const PointerType* ToTypePtr = ToType->getAsPointerType();
+  const PointerType* ToTypePtr = ToType->getAs<PointerType>();
   if (!ToTypePtr)
     return false;
 
@@ -944,7 +944,7 @@
   }
 
   // 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 @@
   } 
   // 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::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 @@
         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 @@
       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 @@
       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 @@
 
   // 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 @@
 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 @@
   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 @@
   // 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 @@
     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 @@
     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 @@
     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 @@
           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 @@
                                          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 @@
     // 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())

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Thu Jul 16 14:58:26 2009
@@ -1204,7 +1204,7 @@
     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 @@
   // 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());

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Jul 16 14:58:26 2009
@@ -225,8 +225,8 @@
   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 @@
       //    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 @@
     //      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()) {

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Thu Jul 16 14:58:26 2009
@@ -397,7 +397,7 @@
       
     //     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 @@
     if (isSimpleTemplateIdType(ParamType) ||
         (isa<PointerType>(ParamType) && 
          isSimpleTemplateIdType(
-                              ParamType->getAsPointerType()->getPointeeType())))
+                              ParamType->getAs<PointerType>()->getPointeeType())))
       TDF |= TDF_DerivedClass;
     
     if (TemplateDeductionResult Result

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=76098&r1=76097&r2=76098&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Thu Jul 16 14:58:26 2009
@@ -300,7 +300,7 @@
     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 @@
   //   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 @@
 /// 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 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 @@
       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 @@
 /// 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();





More information about the cfe-commits mailing list