]> granicus.if.org Git - clang/commitdiff
Change all the Type::getAsFoo() methods to specializations of Type::getAs().
authorJohn McCall <rjmccall@apple.com>
Mon, 21 Sep 2009 23:43:11 +0000 (23:43 +0000)
committerJohn McCall <rjmccall@apple.com>
Mon, 21 Sep 2009 23:43:11 +0000 (23:43 +0000)
Several of the existing methods were identical to their respective
specializations, and so have been removed entirely.  Several more 'leaf'
optimizations were introduced.

The getAsFoo() methods which imposed extra conditions, like
getAsObjCInterfacePointerType(), have been left in place.

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

49 files changed:
include/clang/AST/Decl.h
include/clang/AST/DeclCXX.h
include/clang/AST/Type.h
include/clang/AST/TypeNodes.def
include/clang/Frontend/DeclXML.def
lib/AST/ASTContext.cpp
lib/AST/Decl.cpp
lib/AST/DeclCXX.cpp
lib/AST/DeclPrinter.cpp
lib/AST/Expr.cpp
lib/AST/ExprConstant.cpp
lib/AST/StmtPrinter.cpp
lib/AST/Type.cpp
lib/Analysis/BasicObjCFoundationChecks.cpp
lib/Analysis/CFRefCount.cpp
lib/Analysis/CheckNSError.cpp
lib/Analysis/GRExprEngine.cpp
lib/Analysis/RegionStore.cpp
lib/CodeGen/CGBlocks.cpp
lib/CodeGen/CGCXX.cpp
lib/CodeGen/CGCall.cpp
lib/CodeGen/CGExpr.cpp
lib/CodeGen/CGExprComplex.cpp
lib/CodeGen/CGExprScalar.cpp
lib/CodeGen/CGObjCGNU.cpp
lib/CodeGen/CGObjCMac.cpp
lib/CodeGen/CodeGenFunction.cpp
lib/CodeGen/CodeGenModule.cpp
lib/CodeGen/Mangle.cpp
lib/CodeGen/TargetABIInfo.cpp
lib/Frontend/DocumentXML.cpp
lib/Frontend/PCHReader.cpp
lib/Frontend/RewriteBlocks.cpp
lib/Frontend/RewriteObjC.cpp
lib/Sema/SemaChecking.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclAttr.cpp
lib/Sema/SemaDeclCXX.cpp
lib/Sema/SemaDeclObjC.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaExprCXX.cpp
lib/Sema/SemaExprObjC.cpp
lib/Sema/SemaInit.cpp
lib/Sema/SemaLookup.cpp
lib/Sema/SemaOverload.cpp
lib/Sema/SemaTemplate.cpp
lib/Sema/SemaTemplateDeduction.cpp
lib/Sema/SemaTemplateInstantiateDecl.cpp
lib/Sema/SemaType.cpp

index 231e36ab5f3276e630532c88db467cc9bec70698..4ea5e1a734359cff5f3d927bcf3b047ec8356b8d 100644 (file)
@@ -1012,7 +1012,7 @@ public:
   unsigned getMinRequiredArguments() const;
 
   QualType getResultType() const {
-    return getType()->getAsFunctionType()->getResultType();
+    return getType()->getAs<FunctionType>()->getResultType();
   }
   StorageClass getStorageClass() const { return StorageClass(SClass); }
   void setStorageClass(StorageClass SC) { SClass = SC; }
index 4d7c674835be603e1f07b6d6152743471f454355..cf86bf0b7e51871fa15993e4c1962d6bb611437f 100644 (file)
@@ -811,7 +811,7 @@ public:
   QualType getThisType(ASTContext &C) const;
 
   unsigned getTypeQualifiers() const {
-    return getType()->getAsFunctionProtoType()->getTypeQuals();
+    return getType()->getAs<FunctionProtoType>()->getTypeQuals();
   }
 
   // Implement isa/cast/dyncast/etc.
@@ -1312,7 +1312,7 @@ public:
   /// getConversionType - Returns the type that this conversion
   /// function is converting to.
   QualType getConversionType() const {
-    return getType()->getAsFunctionType()->getResultType();
+    return getType()->getAs<FunctionType>()->getResultType();
   }
 
   // Implement isa/cast/dyncast/etc.
index 4ebda908a30ffc412eacc101f8824a92c80cbaf1..7871830314658519addbb9daf332e7d29ee74595 100644 (file)
@@ -384,8 +384,8 @@ public:
   // Type Predicates: Check to see if this type is structurally the specified
   // type, ignoring typedefs and qualifiers.
   bool isFunctionType() const;
-  bool isFunctionNoProtoType() const { return getAsFunctionNoProtoType() != 0; }
-  bool isFunctionProtoType() const { return getAsFunctionProtoType() != 0; }
+  bool isFunctionNoProtoType() const { return getAs<FunctionNoProtoType>(); }
+  bool isFunctionProtoType() const { return getAs<FunctionProtoType>(); }
   bool isPointerType() const;
   bool isAnyPointerType() const;   // Any C pointer or ObjC object pointer
   bool isBlockPointerType() const;
@@ -440,36 +440,24 @@ public:
   // Type Checking Functions: Check to see if this type is structurally the
   // specified type, ignoring typedefs and qualifiers, and return a pointer to
   // the best type we can.
-  const BuiltinType *getAsBuiltinType() const;
-  const FunctionType *getAsFunctionType() const;
-  const FunctionNoProtoType *getAsFunctionNoProtoType() const;
-  const FunctionProtoType *getAsFunctionProtoType() const;
   const RecordType *getAsStructureType() const;
   /// NOTE: getAs*ArrayType are methods on ASTContext.
-  const TypedefType *getAsTypedefType() const;
   const RecordType *getAsUnionType() const;
-  const EnumType *getAsEnumType() const;
-  const VectorType *getAsVectorType() const; // GCC vector type.
-  const ComplexType *getAsComplexType() const;
   const ComplexType *getAsComplexIntegerType() const; // GCC complex int type.
-  const ExtVectorType *getAsExtVectorType() const; // Extended vector type.
-  const ObjCObjectPointerType *getAsObjCObjectPointerType() const;
   // The following is a convenience method that returns an ObjCObjectPointerType
   // for object declared using an interface.
   const ObjCObjectPointerType *getAsObjCInterfacePointerType() const;
   const ObjCObjectPointerType *getAsObjCQualifiedIdType() const;
-  const ObjCInterfaceType *getAsObjCInterfaceType() const;
   const ObjCInterfaceType *getAsObjCQualifiedInterfaceType() const;
-  const TemplateTypeParmType *getAsTemplateTypeParmType() const;
   const CXXRecordDecl *getCXXRecordDeclForPointerType() const;
 
   // Member-template getAs<specific type>'.  This scheme will eventually
   // replace the specific getAsXXXX methods above.
+  //
+  // There are some specializations of this member template listed
+  // immediately following this class.
   template <typename T> const T *getAs() const;
 
-  const TemplateSpecializationType *
-    getAsTemplateSpecializationType() const;
-
   /// getAsPointerToObjCInterfaceType - If this is a pointer to an ObjC
   /// interface, return the interface type, otherwise return null.
   const ObjCInterfaceType *getAsPointerToObjCInterfaceType() const;
@@ -522,6 +510,20 @@ public:
   static bool classof(const Type *) { return true; }
 };
 
+template <> inline const TypedefType *Type::getAs() const {
+  return dyn_cast<TypedefType>(this);
+}
+
+// We can do canonical leaf types faster, because we don't have to
+// worry about preserving child type decoration.
+#define TYPE(Class, Base)
+#define LEAF_TYPE(Class) \
+template <> inline const Class##Type *Type::getAs() const { \
+  return dyn_cast<Class##Type>(CanonicalType.getUnqualifiedType()); \
+}
+#include "clang/AST/TypeNodes.def"
+
+
 /// ExtQualType - TR18037 (C embedded extensions) 6.2.5p26
 /// This supports all kinds of type attributes; including,
 /// address space qualified types, objective-c's __weak and
@@ -2155,7 +2157,7 @@ public:
   QualType getPointeeType() const { return PointeeType; }
 
   const ObjCInterfaceType *getInterfaceType() const {
-    return PointeeType->getAsObjCInterfaceType();
+    return PointeeType->getAs<ObjCInterfaceType>();
   }
   /// getInterfaceDecl - returns an interface decl for user-defined types.
   ObjCInterfaceDecl *getInterfaceDecl() const {
@@ -2233,7 +2235,7 @@ inline QualType::GCAttrTypes QualType::getObjCGCAttr() const {
       return AT->getElementType().getObjCGCAttr();
   if (const ExtQualType *EXTQT = dyn_cast<ExtQualType>(CT))
     return EXTQT->getObjCGCAttr();
-  if (const ObjCObjectPointerType *PT = CT->getAsObjCObjectPointerType())
+  if (const ObjCObjectPointerType *PT = CT->getAs<ObjCObjectPointerType>())
     return PT->getPointeeType().getObjCGCAttr();
   // We most look at all pointer types, not just pointer to interface types.
   if (const PointerType *PT = CT->getAs<PointerType>())
@@ -2246,9 +2248,9 @@ inline QualType::GCAttrTypes QualType::getObjCGCAttr() const {
 inline bool QualType::getNoReturnAttr() const {
   QualType CT = getTypePtr()->getCanonicalTypeInternal();
   if (const PointerType *PT = getTypePtr()->getAs<PointerType>()) {
-    if (const FunctionType *FT = PT->getPointeeType()->getAsFunctionType())
+    if (const FunctionType *FT = PT->getPointeeType()->getAs<FunctionType>())
       return FT->getNoReturnAttr();
-  } else if (const FunctionType *FT = getTypePtr()->getAsFunctionType())
+  } else if (const FunctionType *FT = getTypePtr()->getAs<FunctionType>())
     return FT->getNoReturnAttr();
 
   return false;
@@ -2295,12 +2297,9 @@ inline QualType QualType::getNonReferenceType() const {
     return *this;
 }
 
-inline const TypedefType* Type::getAsTypedefType() const {
-  return dyn_cast<TypedefType>(this);
-}
 inline const ObjCInterfaceType *Type::getAsPointerToObjCInterfaceType() const {
   if (const PointerType *PT = getAs<PointerType>())
-    return PT->getPointeeType()->getAsObjCInterfaceType();
+    return PT->getPointeeType()->getAs<ObjCInterfaceType>();
   return 0;
 }
 
@@ -2376,22 +2375,22 @@ inline bool Type::isObjCInterfaceType() const {
   return isa<ObjCInterfaceType>(CanonicalType.getUnqualifiedType());
 }
 inline bool Type::isObjCQualifiedIdType() const {
-  if (const ObjCObjectPointerType *OPT = getAsObjCObjectPointerType())
+  if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>())
     return OPT->isObjCQualifiedIdType();
   return false;
 }
 inline bool Type::isObjCQualifiedClassType() const {
-  if (const ObjCObjectPointerType *OPT = getAsObjCObjectPointerType())
+  if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>())
     return OPT->isObjCQualifiedClassType();
   return false;
 }
 inline bool Type::isObjCIdType() const {
-  if (const ObjCObjectPointerType *OPT = getAsObjCObjectPointerType())
+  if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>())
     return OPT->isObjCIdType();
   return false;
 }
 inline bool Type::isObjCClassType() const {
-  if (const ObjCObjectPointerType *OPT = getAsObjCObjectPointerType())
+  if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>())
     return OPT->isObjCClassType();
   return false;
 }
@@ -2403,7 +2402,7 @@ inline bool Type::isTemplateTypeParmType() const {
 }
 
 inline bool Type::isSpecificBuiltinType(unsigned K) const {
-  if (const BuiltinType *BT = getAsBuiltinType())
+  if (const BuiltinType *BT = getAs<BuiltinType>())
     if (BT->getKind() == (BuiltinType::Kind) K)
       return true;
   return false;
index f1d3b362ce348512fe6c3f58d1c6aaa4a0a82788..a2838439c7fc1d92366696670e18e58b546432a6 100644 (file)
 //    type that is always dependent. Clients that do not need to deal
 //    with uninstantiated C++ templates can ignore these types.
 //
+//  There is a fifth macro, independent of the others.  Most clients
+//  will not need to use it.
+//
+//    LEAF_TYPE(Class) - A type that never has inner types.  Clients
+//    which can operate on such types more efficiently may wish to do so.
+//
 //===----------------------------------------------------------------------===//
 
 #ifndef ABSTRACT_TYPE
@@ -83,6 +89,17 @@ DEPENDENT_TYPE(Typename, Type)
 TYPE(ObjCInterface, Type)
 TYPE(ObjCObjectPointer, Type)
 
+// These types are always leaves in the type hierarchy.
+#ifdef LEAF_TYPE
+LEAF_TYPE(Enum)
+LEAF_TYPE(Builtin)
+LEAF_TYPE(FixedWidthInt)
+LEAF_TYPE(ObjCInterface)
+LEAF_TYPE(ObjCObjectPointer)
+LEAF_TYPE(TemplateTypeParm)
+#undef LEAF_TYPE
+#endif
+
 #undef DEPENDENT_TYPE
 #undef NON_CANONICAL_TYPE
 #undef ABSTRACT_TYPE
index 956d9719f9f4080596fd0594fb86c80974ce65fd..36323c260c9a3f8e8ce16c1fd74da2427afdf835 100644 (file)
@@ -91,8 +91,8 @@ NODE_XML(FunctionDecl, "Function")
   ATTRIBUTE_FILE_LOCATION_XML
   ATTRIBUTE_XML(getDeclContext(), "context")
   ATTRIBUTE_XML(getNameAsString(), "name")
-  TYPE_ATTRIBUTE_XML(getType()->getAsFunctionType()->getResultType())
-  ATTRIBUTE_XML(getType()->getAsFunctionType(), "function_type")
+  TYPE_ATTRIBUTE_XML(getType()->getAs<FunctionType>()->getResultType())
+  ATTRIBUTE_XML(getType()->getAs<FunctionType>(), "function_type")
   ATTRIBUTE_ENUM_OPT_XML(getStorageClass(), "storage_class")
          ENUM_XML(FunctionDecl::None, "")
          ENUM_XML(FunctionDecl::Extern, "extern")
@@ -111,8 +111,8 @@ NODE_XML(CXXMethodDecl, "CXXMethodDecl")
   ATTRIBUTE_FILE_LOCATION_XML
   ATTRIBUTE_XML(getDeclContext(), "context")
   ATTRIBUTE_XML(getNameAsString(), "name")
-  TYPE_ATTRIBUTE_XML(getType()->getAsFunctionType()->getResultType())
-  ATTRIBUTE_XML(getType()->getAsFunctionType(), "function_type")
+  TYPE_ATTRIBUTE_XML(getType()->getAs<FunctionType>()->getResultType())
+  ATTRIBUTE_XML(getType()->getAs<FunctionType>(), "function_type")
   ATTRIBUTE_OPT_XML(isInline(), "inline")
   ATTRIBUTE_OPT_XML(isStatic(), "static")       
   ATTRIBUTE_OPT_XML(isVirtual(), "virtual")       
index f701ae47320dccd9e873e6de1a6f450625e77742..a12ac207d910cc68fd7eec71d47cd5802267c2c8 100644 (file)
@@ -487,7 +487,7 @@ const char *ASTContext::getCommentForDecl(const Decl *D) {
 /// getFloatTypeSemantics - Return the APFloat 'semantics' for the specified
 /// scalar floating point type.
 const llvm::fltSemantics &ASTContext::getFloatTypeSemantics(QualType T) const {
-  const BuiltinType *BT = T->getAsBuiltinType();
+  const BuiltinType *BT = T->getAs<BuiltinType>();
   assert(BT && "Not a floating point type!");
   switch (BT->getKind()) {
   default: assert(0 && "Not a floating point type!");
@@ -782,7 +782,7 @@ unsigned ASTContext::getPreferredTypeAlign(const Type *T) {
   unsigned ABIAlign = getTypeAlign(T);
 
   // Double and long long should be naturally aligned if possible.
-  if (const ComplexType* CT = T->getAsComplexType())
+  if (const ComplexType* CT = T->getAs<ComplexType>())
     T = CT->getElementType().getTypePtr();
   if (T->isSpecificBuiltinType(BuiltinType::Double) ||
       T->isSpecificBuiltinType(BuiltinType::LongLong))
@@ -1120,10 +1120,10 @@ QualType ASTContext::getNoReturnType(QualType T) {
   if (!T->isFunctionType())
     assert(0 && "can't noreturn qualify non-pointer to function or block type");
 
-  if (const FunctionNoProtoType *F = T->getAsFunctionNoProtoType()) {
+  if (const FunctionNoProtoType *F = T->getAs<FunctionNoProtoType>()) {
     return getFunctionNoProtoType(F->getResultType(), true);
   }
-  const FunctionProtoType *F = T->getAsFunctionProtoType();
+  const FunctionProtoType *F = T->getAs<FunctionProtoType>();
   return getFunctionType(F->getResultType(), F->arg_type_begin(),
                          F->getNumArgs(), F->isVariadic(), F->getTypeQuals(),
                          F->hasExceptionSpec(), F->hasAnyExceptionSpec(),
@@ -1887,7 +1887,7 @@ ASTContext::getTypenameType(NestedNameSpecifier *NNS,
     QualType CanonType = getCanonicalType(QualType(TemplateId, 0));
     if (CanonNNS != NNS || CanonType != QualType(TemplateId, 0)) {
       const TemplateSpecializationType *CanonTemplateId
-        = CanonType->getAsTemplateSpecializationType();
+        = CanonType->getAs<TemplateSpecializationType>();
       assert(CanonTemplateId &&
              "Canonical type must also be a template specialization type");
       Canon = getTypenameType(CanonNNS, CanonTemplateId);
@@ -2454,11 +2454,11 @@ ASTContext::getConstantArrayElementCount(const ConstantArrayType *CA)  const {
 /// getFloatingRank - Return a relative rank for floating point types.
 /// This routine will assert if passed a built-in type that isn't a float.
 static FloatingRank getFloatingRank(QualType T) {
-  if (const ComplexType *CT = T->getAsComplexType())
+  if (const ComplexType *CT = T->getAs<ComplexType>())
     return getFloatingRank(CT->getElementType());
 
-  assert(T->getAsBuiltinType() && "getFloatingRank(): not a floating type");
-  switch (T->getAsBuiltinType()->getKind()) {
+  assert(T->getAs<BuiltinType>() && "getFloatingRank(): not a floating type");
+  switch (T->getAs<BuiltinType>()->getKind()) {
   default: assert(0 && "getFloatingRank(): not a floating type");
   case BuiltinType::Float:      return FloatRank;
   case BuiltinType::Double:     return DoubleRank;
@@ -2911,7 +2911,7 @@ void ASTContext::getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD,
 ///
 void ASTContext::getLegacyIntegralTypeEncoding (QualType &PointeeTy) const {
   if (isa<TypedefType>(PointeeTy.getTypePtr())) {
-    if (const BuiltinType *BT = PointeeTy->getAsBuiltinType()) {
+    if (const BuiltinType *BT = PointeeTy->getAs<BuiltinType>()) {
       if (BT->getKind() == BuiltinType::ULong &&
           ((const_cast<ASTContext *>(this))->getIntWidth(PointeeTy) == 32))
         PointeeTy = UnsignedIntTy;
@@ -2949,7 +2949,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
                                             const FieldDecl *FD,
                                             bool OutermostType,
                                             bool EncodingProperty) {
-  if (const BuiltinType *BT = T->getAsBuiltinType()) {
+  if (const BuiltinType *BT = T->getAs<BuiltinType>()) {
     if (FD && FD->isBitField())
       return EncodeBitField(this, S, FD);
     char encoding;
@@ -2986,7 +2986,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
     return;
   }
 
-  if (const ComplexType *CT = T->getAsComplexType()) {
+  if (const ComplexType *CT = T->getAs<ComplexType>()) {
     S += 'j';
     getObjCEncodingForTypeImpl(CT->getElementType(), S, false, false, 0, false,
                                false);
@@ -3085,7 +3085,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
     return;
   }
 
-  if (T->getAsFunctionType()) {
+  if (T->getAs<FunctionType>()) {
     S += '?';
     return;
   }
@@ -3141,7 +3141,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
 
   if (T->isObjCInterfaceType()) {
     // @encode(class_name)
-    ObjCInterfaceDecl *OI = T->getAsObjCInterfaceType()->getDecl();
+    ObjCInterfaceDecl *OI = T->getAs<ObjCInterfaceType>()->getDecl();
     S += '{';
     const IdentifierInfo *II = OI->getIdentifier();
     S += II->getName();
@@ -3160,7 +3160,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
     return;
   }
 
-  if (const ObjCObjectPointerType *OPT = T->getAsObjCObjectPointerType()) {
+  if (const ObjCObjectPointerType *OPT = T->getAs<ObjCObjectPointerType>()) {
     if (OPT->isObjCIdType()) {
       S += '@';
       return;
@@ -3250,7 +3250,7 @@ void ASTContext::setObjCIdType(QualType T) {
 void ASTContext::setObjCSelType(QualType T) {
   ObjCSelType = T;
 
-  const TypedefType *TT = T->getAsTypedefType();
+  const TypedefType *TT = T->getAs<TypedefType>();
   if (!TT)
     return;
   TypedefDecl *TD = TT->getDecl();
@@ -3462,7 +3462,7 @@ bool ASTContext::ObjCQualifiedIdTypesAreCompatible(QualType lhs, QualType rhs,
     return true;
 
   if (const ObjCObjectPointerType *lhsQID = lhs->getAsObjCQualifiedIdType()) {
-    const ObjCObjectPointerType *rhsOPT = rhs->getAsObjCObjectPointerType();
+    const ObjCObjectPointerType *rhsOPT = rhs->getAs<ObjCObjectPointerType>();
 
     if (!rhsOPT) return false;
 
@@ -3635,8 +3635,8 @@ bool ASTContext::canAssignObjCInterfaces(const ObjCInterfaceType *LHS,
 
 bool ASTContext::areComparableObjCPointerTypes(QualType LHS, QualType RHS) {
   // get the "pointed to" types
-  const ObjCObjectPointerType *LHSOPT = LHS->getAsObjCObjectPointerType();
-  const ObjCObjectPointerType *RHSOPT = RHS->getAsObjCObjectPointerType();
+  const ObjCObjectPointerType *LHSOPT = LHS->getAs<ObjCObjectPointerType>();
+  const ObjCObjectPointerType *RHSOPT = RHS->getAs<ObjCObjectPointerType>();
 
   if (!LHSOPT || !RHSOPT)
     return false;
@@ -3654,8 +3654,8 @@ bool ASTContext::typesAreCompatible(QualType LHS, QualType RHS) {
 }
 
 QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs) {
-  const FunctionType *lbase = lhs->getAsFunctionType();
-  const FunctionType *rbase = rhs->getAsFunctionType();
+  const FunctionType *lbase = lhs->getAs<FunctionType>();
+  const FunctionType *rbase = rhs->getAs<FunctionType>();
   const FunctionProtoType *lproto = dyn_cast<FunctionProtoType>(lbase);
   const FunctionProtoType *rproto = dyn_cast<FunctionProtoType>(rbase);
   bool allLTypes = true;
@@ -3847,11 +3847,11 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
   if (LHSClass != RHSClass) {
     // C99 6.7.2.2p4: Each enumerated type shall be compatible with char,
     // a signed integer type, or an unsigned integer type.
-    if (const EnumType* ETy = LHS->getAsEnumType()) {
+    if (const EnumType* ETy = LHS->getAs<EnumType>()) {
       if (ETy->getDecl()->getIntegerType() == RHSCan.getUnqualifiedType())
         return RHS;
     }
-    if (const EnumType* ETy = RHS->getAsEnumType()) {
+    if (const EnumType* ETy = RHS->getAs<EnumType>()) {
       if (ETy->getDecl()->getIntegerType() == LHSCan.getUnqualifiedType())
         return LHS;
     }
@@ -3963,15 +3963,15 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
     return QualType();
   case Type::Vector:
     // FIXME: The merged type should be an ExtVector!
-    if (areCompatVectorTypes(LHS->getAsVectorType(), RHS->getAsVectorType()))
+    if (areCompatVectorTypes(LHS->getAs<VectorType>(), RHS->getAs<VectorType>()))
       return LHS;
     return QualType();
   case Type::ObjCInterface: {
     // Check if the interfaces are assignment compatible.
     // FIXME: This should be type compatibility, e.g. whether
     // "LHS x; RHS x;" at global scope is legal.
-    const ObjCInterfaceType* LHSIface = LHS->getAsObjCInterfaceType();
-    const ObjCInterfaceType* RHSIface = RHS->getAsObjCInterfaceType();
+    const ObjCInterfaceType* LHSIface = LHS->getAs<ObjCInterfaceType>();
+    const ObjCInterfaceType* RHSIface = RHS->getAs<ObjCInterfaceType>();
     if (LHSIface && RHSIface &&
         canAssignObjCInterfaces(LHSIface, RHSIface))
       return LHS;
@@ -3979,8 +3979,8 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
     return QualType();
   }
   case Type::ObjCObjectPointer: {
-    if (canAssignObjCInterfaces(LHS->getAsObjCObjectPointerType(),
-                                RHS->getAsObjCObjectPointerType()))
+    if (canAssignObjCInterfaces(LHS->getAs<ObjCObjectPointerType>(),
+                                RHS->getAs<ObjCObjectPointerType>()))
       return LHS;
 
     return QualType();
@@ -4040,9 +4040,9 @@ unsigned ASTContext::getIntWidth(QualType T) {
 
 QualType ASTContext::getCorrespondingUnsignedType(QualType T) {
   assert(T->isSignedIntegerType() && "Unexpected type");
-  if (const EnumType* ETy = T->getAsEnumType())
+  if (const EnumType* ETy = T->getAs<EnumType>())
     T = ETy->getDecl()->getIntegerType();
-  const BuiltinType* BTy = T->getAsBuiltinType();
+  const BuiltinType* BTy = T->getAs<BuiltinType>();
   assert (BTy && "Unexpected signed integer type");
   switch (BTy->getKind()) {
   case BuiltinType::Char_S:
index 77c085a35515ead2945267ddccd5d2ce69ffe040..1a7aaac6f78154082a3b70e4d403161601d33d2b 100644 (file)
@@ -542,7 +542,7 @@ unsigned FunctionDecl::getBuiltinID() const {
 /// based on its FunctionType.  This is the length of the PararmInfo array
 /// after it has been created.
 unsigned FunctionDecl::getNumParams() const {
-  const FunctionType *FT = getType()->getAsFunctionType();
+  const FunctionType *FT = getType()->getAs<FunctionType>();
   if (isa<FunctionNoProtoType>(FT))
     return 0;
   return cast<FunctionProtoType>(FT)->getNumArgs();
index 53e2b840679db44095800679a5fb8f9dc8d076f6..f3ea04305bb3aaa78c4474d37df0988d9f2e4755 100644 (file)
@@ -194,7 +194,7 @@ bool CXXRecordDecl::hasConstCopyAssignment(ASTContext &Context,
       continue;
     // TODO: Skip templates? Or is this implicitly done due to parameter types?
     const FunctionProtoType *FnType =
-      Method->getType()->getAsFunctionProtoType();
+      Method->getType()->getAs<FunctionProtoType>();
     assert(FnType && "Overloaded operator has no prototype.");
     // Don't assert on this; an invalid decl might have been left in the AST.
     if (FnType->getNumArgs() != 1 || FnType->isVariadic())
@@ -256,7 +256,7 @@ CXXRecordDecl::addedConstructor(ASTContext &Context,
 void CXXRecordDecl::addedAssignmentOperator(ASTContext &Context,
                                             CXXMethodDecl *OpDecl) {
   // We're interested specifically in copy assignment operators.
-  const FunctionProtoType *FnType = OpDecl->getType()->getAsFunctionProtoType();
+  const FunctionProtoType *FnType = OpDecl->getType()->getAs<FunctionProtoType>();
   assert(FnType && "Overloaded operator has no proto function type.");
   assert(FnType->getNumArgs() == 1 && !FnType->isVariadic());
   QualType ArgType = FnType->getArgType(0);
@@ -616,7 +616,7 @@ bool CXXConstructorDecl::isConvertingConstructor(bool AllowExplicit) const {
     return false;
 
   return (getNumParams() == 0 &&
-          getType()->getAsFunctionProtoType()->isVariadic()) ||
+          getType()->getAs<FunctionProtoType>()->isVariadic()) ||
          (getNumParams() == 1) ||
          (getNumParams() > 1 && getParamDecl(1)->hasDefaultArg());
 }
index 8aae742ef1a778b2e47a8930f588e40805de547e..f448144d2821d678be452098aff7678ebc771409 100644 (file)
@@ -97,9 +97,9 @@ static QualType GetBaseType(QualType T) {
       BaseType = PTy->getPointeeType();
     else if (const ArrayType* ATy = dyn_cast<ArrayType>(BaseType))
       BaseType = ATy->getElementType();
-    else if (const FunctionType* FTy = BaseType->getAsFunctionType())
+    else if (const FunctionType* FTy = BaseType->getAs<FunctionType>())
       BaseType = FTy->getResultType();
-    else if (const VectorType *VTy = BaseType->getAsVectorType())
+    else if (const VectorType *VTy = BaseType->getAs<VectorType>())
       BaseType = VTy->getElementType();
     else
       assert(0 && "Unknown declarator!");
@@ -332,7 +332,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
   SubPolicy.SuppressSpecifiers = false;
   std::string Proto = D->getNameAsString();
   if (isa<FunctionType>(D->getType().getTypePtr())) {
-    const FunctionType *AFT = D->getType()->getAsFunctionType();
+    const FunctionType *AFT = D->getType()->getAs<FunctionType>();
 
     const FunctionProtoType *FT = 0;
     if (D->hasWrittenPrototype())
index 60458b4fb6ec8941f882440496645bf120adc7ba..6e46c4f701a479a9edb6c9a7c08cab5626827d21 100644 (file)
@@ -51,7 +51,7 @@ std::string PredefinedExpr::ComputeName(ASTContext &Context, IdentType IT,
 
     std::string Proto = FD->getQualifiedNameAsString(Policy);
 
-    const FunctionType *AFT = FD->getType()->getAsFunctionType();
+    const FunctionType *AFT = FD->getType()->getAs<FunctionType>();
     const FunctionProtoType *FT = 0;
     if (FD->hasWrittenPrototype())
       FT = dyn_cast<FunctionProtoType>(AFT);
@@ -335,7 +335,7 @@ QualType CallExpr::getCallReturnType() const {
   else if (const BlockPointerType *BPT = CalleeType->getAs<BlockPointerType>())
     CalleeType = BPT->getPointeeType();
 
-  const FunctionType *FnType = CalleeType->getAsFunctionType();
+  const FunctionType *FnType = CalleeType->getAs<FunctionType>();
   return FnType->getResultType();
 }
 
@@ -575,7 +575,7 @@ Expr *InitListExpr::updateInit(unsigned Init, Expr *expr) {
 ///
 const FunctionType *BlockExpr::getFunctionType() const {
   return getType()->getAs<BlockPointerType>()->
-                    getPointeeType()->getAsFunctionType();
+                    getPointeeType()->getAs<FunctionType>();
 }
 
 SourceLocation BlockExpr::getCaretLocation() const {
@@ -1693,7 +1693,7 @@ bool ExtVectorElementExpr::isArrow() const {
 }
 
 unsigned ExtVectorElementExpr::getNumElements() const {
-  if (const VectorType *VT = getType()->getAsVectorType())
+  if (const VectorType *VT = getType()->getAs<VectorType>())
     return VT->getNumElements();
   return 1;
 }
index 8df52c9377a57f48cdad31d3d43eea8fea739c0c..9c34547db1adc04b7dfd5cb6ef878c1f3aabdd1e 100644 (file)
@@ -487,7 +487,7 @@ static bool EvaluateVector(const Expr* E, APValue& Result, EvalInfo &Info) {
 }
 
 APValue VectorExprEvaluator::VisitCastExpr(const CastExpr* E) {
-  const VectorType *VTy = E->getType()->getAsVectorType();
+  const VectorType *VTy = E->getType()->getAs<VectorType>();
   QualType EltTy = VTy->getElementType();
   unsigned NElts = VTy->getNumElements();
   unsigned EltWidth = Info.Ctx.getTypeSize(EltTy);
@@ -566,7 +566,7 @@ VectorExprEvaluator::VisitCompoundLiteralExpr(const CompoundLiteralExpr *E) {
 
 APValue
 VectorExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
-  const VectorType *VT = E->getType()->getAsVectorType();
+  const VectorType *VT = E->getType()->getAs<VectorType>();
   unsigned NumInits = E->getNumInits();
   unsigned NumElements = VT->getNumElements();
 
@@ -599,7 +599,7 @@ VectorExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
 
 APValue
 VectorExprEvaluator::GetZeroVector(QualType T) {
-  const VectorType *VT = T->getAsVectorType();
+  const VectorType *VT = T->getAs<VectorType>();
   QualType EltTy = VT->getElementType();
   APValue ZeroElement;
   if (EltTy->isIntegerType())
@@ -1575,7 +1575,7 @@ public:
 
   APValue VisitCastExpr(CastExpr *E) {
     Expr* SubExpr = E->getSubExpr();
-    QualType EltType = E->getType()->getAsComplexType()->getElementType();
+    QualType EltType = E->getType()->getAs<ComplexType>()->getElementType();
     QualType SubType = SubExpr->getType();
 
     if (SubType->isRealFloatingType()) {
@@ -1612,7 +1612,7 @@ public:
         Zero = 0;
         return APValue(Result, Zero);
       }
-    } else if (const ComplexType *CT = SubType->getAsComplexType()) {
+    } else if (const ComplexType *CT = SubType->getAs<ComplexType>()) {
       APValue Src;
 
       if (!EvaluateComplex(SubExpr, Src, Info))
index a6f2b823fe6d4b769e3d385de036ab68da0c48c4..05d0c26835456e5b5682177332a6f804442983d1 100644 (file)
@@ -595,7 +595,7 @@ void StmtPrinter::VisitIntegerLiteral(IntegerLiteral *Node) {
   OS << Node->getValue().toString(10, isSigned);
 
   // Emit suffixes.  Integer literals are always a builtin integer type.
-  switch (Node->getType()->getAsBuiltinType()->getKind()) {
+  switch (Node->getType()->getAs<BuiltinType>()->getKind()) {
   default: assert(0 && "Unexpected type for integer literal!");
   case BuiltinType::Int:       break; // no suffix.
   case BuiltinType::UInt:      OS << 'U'; break;
index 1a6ea0a136676744228e7cf831132409ffe74045..278321166161c21accdac6742279d7dd72f698f0 100644 (file)
@@ -159,7 +159,7 @@ QualType Type::getDesugaredType(bool ForDisplay) const {
       return QualType(this, 0);
 
     QualType Canon = Spec->getCanonicalTypeInternal();
-    if (Canon->getAsTemplateSpecializationType())
+    if (Canon->getAs<TemplateSpecializationType>())
       return QualType(this, 0);
     return Canon->getDesugaredType();
   }
@@ -276,54 +276,10 @@ const ComplexType *Type::getAsComplexIntegerType() const {
   return cast<ComplexType>(getDesugaredType());
 }
 
-const BuiltinType *Type::getAsBuiltinType() const {
-  // If this is directly a builtin type, return it.
-  if (const BuiltinType *BTy = dyn_cast<BuiltinType>(this))
-    return BTy;
-
-  // If the canonical form of this type isn't a builtin type, reject it.
-  if (!isa<BuiltinType>(CanonicalType)) {
-    // Look through type qualifiers (e.g. ExtQualType's).
-    if (isa<BuiltinType>(CanonicalType.getUnqualifiedType()))
-      return CanonicalType.getUnqualifiedType()->getAsBuiltinType();
-    return 0;
-  }
-
-  // If this is a typedef for a builtin type, strip the typedef off without
-  // losing all typedef information.
-  return cast<BuiltinType>(getDesugaredType());
-}
-
-const FunctionType *Type::getAsFunctionType() const {
-  // If this is directly a function type, return it.
-  if (const FunctionType *FTy = dyn_cast<FunctionType>(this))
-    return FTy;
-
-  // If the canonical form of this type isn't the right kind, reject it.
-  if (!isa<FunctionType>(CanonicalType)) {
-    // Look through type qualifiers
-    if (isa<FunctionType>(CanonicalType.getUnqualifiedType()))
-      return CanonicalType.getUnqualifiedType()->getAsFunctionType();
-    return 0;
-  }
-
-  // If this is a typedef for a function type, strip the typedef off without
-  // losing all typedef information.
-  return cast<FunctionType>(getDesugaredType());
-}
-
-const FunctionNoProtoType *Type::getAsFunctionNoProtoType() const {
-  return dyn_cast_or_null<FunctionNoProtoType>(getAsFunctionType());
-}
-
-const FunctionProtoType *Type::getAsFunctionProtoType() const {
-  return dyn_cast_or_null<FunctionProtoType>(getAsFunctionType());
-}
-
 QualType Type::getPointeeType() const {
   if (const PointerType *PT = getAs<PointerType>())
     return PT->getPointeeType();
-  if (const ObjCObjectPointerType *OPT = getAsObjCObjectPointerType())
+  if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>())
     return OPT->getPointeeType();
   if (const BlockPointerType *BPT = getAs<BlockPointerType>())
     return BPT->getPointeeType();
@@ -357,7 +313,7 @@ bool Type::isVariablyModifiedType() const {
   // This one isn't completely obvious, but it follows from the
   // definition in C99 6.7.5p3. Because of this rule, it's
   // illegal to declare a function returning a variably modified type.
-  if (const FunctionType *FT = getAsFunctionType())
+  if (const FunctionType *FT = getAs<FunctionType>())
     return FT->getResultType()->isVariablyModifiedType();
 
   return false;
@@ -408,79 +364,11 @@ const RecordType *Type::getAsUnionType() const {
   return 0;
 }
 
-const EnumType *Type::getAsEnumType() const {
-  // Check the canonicalized unqualified type directly; the more complex
-  // version is unnecessary because there isn't any typedef information
-  // to preserve.
-  return dyn_cast<EnumType>(CanonicalType.getUnqualifiedType());
-}
-
-const ComplexType *Type::getAsComplexType() const {
-  // Are we directly a complex type?
-  if (const ComplexType *CTy = dyn_cast<ComplexType>(this))
-    return CTy;
-
-  // If the canonical form of this type isn't the right kind, reject it.
-  if (!isa<ComplexType>(CanonicalType)) {
-    // Look through type qualifiers
-    if (isa<ComplexType>(CanonicalType.getUnqualifiedType()))
-      return CanonicalType.getUnqualifiedType()->getAsComplexType();
-    return 0;
-  }
-
-  // If this is a typedef for a complex type, strip the typedef off without
-  // losing all typedef information.
-  return cast<ComplexType>(getDesugaredType());
-}
-
-const VectorType *Type::getAsVectorType() const {
-  // Are we directly a vector type?
-  if (const VectorType *VTy = dyn_cast<VectorType>(this))
-    return VTy;
-
-  // If the canonical form of this type isn't the right kind, reject it.
-  if (!isa<VectorType>(CanonicalType)) {
-    // Look through type qualifiers
-    if (isa<VectorType>(CanonicalType.getUnqualifiedType()))
-      return CanonicalType.getUnqualifiedType()->getAsVectorType();
-    return 0;
-  }
-
-  // If this is a typedef for a vector type, strip the typedef off without
-  // losing all typedef information.
-  return cast<VectorType>(getDesugaredType());
-}
-
-const ExtVectorType *Type::getAsExtVectorType() const {
-  // Are we directly an OpenCU vector type?
-  if (const ExtVectorType *VTy = dyn_cast<ExtVectorType>(this))
-    return VTy;
-
-  // If the canonical form of this type isn't the right kind, reject it.
-  if (!isa<ExtVectorType>(CanonicalType)) {
-    // Look through type qualifiers
-    if (isa<ExtVectorType>(CanonicalType.getUnqualifiedType()))
-      return CanonicalType.getUnqualifiedType()->getAsExtVectorType();
-    return 0;
-  }
-
-  // If this is a typedef for an extended vector type, strip the typedef off
-  // without losing all typedef information.
-  return cast<ExtVectorType>(getDesugaredType());
-}
-
-const ObjCInterfaceType *Type::getAsObjCInterfaceType() const {
-  // There is no sugar for ObjCInterfaceType's, just return the canonical
-  // type pointer if it is the right class.  There is no typedef information to
-  // return and these cannot be Address-space qualified.
-  return dyn_cast<ObjCInterfaceType>(CanonicalType.getUnqualifiedType());
-}
-
 const ObjCInterfaceType *Type::getAsObjCQualifiedInterfaceType() const {
   // There is no sugar for ObjCInterfaceType's, just return the canonical
   // type pointer if it is the right class.  There is no typedef information to
   // return and these cannot be Address-space qualified.
-  if (const ObjCInterfaceType *OIT = getAsObjCInterfaceType())
+  if (const ObjCInterfaceType *OIT = getAs<ObjCInterfaceType>())
     if (OIT->getNumProtocols())
       return OIT;
   return 0;
@@ -490,16 +378,10 @@ bool Type::isObjCQualifiedInterfaceType() const {
   return getAsObjCQualifiedInterfaceType() != 0;
 }
 
-const ObjCObjectPointerType *Type::getAsObjCObjectPointerType() const {
-  // There is no sugar for ObjCObjectPointerType's, just return the
-  // canonical type pointer if it is the right class.
-  return dyn_cast<ObjCObjectPointerType>(CanonicalType.getUnqualifiedType());
-}
-
 const ObjCObjectPointerType *Type::getAsObjCQualifiedIdType() const {
   // There is no sugar for ObjCQualifiedIdType's, just return the canonical
   // type pointer if it is the right class.
-  if (const ObjCObjectPointerType *OPT = getAsObjCObjectPointerType()) {
+  if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>()) {
     if (OPT->isObjCQualifiedIdType())
       return OPT;
   }
@@ -507,20 +389,13 @@ const ObjCObjectPointerType *Type::getAsObjCQualifiedIdType() const {
 }
 
 const ObjCObjectPointerType *Type::getAsObjCInterfacePointerType() const {
-  if (const ObjCObjectPointerType *OPT = getAsObjCObjectPointerType()) {
+  if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>()) {
     if (OPT->getInterfaceType())
       return OPT;
   }
   return 0;
 }
 
-const TemplateTypeParmType *Type::getAsTemplateTypeParmType() const {
-  // There is no sugar for template type parameters, so just return
-  // the canonical type pointer if it is the right class.
-  // FIXME: can these be address-space qualified?
-  return dyn_cast<TemplateTypeParmType>(CanonicalType);
-}
-
 const CXXRecordDecl *Type::getCXXRecordDeclForPointerType() const {
   if (const PointerType *PT = getAs<PointerType>())
     if (const RecordType *RT = PT->getPointeeType()->getAs<RecordType>())
@@ -528,13 +403,6 @@ const CXXRecordDecl *Type::getCXXRecordDeclForPointerType() const {
   return 0;
 }
 
-const TemplateSpecializationType *
-Type::getAsTemplateSpecializationType() const {
-  // There is no sugar for class template specialization types, so
-  // just return the canonical type pointer if it is the right class.
-  return this->getAs<TemplateSpecializationType>();
-}
-
 bool Type::isIntegerType() const {
   if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
     return BT->getKind() >= BuiltinType::Bool &&
@@ -826,7 +694,7 @@ bool Type::isPODType() const {
 }
 
 bool Type::isPromotableIntegerType() const {
-  if (const BuiltinType *BT = getAsBuiltinType())
+  if (const BuiltinType *BT = getAs<BuiltinType>())
     switch (BT->getKind()) {
     case BuiltinType::Bool:
     case BuiltinType::Char_S:
@@ -843,7 +711,7 @@ bool Type::isPromotableIntegerType() const {
 }
 
 bool Type::isNullPtrType() const {
-  if (const BuiltinType *BT = getAsBuiltinType())
+  if (const BuiltinType *BT = getAs<BuiltinType>())
     return BT->getKind() == BuiltinType::NullPtr;
   return false;
 }
index 9c20089b4f3cfdc6f7ff3ad96f14e7309083ba36..af300f36fa7219ed7532530315e348bcba548651 100644 (file)
@@ -38,7 +38,7 @@ static const ObjCInterfaceType* GetReceiverType(const ObjCMessageExpr* ME) {
     return NULL;
 
   if (const ObjCObjectPointerType *PT =
-      Receiver->getType()->getAsObjCObjectPointerType())
+      Receiver->getType()->getAs<ObjCObjectPointerType>())
     return PT->getInterfaceType();
 
   return NULL;
index 86edfb946cc78cd1c1dce33523f539fa5550e19f..81ebccb76a0a1332959351dbb8182d5c5658871a 100644 (file)
@@ -553,7 +553,7 @@ public:
 
   const ObjCInterfaceDecl* getReceiverDecl(Expr* E) {
     if (const ObjCObjectPointerType* PT =
-        E->getType()->getAsObjCObjectPointerType())
+        E->getType()->getAs<ObjCObjectPointerType>())
       return PT->getInterfaceDecl();
 
     return NULL;
@@ -886,7 +886,7 @@ bool RetainSummaryManager::isTrackedObjCObjectType(QualType Ty) {
   if (!Ty->isObjCObjectPointerType())
     return false;
 
-  const ObjCObjectPointerType *PT = Ty->getAsObjCObjectPointerType();
+  const ObjCObjectPointerType *PT = Ty->getAs<ObjCObjectPointerType>();
 
   // Can be true for objects with the 'NSObject' attribute.
   if (!PT)
@@ -953,9 +953,9 @@ RetainSummary* RetainSummaryManager::getSummary(FunctionDecl* FD) {
       break;
     }
 
-    // [PR 3337] Use 'getAsFunctionType' to strip away any typedefs on the
+    // [PR 3337] Use 'getAs<FunctionType>' to strip away any typedefs on the
     // function's type.
-    const FunctionType* FT = FD->getType()->getAsFunctionType();
+    const FunctionType* FT = FD->getType()->getAs<FunctionType>();
     const char* FName = FD->getIdentifier()->getName();
 
     // Strip away preceding '_'.  Doing this here will effect all the checks
@@ -2739,7 +2739,7 @@ static QualType GetReturnType(const Expr* RetE, ASTContext& Ctx) {
   // If RetE is a message expression, return its types if it is something
   /// more specific than id.
   if (const ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(RetE))
-    if (const ObjCObjectPointerType *PT = RetTy->getAsObjCObjectPointerType())
+    if (const ObjCObjectPointerType *PT = RetTy->getAs<ObjCObjectPointerType>())
       if (PT->isObjCQualifiedIdType() || PT->isObjCIdType() ||
           PT->isObjCClassType()) {
         // At this point we know the return type of the message expression is
@@ -3012,7 +3012,7 @@ void CFRefCount::EvalObjCMessageExpr(ExplodedNodeSet& Dst,
     if (Sym) {
       if (const RefVal* T  = St->get<RefBindings>(Sym)) {
         if (const ObjCObjectPointerType* PT =
-            T->getType()->getAsObjCObjectPointerType())
+            T->getType()->getAs<ObjCObjectPointerType>())
           ID = PT->getInterfaceDecl();
       }
     }
@@ -3021,7 +3021,7 @@ void CFRefCount::EvalObjCMessageExpr(ExplodedNodeSet& Dst,
     //  that is called.
     if (!ID) {
       if (const ObjCObjectPointerType *PT =
-          Receiver->getType()->getAsObjCObjectPointerType())
+          Receiver->getType()->getAs<ObjCObjectPointerType>())
         ID = PT->getInterfaceDecl();
     }
 
index 7e596435d00d09febf2187d2ce6e9029eb3744fa..8086da588264b40aa731d8b29bcc27455f25ccc0 100644 (file)
@@ -166,7 +166,7 @@ bool NSErrorCheck::CheckNSErrorArgument(QualType ArgTy) {
     return false;
 
   const ObjCObjectPointerType* PT =
-    PPT->getPointeeType()->getAsObjCObjectPointerType();
+    PPT->getPointeeType()->getAs<ObjCObjectPointerType>();
 
   if (!PT)
     return false;
@@ -185,7 +185,7 @@ bool NSErrorCheck::CheckCFErrorArgument(QualType ArgTy) {
   const PointerType* PPT = ArgTy->getAs<PointerType>();
   if (!PPT) return false;
 
-  const TypedefType* TT = PPT->getPointeeType()->getAsTypedefType();
+  const TypedefType* TT = PPT->getPointeeType()->getAs<TypedefType>();
   if (!TT) return false;
 
   return TT->getDecl()->getIdentifier() == II;
index 821dbbf2675aea93121b2ca33b519c882047e8dc..3e9ed5b7f33b9b87ec3fcb8c436e004a6ab734dd 100644 (file)
@@ -1590,7 +1590,7 @@ void GRExprEngine::VisitCall(CallExpr* CE, ExplodedNode* Pred,
   const FunctionProtoType *Proto = NULL;
   QualType FnType = CE->getCallee()->IgnoreParens()->getType();
   if (const PointerType *FnTypePtr = FnType->getAs<PointerType>())
-    Proto = FnTypePtr->getPointeeType()->getAsFunctionProtoType();
+    Proto = FnTypePtr->getPointeeType()->getAs<FunctionProtoType>();
 
   VisitCallRec(CE, Pred, AI, AE, Dst, Proto, /*ParamIdx=*/0);
 }
index f4f2fecc2143806aed80978d282e1505c8fa6164..8b5848f5236a7338186081c8a83ac6ef316d62a6 100644 (file)
@@ -756,7 +756,7 @@ SVal RegionStoreManager::EvalBinOp(const GRState *state,
       if (const PointerType *PT = T->getAs<PointerType>())
         EleTy = PT->getPointeeType();
       else
-        EleTy = T->getAsObjCObjectPointerType()->getPointeeType();
+        EleTy = T->getAs<ObjCObjectPointerType>()->getPointeeType();
 
       SVal ZeroIdx = ValMgr.makeZeroArrayIndex();
       ER = MRMgr.getElementRegion(EleTy, ZeroIdx, SR, getContext());
index 59e2ee822ee05b3110331b573c963616dc6b9ca0..41b49c7d7efc5aa80de102b3bfb09fc6b1bdb443 100644 (file)
@@ -417,13 +417,13 @@ RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E) {
   QualType FnType = BPT->getPointeeType();
 
   // And the rest of the arguments.
-  EmitCallArgs(Args, FnType->getAsFunctionProtoType(),
+  EmitCallArgs(Args, FnType->getAs<FunctionProtoType>(),
                E->arg_begin(), E->arg_end());
 
   // Load the function.
   llvm::Value *Func = Builder.CreateLoad(FuncPtr, false, "tmp");
 
-  QualType ResultType = FnType->getAsFunctionType()->getResultType();
+  QualType ResultType = FnType->getAs<FunctionType>()->getResultType();
 
   const CGFunctionInfo &FnInfo =
     CGM.getTypes().getFunctionInfo(ResultType, Args);
index 715f1b0d0d1929bce2ce399d50c14b663d9a9f35..91b984ac2ca1b277f00a4fbb2ab53e7a31304db3 100644 (file)
@@ -183,7 +183,7 @@ RValue CodeGenFunction::EmitCXXMemberCall(const CXXMethodDecl *MD,
     if (Destructor->isTrivial())
       return RValue::get(0);
 
-  const FunctionProtoType *FPT = MD->getType()->getAsFunctionProtoType();
+  const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>();
 
   CallArgList Args;
 
@@ -194,7 +194,7 @@ RValue CodeGenFunction::EmitCXXMemberCall(const CXXMethodDecl *MD,
   // And the rest of the call args
   EmitCallArgs(Args, FPT, ArgBeg, ArgEnd);
 
-  QualType ResultType = MD->getType()->getAsFunctionType()->getResultType();
+  QualType ResultType = MD->getType()->getAs<FunctionType>()->getResultType();
   return EmitCall(CGM.getTypes().getFunctionInfo(ResultType, Args),
                   Callee, Args, MD);
 }
@@ -203,7 +203,7 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE) {
   const MemberExpr *ME = cast<MemberExpr>(CE->getCallee());
   const CXXMethodDecl *MD = cast<CXXMethodDecl>(ME->getMemberDecl());
 
-  const FunctionProtoType *FPT = MD->getType()->getAsFunctionProtoType();
+  const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>();
 
   const llvm::Type *Ty =
     CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD),
@@ -252,7 +252,7 @@ CodeGenFunction::EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E,
     }
   }
 
-  const FunctionProtoType *FPT = MD->getType()->getAsFunctionProtoType();
+  const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>();
   const llvm::Type *Ty =
     CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD),
                                    FPT->isVariadic());
@@ -461,7 +461,7 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) {
 
   QualType AllocType = E->getAllocatedType();
   FunctionDecl *NewFD = E->getOperatorNew();
-  const FunctionProtoType *NewFTy = NewFD->getType()->getAsFunctionProtoType();
+  const FunctionProtoType *NewFTy = NewFD->getType()->getAs<FunctionProtoType>();
 
   CallArgList NewArgs;
 
@@ -623,7 +623,7 @@ void CodeGenFunction::EmitCXXDeleteExpr(const CXXDeleteExpr *E) {
   // Call delete.
   FunctionDecl *DeleteFD = E->getOperatorDelete();
   const FunctionProtoType *DeleteFTy =
-    DeleteFD->getType()->getAsFunctionProtoType();
+    DeleteFD->getType()->getAs<FunctionProtoType>();
 
   CallArgList DeleteArgs;
 
@@ -872,9 +872,9 @@ public:
         // FIXME: begin_overridden_methods might be too lax, covariance */
         if (submethods[i] != om)
           continue;
-        QualType nc_oret = OMD->getType()->getAsFunctionType()->getResultType();
+        QualType nc_oret = OMD->getType()->getAs<FunctionType>()->getResultType();
         CanQualType oret = CGM.getContext().getCanonicalType(nc_oret);
-        QualType nc_ret = MD->getType()->getAsFunctionType()->getResultType();
+        QualType nc_ret = MD->getType()->getAs<FunctionType>()->getResultType();
         CanQualType ret = CGM.getContext().getCanonicalType(nc_ret);
         CallOffset ReturnOffset = std::make_pair(0, 0);
         if (oret != ret) {
@@ -1262,7 +1262,7 @@ llvm::Constant *CodeGenFunction::GenerateThunk(llvm::Function *Fn,
                                                const CXXMethodDecl *MD,
                                                bool Extern, int64_t nv,
                                                int64_t v) {
-  QualType R = MD->getType()->getAsFunctionType()->getResultType();
+  QualType R = MD->getType()->getAs<FunctionType>()->getResultType();
 
   FunctionArgList Args;
   ImplicitParamDecl *ThisDecl =
@@ -1297,7 +1297,7 @@ llvm::Constant *CodeGenFunction::GenerateCovariantThunk(llvm::Function *Fn,
                                                         int64_t v_t,
                                                         int64_t nv_r,
                                                         int64_t v_r) {
-  QualType R = MD->getType()->getAsFunctionType()->getResultType();
+  QualType R = MD->getType()->getAs<FunctionType>()->getResultType();
 
   FunctionArgList Args;
   ImplicitParamDecl *ThisDecl =
@@ -1335,7 +1335,7 @@ llvm::Constant *CodeGenModule::BuildThunk(const CXXMethodDecl *MD, bool Extern,
   if (!Extern)
     linktype = llvm::GlobalValue::InternalLinkage;
   llvm::Type *Ptr8Ty=llvm::PointerType::get(llvm::Type::getInt8Ty(VMContext),0);
-  const FunctionProtoType *FPT = MD->getType()->getAsFunctionProtoType();
+  const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>();
   const llvm::FunctionType *FTy =
     getTypes().GetFunctionType(getTypes().getFunctionInfo(MD),
                                FPT->isVariadic());
@@ -1360,7 +1360,7 @@ llvm::Constant *CodeGenModule::BuildCovariantThunk(const CXXMethodDecl *MD,
   if (!Extern)
     linktype = llvm::GlobalValue::InternalLinkage;
   llvm::Type *Ptr8Ty=llvm::PointerType::get(llvm::Type::getInt8Ty(VMContext),0);
-  const FunctionProtoType *FPT = MD->getType()->getAsFunctionProtoType();
+  const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>();
   const llvm::FunctionType *FTy =
     getTypes().GetFunctionType(getTypes().getFunctionInfo(MD),
                                FPT->isVariadic());
@@ -1454,7 +1454,7 @@ void CodeGenFunction::EmitClassAggrMemberwiseCopy(llvm::Value *Dest,
     CallArgs.push_back(std::make_pair(RValue::get(Src),
                                       BaseCopyCtor->getParamDecl(0)->getType()));
     QualType ResultType =
-      BaseCopyCtor->getType()->getAsFunctionType()->getResultType();
+      BaseCopyCtor->getType()->getAs<FunctionType>()->getResultType();
     EmitCall(CGM.getTypes().getFunctionInfo(ResultType, CallArgs),
              Callee, CallArgs, BaseCopyCtor);
   }
@@ -1524,7 +1524,7 @@ void CodeGenFunction::EmitClassAggrCopyAssignment(llvm::Value *Dest,
                                                                MD);
     assert(hasCopyAssign && "EmitClassAggrCopyAssignment - No user assign");
     (void)hasCopyAssign;
-    const FunctionProtoType *FPT = MD->getType()->getAsFunctionProtoType();
+    const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>();
     const llvm::Type *LTy =
     CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD),
                                    FPT->isVariadic());
@@ -1538,7 +1538,7 @@ void CodeGenFunction::EmitClassAggrCopyAssignment(llvm::Value *Dest,
     // Push the Src ptr.
     CallArgs.push_back(std::make_pair(RValue::get(Src),
                                       MD->getParamDecl(0)->getType()));
-    QualType ResultType = MD->getType()->getAsFunctionType()->getResultType();
+    QualType ResultType = MD->getType()->getAs<FunctionType>()->getResultType();
     EmitCall(CGM.getTypes().getFunctionInfo(ResultType, CallArgs),
              Callee, CallArgs, MD);
   }
@@ -1588,7 +1588,7 @@ void CodeGenFunction::EmitClassMemberwiseCopy(
     CallArgs.push_back(std::make_pair(RValue::get(Src),
                        BaseCopyCtor->getParamDecl(0)->getType()));
     QualType ResultType =
-    BaseCopyCtor->getType()->getAsFunctionType()->getResultType();
+    BaseCopyCtor->getType()->getAs<FunctionType>()->getResultType();
     EmitCall(CGM.getTypes().getFunctionInfo(ResultType, CallArgs),
              Callee, CallArgs, BaseCopyCtor);
   }
@@ -1620,7 +1620,7 @@ void CodeGenFunction::EmitClassCopyAssignment(
   assert(ConstCopyAssignOp && "EmitClassCopyAssignment - missing copy assign");
   (void)ConstCopyAssignOp;
 
-  const FunctionProtoType *FPT = MD->getType()->getAsFunctionProtoType();
+  const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>();
   const llvm::Type *LTy =
     CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD),
                                    FPT->isVariadic());
@@ -1635,7 +1635,7 @@ void CodeGenFunction::EmitClassCopyAssignment(
   CallArgs.push_back(std::make_pair(RValue::get(Src),
                                     MD->getParamDecl(0)->getType()));
   QualType ResultType =
-    MD->getType()->getAsFunctionType()->getResultType();
+    MD->getType()->getAs<FunctionType>()->getResultType();
   EmitCall(CGM.getTypes().getFunctionInfo(ResultType, CallArgs),
            Callee, CallArgs, MD);
 }
index c58c0f6fbf0cfe2a4d59b4ba3162ba250928e6b3..1dbb6e67f26b21a13c69df73396590f8e6d43d79 100644 (file)
@@ -69,7 +69,7 @@ const CGFunctionInfo &CodeGenTypes::getFunctionInfo(const CXXMethodDecl *MD) {
   if (MD->isInstance())
     ArgTys.push_back(MD->getThisType(Context));
 
-  const FunctionProtoType *FTP = MD->getType()->getAsFunctionProtoType();
+  const FunctionProtoType *FTP = MD->getType()->getAs<FunctionProtoType>();
   for (unsigned i = 0, e = FTP->getNumArgs(); i != e; ++i)
     ArgTys.push_back(FTP->getArgType(i));
   return getFunctionInfo(FTP->getResultType(), ArgTys,
@@ -82,7 +82,7 @@ const CGFunctionInfo &CodeGenTypes::getFunctionInfo(const FunctionDecl *FD) {
       return getFunctionInfo(MD);
 
   unsigned CallingConvention = getCallingConventionForDecl(FD);
-  const FunctionType *FTy = FD->getType()->getAsFunctionType();
+  const FunctionType *FTy = FD->getType()->getAs<FunctionType>();
   if (const FunctionNoProtoType *FNTP = dyn_cast<FunctionNoProtoType>(FTy))
     return getFunctionInfo(FNTP->getResultType(), 
                            llvm::SmallVector<QualType, 16>(),
index 2539387e96758ed067666f65f44e06cc2aedffe2..a7eebbf1fd1ef1fa6634d4c265e29a51fd8b85e3 100644 (file)
@@ -143,7 +143,7 @@ unsigned CodeGenFunction::getAccessedFieldNo(unsigned Idx,
 RValue CodeGenFunction::GetUndefRValue(QualType Ty) {
   if (Ty->isVoidType()) {
     return RValue::get(0);
-  } else if (const ComplexType *CTy = Ty->getAsComplexType()) {
+  } else if (const ComplexType *CTy = Ty->getAs<ComplexType>()) {
     const llvm::Type *EltTy = ConvertType(CTy->getElementType());
     llvm::Value *U = llvm::UndefValue::get(EltTy);
     return RValue::getComplex(std::make_pair(U, U));
@@ -420,7 +420,7 @@ RValue CodeGenFunction::EmitLoadOfExtVectorElementLValue(LValue LV,
 
   // If the result of the expression is a non-vector type, we must be extracting
   // a single element.  Just codegen as an extractelement.
-  const VectorType *ExprVT = ExprType->getAsVectorType();
+  const VectorType *ExprVT = ExprType->getAs<VectorType>();
   if (!ExprVT) {
     unsigned InIdx = getAccessedFieldNo(0, Elts);
     llvm::Value *Elt = llvm::ConstantInt::get(
@@ -619,7 +619,7 @@ void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src,
 
   llvm::Value *SrcVal = Src.getScalarVal();
 
-  if (const VectorType *VTy = Ty->getAsVectorType()) {
+  if (const VectorType *VTy = Ty->getAs<VectorType>()) {
     unsigned NumSrcElts = VTy->getNumElements();
     unsigned NumDstElts =
        cast<llvm::VectorType>(Vec->getType())->getNumElements();
@@ -784,7 +784,7 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
     llvm::Value* V = CGM.GetAddrOfFunction(FD);
     if (!FD->hasPrototype()) {
       if (const FunctionProtoType *Proto =
-              FD->getType()->getAsFunctionProtoType()) {
+              FD->getType()->getAs<FunctionProtoType>()) {
         // Ugly case: for a K&R-style definition, the type of the definition
         // isn't the same as the type of a use.  Correct for this with a
         // bitcast.
@@ -1470,10 +1470,10 @@ RValue CodeGenFunction::EmitCall(llvm::Value *Callee, QualType CalleeType,
          "Call must have function pointer type!");
 
   QualType FnType = CalleeType->getAs<PointerType>()->getPointeeType();
-  QualType ResultType = FnType->getAsFunctionType()->getResultType();
+  QualType ResultType = FnType->getAs<FunctionType>()->getResultType();
 
   CallArgList Args;
-  EmitCallArgs(Args, FnType->getAsFunctionProtoType(), ArgBeg, ArgEnd);
+  EmitCallArgs(Args, FnType->getAs<FunctionProtoType>(), ArgBeg, ArgEnd);
 
   // FIXME: We should not need to do this, it should be part of the function
   // type.
index 4fcfe06cd72c11a2b3ccf021430f1baaacdf51f9..9e81e4fbeabee6e2de3ce80f58b828cd5209cf10 100644 (file)
@@ -181,13 +181,13 @@ public:
   }
   ComplexPairTy VisitCXXZeroInitValueExpr(CXXZeroInitValueExpr *E) {
     assert(E->getType()->isAnyComplexType() && "Expected complex type!");
-    QualType Elem = E->getType()->getAsComplexType()->getElementType();
+    QualType Elem = E->getType()->getAs<ComplexType>()->getElementType();
     llvm::Constant *Null = llvm::Constant::getNullValue(CGF.ConvertType(Elem));
     return ComplexPairTy(Null, Null);
   }
   ComplexPairTy VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
     assert(E->getType()->isAnyComplexType() && "Expected complex type!");
-    QualType Elem = E->getType()->getAsComplexType()->getElementType();
+    QualType Elem = E->getType()->getAs<ComplexType>()->getElementType();
     llvm::Constant *Null =
                        llvm::Constant::getNullValue(CGF.ConvertType(Elem));
     return ComplexPairTy(Null, Null);
@@ -313,7 +313,7 @@ void ComplexExprEmitter::EmitStoreOfComplex(ComplexPairTy Val, llvm::Value *Ptr,
 ComplexPairTy ComplexExprEmitter::VisitExpr(Expr *E) {
   CGF.ErrorUnsupported(E, "complex expression");
   const llvm::Type *EltTy =
-    CGF.ConvertType(E->getType()->getAsComplexType()->getElementType());
+    CGF.ConvertType(E->getType()->getAs<ComplexType>()->getElementType());
   llvm::Value *U = llvm::UndefValue::get(EltTy);
   return ComplexPairTy(U, U);
 }
@@ -342,8 +342,8 @@ ComplexPairTy ComplexExprEmitter::EmitComplexToComplexCast(ComplexPairTy Val,
                                                            QualType SrcType,
                                                            QualType DestType) {
   // Get the src/dest element type.
-  SrcType = SrcType->getAsComplexType()->getElementType();
-  DestType = DestType->getAsComplexType()->getElementType();
+  SrcType = SrcType->getAs<ComplexType>()->getElementType();
+  DestType = DestType->getAs<ComplexType>()->getElementType();
 
   // C99 6.3.1.6: When a value of complex type is converted to another
   // complex type, both the real and imaginary parts follow the conversion
@@ -365,7 +365,7 @@ ComplexPairTy ComplexExprEmitter::EmitCast(Expr *Op, QualType DestTy) {
   llvm::Value *Elt = CGF.EmitScalarExpr(Op);
 
   // Convert the input element to the element type of the complex.
-  DestTy = DestTy->getAsComplexType()->getElementType();
+  DestTy = DestTy->getAs<ComplexType>()->getElementType();
   Elt = CGF.EmitScalarConversion(Elt, Op->getType(), DestTy);
 
   // Return (realval, 0).
@@ -386,7 +386,7 @@ ComplexPairTy ComplexExprEmitter::VisitPrePostIncDec(const UnaryOperator *E,
     // Add the inc/dec to the real part.
     NextVal = Builder.CreateAdd(InVal.first, NextVal, isInc ? "inc" : "dec");
   } else {
-    QualType ElemTy = E->getType()->getAsComplexType()->getElementType();
+    QualType ElemTy = E->getType()->getAs<ComplexType>()->getElementType();
     llvm::APFloat FVal(CGF.getContext().getFloatTypeSemantics(ElemTy), 1);
     if (!isInc)
       FVal.changeSign();
@@ -526,7 +526,7 @@ ComplexPairTy ComplexExprEmitter::EmitBinDiv(const BinOpInfo &Op) {
     llvm::Value *Tmp8 = Builder.CreateMul(LHSr, RHSi, "tmp"); // a*d
     llvm::Value *Tmp9 = Builder.CreateSub(Tmp7, Tmp8, "tmp"); // bc-ad
 
-    if (Op.Ty->getAsComplexType()->getElementType()->isUnsignedIntegerType()) {
+    if (Op.Ty->getAs<ComplexType>()->getElementType()->isUnsignedIntegerType()) {
       DSTr = Builder.CreateUDiv(Tmp3, Tmp6, "tmp");
       DSTi = Builder.CreateUDiv(Tmp9, Tmp6, "tmp");
     } else {
@@ -701,7 +701,7 @@ ComplexPairTy ComplexExprEmitter::VisitInitListExpr(InitListExpr *E) {
     return Visit(E->getInit(0));
 
   // Empty init list intializes to null
-  QualType Ty = E->getType()->getAsComplexType()->getElementType();
+  QualType Ty = E->getType()->getAs<ComplexType>()->getElementType();
   const llvm::Type* LTy = CGF.ConvertType(Ty);
   llvm::Value* zeroConstant = llvm::Constant::getNullValue(LTy);
   return ComplexPairTy(zeroConstant, zeroConstant);
@@ -714,7 +714,7 @@ ComplexPairTy ComplexExprEmitter::VisitVAArgExpr(VAArgExpr *E) {
   if (!ArgPtr) {
     CGF.ErrorUnsupported(E, "complex va_arg expression");
     const llvm::Type *EltTy =
-      CGF.ConvertType(E->getType()->getAsComplexType()->getElementType());
+      CGF.ConvertType(E->getType()->getAs<ComplexType>()->getElementType());
     llvm::Value *U = llvm::UndefValue::get(EltTy);
     return ComplexPairTy(U, U);
   }
index 682d14ca2e5a34b2f68f8d71d430a56493e66d0c..308376c179ec1cc4259dae43d9fd0318357a2dd3 100644 (file)
@@ -494,7 +494,7 @@ Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType,
   // A scalar can be splatted to an extended vector of the same element type
   if (DstType->isExtVectorType() && !SrcType->isVectorType()) {
     // Cast the scalar to element type
-    QualType EltTy = DstType->getAsExtVectorType()->getElementType();
+    QualType EltTy = DstType->getAs<ExtVectorType>()->getElementType();
     llvm::Value *Elt = EmitScalarConversion(Src, SrcType, EltTy);
 
     // Insert the element in element zero of an undef vector
@@ -553,7 +553,7 @@ Value *ScalarExprEmitter::
 EmitComplexToScalarConversion(CodeGenFunction::ComplexPairTy Src,
                               QualType SrcTy, QualType DstTy) {
   // Get the source element type.
-  SrcTy = SrcTy->getAsComplexType()->getElementType();
+  SrcTy = SrcTy->getAs<ComplexType>()->getElementType();
 
   // Handle conversions to bool first, they are special: comparisons against 0.
   if (DstTy->isBooleanType()) {
@@ -1118,14 +1118,14 @@ Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &Ops) {
   Expr *IdxExp;
   const PointerType *PT = Ops.E->getLHS()->getType()->getAs<PointerType>();
   const ObjCObjectPointerType *OPT =
-    Ops.E->getLHS()->getType()->getAsObjCObjectPointerType();
+    Ops.E->getLHS()->getType()->getAs<ObjCObjectPointerType>();
   if (PT || OPT) {
     Ptr = Ops.LHS;
     Idx = Ops.RHS;
     IdxExp = Ops.E->getRHS();
   } else {  // int + pointer
     PT = Ops.E->getRHS()->getType()->getAs<PointerType>();
-    OPT = Ops.E->getRHS()->getType()->getAsObjCObjectPointerType();
+    OPT = Ops.E->getRHS()->getType()->getAs<ObjCObjectPointerType>();
     assert((PT || OPT) && "Invalid add expr");
     Ptr = Ops.RHS;
     Idx = Ops.LHS;
@@ -1320,7 +1320,7 @@ Value *ScalarExprEmitter::EmitCompare(const BinaryOperator *E,unsigned UICmpOpc,
     CodeGenFunction::ComplexPairTy LHS = CGF.EmitComplexExpr(E->getLHS());
     CodeGenFunction::ComplexPairTy RHS = CGF.EmitComplexExpr(E->getRHS());
 
-    QualType CETy = LHSTy->getAsComplexType()->getElementType();
+    QualType CETy = LHSTy->getAs<ComplexType>()->getElementType();
 
     Value *ResultR, *ResultI;
     if (CETy->isRealFloatingType()) {
index 89493db91810daf20e51a03d71602e5ed9552958..e19debc97f8e76efe197247e3c0a40cad296c1a7 100644 (file)
@@ -1688,10 +1688,10 @@ void CGObjCGNU::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
 
         // All other types should be Objective-C interface pointer types.
         const ObjCObjectPointerType *OPT =
-          CatchDecl->getType()->getAsObjCObjectPointerType();
+          CatchDecl->getType()->getAs<ObjCObjectPointerType>();
         assert(OPT && "Invalid @catch type.");
         const ObjCInterfaceType *IT =
-          OPT->getPointeeType()->getAsObjCInterfaceType();
+          OPT->getPointeeType()->getAs<ObjCInterfaceType>();
         assert(IT && "Invalid @catch type.");
         llvm::Value *EHType =
           MakeConstantString(IT->getDecl()->getNameAsString());
@@ -1927,7 +1927,7 @@ LValue CGObjCGNU::EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
                                        llvm::Value *BaseValue,
                                        const ObjCIvarDecl *Ivar,
                                        unsigned CVRQualifiers) {
-  const ObjCInterfaceDecl *ID = ObjectTy->getAsObjCInterfaceType()->getDecl();
+  const ObjCInterfaceDecl *ID = ObjectTy->getAs<ObjCInterfaceType>()->getDecl();
   return EmitValueForIvarAtOffset(CGF, ID, BaseValue, Ivar, CVRQualifiers,
                                   EmitIvarOffset(CGF, ID, Ivar));
 }
index f6cdd274006377133d4fb4825e7744696d097654..df6058303a101cc356b04c6ea218dae17d9881f3 100644 (file)
@@ -1539,7 +1539,7 @@ CGObjCCommonMac::EmitLegacyMessageSend(CodeGen::CodeGenFunction &CGF,
       : ObjCTypes.getSendStretFn(IsSuper);
   } else if (ResultType->isFloatingType()) {
     if (ObjCABI == 2) {
-      if (const BuiltinType *BT = ResultType->getAsBuiltinType()) {
+      if (const BuiltinType *BT = ResultType->getAs<BuiltinType>()) {
         BuiltinType::Kind k = BT->getKind();
         Fn = (k == BuiltinType::LongDouble) ? ObjCTypes.getSendFpretFn2(IsSuper)
           : ObjCTypes.getSendFn2(IsSuper);
@@ -2546,7 +2546,7 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
       if (!CatchParam) {
         AllMatched = true;
       } else {
-        OPT = CatchParam->getType()->getAsObjCObjectPointerType();
+        OPT = CatchParam->getType()->getAs<ObjCObjectPointerType>();
 
         // catch(id e) always matches.
         // FIXME: For the time being we also match id<X>; this should
@@ -2569,7 +2569,7 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
 
       assert(OPT && "Unexpected non-object pointer type in @catch");
       QualType T = OPT->getPointeeType();
-      const ObjCInterfaceType *ObjCType = T->getAsObjCInterfaceType();
+      const ObjCInterfaceType *ObjCType = T->getAs<ObjCInterfaceType>();
       assert(ObjCType && "Catch parameter must have Objective-C type!");
 
       // Check if the @catch block matches the exception object.
@@ -2803,7 +2803,7 @@ LValue CGObjCMac::EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
                                        llvm::Value *BaseValue,
                                        const ObjCIvarDecl *Ivar,
                                        unsigned CVRQualifiers) {
-  const ObjCInterfaceDecl *ID = ObjectTy->getAsObjCInterfaceType()->getDecl();
+  const ObjCInterfaceDecl *ID = ObjectTy->getAs<ObjCInterfaceType>()->getDecl();
   return EmitValueForIvarAtOffset(CGF, ID, BaseValue, Ivar, CVRQualifiers,
                                   EmitIvarOffset(CGF, ID, Ivar));
 }
@@ -4968,7 +4968,7 @@ LValue CGObjCNonFragileABIMac::EmitObjCValueForIvar(
   llvm::Value *BaseValue,
   const ObjCIvarDecl *Ivar,
   unsigned CVRQualifiers) {
-  const ObjCInterfaceDecl *ID = ObjectTy->getAsObjCInterfaceType()->getDecl();
+  const ObjCInterfaceDecl *ID = ObjectTy->getAs<ObjCInterfaceType>()->getDecl();
   return EmitValueForIvarAtOffset(CGF, ID, BaseValue, Ivar, CVRQualifiers,
                                   EmitIvarOffset(CGF, ID, Ivar));
 }
@@ -5462,7 +5462,7 @@ CGObjCNonFragileABIMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
         } else {
           // All other types should be Objective-C interface pointer types.
           const ObjCObjectPointerType *PT =
-            CatchDecl->getType()->getAsObjCObjectPointerType();
+            CatchDecl->getType()->getAs<ObjCObjectPointerType>();
           assert(PT && "Invalid @catch type.");
           const ObjCInterfaceType *IT = PT->getInterfaceType();
           assert(IT && "Invalid @catch type.");
index 0ed61bf0de5819cf1bc83a99fdf86601408bb6c5..f21984eaa4e46994a91cdb59e29c1dd278ee4ce6 100644 (file)
@@ -224,7 +224,7 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD,
   }
 
   if (FD->getNumParams()) {
-    const FunctionProtoType* FProto = FD->getType()->getAsFunctionProtoType();
+    const FunctionProtoType* FProto = FD->getType()->getAs<FunctionProtoType>();
     assert(FProto && "Function def must have prototype!");
 
     for (unsigned i = 0, e = FD->getNumParams(); i != e; ++i)
index fca6ebefda4cbfa8a7676e7c2d0417050dca738e..af9f7e91f3f04d51f4f8089089fa852cfd38b0c8 100644 (file)
@@ -1099,7 +1099,7 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD) {
   const FunctionDecl *D = cast<FunctionDecl>(GD.getDecl());
 
   if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(D)) {
-    bool isVariadic = D->getType()->getAsFunctionProtoType()->isVariadic();
+    bool isVariadic = D->getType()->getAs<FunctionProtoType>()->isVariadic();
 
     Ty = getTypes().GetFunctionType(getTypes().getFunctionInfo(MD), isVariadic);
   } else {
index 48445e6caed206a397d8ba754779fec2b50317f0..973f0d188cb01d54103df3f2445df806acd37c17 100644 (file)
@@ -241,7 +241,7 @@ void CXXNameMangler::mangleFunctionEncoding(const FunctionDecl *FD) {
     FD = PrimaryTemplate->getTemplatedDecl();
   }
 
-  mangleBareFunctionType(FD->getType()->getAsFunctionType(), MangleReturnType);
+  mangleBareFunctionType(FD->getType()->getAs<FunctionType>(), MangleReturnType);
 }
 
 static bool isStdNamespace(const DeclContext *DC) {
index a9d883b8579ca6a9eb6bfd1590302174b91899b1..3ad8cfc36f59452295c8a1cd1feb2bb6d7624da2 100644 (file)
@@ -159,7 +159,7 @@ static const Type *isSingleElementStruct(QualType T, ASTContext &Context) {
 }
 
 static bool is32Or64BitBasicType(QualType Ty, ASTContext &Context) {
-  if (!Ty->getAsBuiltinType() && !Ty->isPointerType())
+  if (!Ty->getAs<BuiltinType>() && !Ty->isPointerType())
     return false;
 
   uint64_t Size = Context.getTypeSize(Ty);
@@ -292,7 +292,7 @@ bool X86_32ABIInfo::shouldReturnTypeInRegister(QualType Ty,
   }
 
   // If this is a builtin, pointer, or complex type, it is ok.
-  if (Ty->getAsBuiltinType() || Ty->isPointerType() || Ty->isAnyComplexType())
+  if (Ty->getAs<BuiltinType>() || Ty->isPointerType() || Ty->isAnyComplexType())
     return true;
 
   // Arrays are treated like records.
@@ -326,7 +326,7 @@ ABIArgInfo X86_32ABIInfo::classifyReturnType(QualType RetTy,
                                           llvm::LLVMContext &VMContext) const {
   if (RetTy->isVoidType()) {
     return ABIArgInfo::getIgnore();
-  } else if (const VectorType *VT = RetTy->getAsVectorType()) {
+  } else if (const VectorType *VT = RetTy->getAs<VectorType>()) {
     // On Darwin, some vectors are returned in registers.
     if (IsDarwinVectorABI) {
       uint64_t Size = Context.getTypeSize(RetTy);
@@ -360,7 +360,7 @@ ABIArgInfo X86_32ABIInfo::classifyReturnType(QualType RetTy,
 
     // Classify "single element" structs as their element type.
     if (const Type *SeltTy = isSingleElementStruct(RetTy, Context)) {
-      if (const BuiltinType *BT = SeltTy->getAsBuiltinType()) {
+      if (const BuiltinType *BT = SeltTy->getAs<BuiltinType>()) {
         if (BT->isIntegerType()) {
           // We need to use the size of the structure, padding
           // bit-fields can adjust that to be larger than the single
@@ -618,7 +618,7 @@ void X86_64ABIInfo::classify(QualType Ty,
   Class &Current = OffsetBase < 64 ? Lo : Hi;
   Current = Memory;
 
-  if (const BuiltinType *BT = Ty->getAsBuiltinType()) {
+  if (const BuiltinType *BT = Ty->getAs<BuiltinType>()) {
     BuiltinType::Kind k = BT->getKind();
 
     if (k == BuiltinType::Void) {
@@ -636,12 +636,12 @@ void X86_64ABIInfo::classify(QualType Ty,
     }
     // FIXME: _Decimal32 and _Decimal64 are SSE.
     // FIXME: _float128 and _Decimal128 are (SSE, SSEUp).
-  } else if (const EnumType *ET = Ty->getAsEnumType()) {
+  } else if (const EnumType *ET = Ty->getAs<EnumType>()) {
     // Classify the underlying integer type.
     classify(ET->getDecl()->getIntegerType(), Context, OffsetBase, Lo, Hi);
   } else if (Ty->hasPointerRepresentation()) {
     Current = Integer;
-  } else if (const VectorType *VT = Ty->getAsVectorType()) {
+  } else if (const VectorType *VT = Ty->getAs<VectorType>()) {
     uint64_t Size = Context.getTypeSize(VT);
     if (Size == 32) {
       // gcc passes all <4 x char>, <2 x short>, <1 x int>, <1 x
@@ -673,7 +673,7 @@ void X86_64ABIInfo::classify(QualType Ty,
       Lo = SSE;
       Hi = SSEUp;
     }
-  } else if (const ComplexType *CT = Ty->getAsComplexType()) {
+  } else if (const ComplexType *CT = Ty->getAs<ComplexType>()) {
     QualType ET = Context.getCanonicalType(CT->getElementType());
 
     uint64_t Size = Context.getTypeSize(Ty);
@@ -1468,7 +1468,7 @@ static bool isIntegerLikeType(QualType Ty,
     return false;
 
   // If this is a builtin or pointer type then it is ok.
-  if (Ty->getAsBuiltinType() || Ty->isPointerType())
+  if (Ty->getAs<BuiltinType>() || Ty->isPointerType())
     return true;
 
   // Complex types "should" be ok by the definition above, but they are not.
@@ -1651,7 +1651,7 @@ class SystemZABIInfo : public ABIInfo {
 
 bool SystemZABIInfo::isPromotableIntegerType(QualType Ty) const {
   // SystemZ ABI requires all 8, 16 and 32 bit quantities to be extended.
-  if (const BuiltinType *BT = Ty->getAsBuiltinType())
+  if (const BuiltinType *BT = Ty->getAs<BuiltinType>())
     switch (BT->getKind()) {
     case BuiltinType::Bool:
     case BuiltinType::Char_S:
index 6dcb6ae45a2772fb639e7b00ddd0064fa3b668e6..a6af2f8ecfa44edb1b70ffdf3d4a13ee2823b1c5 100644 (file)
@@ -161,7 +161,7 @@ void DocumentXML::finalize() {
     if (const TagDecl *TD = dyn_cast<TagDecl>(i->first))
       addAttribute("type", getPrefixedId(BasicTypes[TD->getTypeForDecl()], ID_NORMAL));
     else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(i->first))
-      addAttribute("type", getPrefixedId(BasicTypes[FD->getType()->getAsFunctionType()], ID_NORMAL));
+      addAttribute("type", getPrefixedId(BasicTypes[FD->getType()->getAs<FunctionType>()], ID_NORMAL));
 
     if (const DeclContext* parent = i->first->getParent())
       addAttribute("context", parent);
index 9c855eb26f1d6289ab2b1970dd6b130b6ff85d31..e85f58b0e91be411a8a435243259b8498cd51030 100644 (file)
@@ -1536,7 +1536,7 @@ void PCHReader::InitializeContext(ASTContext &Ctx) {
   if (unsigned File = SpecialTypes[pch::SPECIAL_TYPE_FILE]) {
     QualType FileType = GetType(File);
     assert(!FileType.isNull() && "FILE type is NULL");
-    if (const TypedefType *Typedef = FileType->getAsTypedefType())
+    if (const TypedefType *Typedef = FileType->getAs<TypedefType>())
       Context->setFILEDecl(Typedef->getDecl());
     else {
       const TagType *Tag = FileType->getAs<TagType>();
@@ -1547,7 +1547,7 @@ void PCHReader::InitializeContext(ASTContext &Ctx) {
   if (unsigned Jmp_buf = SpecialTypes[pch::SPECIAL_TYPE_jmp_buf]) {
     QualType Jmp_bufType = GetType(Jmp_buf);
     assert(!Jmp_bufType.isNull() && "jmp_bug type is NULL");
-    if (const TypedefType *Typedef = Jmp_bufType->getAsTypedefType())
+    if (const TypedefType *Typedef = Jmp_bufType->getAs<TypedefType>())
       Context->setjmp_bufDecl(Typedef->getDecl());
     else {
       const TagType *Tag = Jmp_bufType->getAs<TagType>();
@@ -1558,7 +1558,7 @@ void PCHReader::InitializeContext(ASTContext &Ctx) {
   if (unsigned Sigjmp_buf = SpecialTypes[pch::SPECIAL_TYPE_sigjmp_buf]) {
     QualType Sigjmp_bufType = GetType(Sigjmp_buf);
     assert(!Sigjmp_bufType.isNull() && "sigjmp_buf type is NULL");
-    if (const TypedefType *Typedef = Sigjmp_bufType->getAsTypedefType())
+    if (const TypedefType *Typedef = Sigjmp_bufType->getAs<TypedefType>())
       Context->setsigjmp_bufDecl(Typedef->getDecl());
     else {
       const TagType *Tag = Sigjmp_bufType->getAs<TagType>();
index b29f9eac49dfd9839ed8a278b76a5123c5648c6f..25e7fc4238492d8a585266ab17128b8e5377c81d 100644 (file)
@@ -694,7 +694,7 @@ std::string RewriteBlocks::SynthesizeBlockCall(CallExpr *Exp) {
     assert(1 && "RewriteBlockClass: Bad type");
   }
   assert(CPT && "RewriteBlockClass: Bad type");
-  const FunctionType *FT = CPT->getPointeeType()->getAsFunctionType();
+  const FunctionType *FT = CPT->getPointeeType()->getAs<FunctionType>();
   assert(FT && "RewriteBlockClass: Bad type");
   const FunctionProtoType *FTP = dyn_cast<FunctionProtoType>(FT);
   // FTP will be null for closures that don't take arguments.
@@ -814,11 +814,11 @@ bool RewriteBlocks::PointerTypeTakesAnyBlockArguments(QualType QT) {
   const FunctionProtoType *FTP;
   const PointerType *PT = QT->getAs<PointerType>();
   if (PT) {
-    FTP = PT->getPointeeType()->getAsFunctionProtoType();
+    FTP = PT->getPointeeType()->getAs<FunctionProtoType>();
   } else {
     const BlockPointerType *BPT = QT->getAs<BlockPointerType>();
     assert(BPT && "BlockPointerTypeTakeAnyBlockArguments(): not a block pointer type");
-    FTP = BPT->getPointeeType()->getAsFunctionProtoType();
+    FTP = BPT->getPointeeType()->getAs<FunctionProtoType>();
   }
   if (FTP) {
     for (FunctionProtoType::arg_type_iterator I = FTP->arg_type_begin(),
index 323804744d384e3e1c3d788c1bc992995e8863c4..57b1fc31a84c3e8d8e63e90a5fe175f2abc285e5 100644 (file)
@@ -868,7 +868,7 @@ void RewriteObjC::RewriteObjCMethodDecl(ObjCMethodDecl *OMD,
       PointeeTy = PT->getPointeeType();
     else if (const BlockPointerType *BPT = retType->getAs<BlockPointerType>())
       PointeeTy = BPT->getPointeeType();
-    if ((FPRetType = PointeeTy->getAsFunctionType())) {
+    if ((FPRetType = PointeeTy->getAs<FunctionType>())) {
       ResultStr += FPRetType->getResultType().getAsString();
       ResultStr += "(*";
     }
@@ -1790,7 +1790,7 @@ CallExpr *RewriteObjC::SynthesizeCallToFunctionDecl(
                                                          DRE,
                                                /*isLvalue=*/false);
 
-  const FunctionType *FT = msgSendType->getAsFunctionType();
+  const FunctionType *FT = msgSendType->getAs<FunctionType>();
 
   return new (Context) CallExpr(*Context, ICE, args, nargs, FT->getResultType(),
                                 SourceLocation());
@@ -1871,7 +1871,7 @@ void RewriteObjC::RewriteObjCQualifiedInterfaceTypes(Decl *Dcl) {
     Loc = FD->getLocation();
     // Check for ObjC 'id' and class types that have been adorned with protocol
     // information (id<p>, C<p>*). The protocol references need to be rewritten!
-    const FunctionType *funcType = FD->getType()->getAsFunctionType();
+    const FunctionType *funcType = FD->getType()->getAs<FunctionType>();
     assert(funcType && "missing function type");
     proto = dyn_cast<FunctionProtoType>(funcType);
     if (!proto)
@@ -2164,7 +2164,7 @@ ObjCInterfaceDecl *RewriteObjC::isSuperReceiver(Expr *recExpr) {
 
   if (ObjCSuperExpr *Super = dyn_cast<ObjCSuperExpr>(recExpr)) {
       const ObjCObjectPointerType *OPT =
-        Super->getType()->getAsObjCObjectPointerType();
+        Super->getType()->getAs<ObjCObjectPointerType>();
       assert(OPT);
       const ObjCInterfaceType *IT = OPT->getInterfaceType();
       return IT->getDecl();
@@ -2535,7 +2535,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
   // Don't forget the parens to enforce the proper binding.
   ParenExpr *PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), cast);
 
-  const FunctionType *FT = msgSendType->getAsFunctionType();
+  const FunctionType *FT = msgSendType->getAs<FunctionType>();
   CallExpr *CE = new (Context) CallExpr(*Context, PE, &MsgExprs[0],
                                         MsgExprs.size(),
                                         FT->getResultType(), SourceLocation());
@@ -2565,7 +2565,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
     // Don't forget the parens to enforce the proper binding.
     PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), cast);
 
-    FT = msgSendType->getAsFunctionType();
+    FT = msgSendType->getAs<FunctionType>();
     CallExpr *STCE = new (Context) CallExpr(*Context, PE, &MsgExprs[0],
                                             MsgExprs.size(),
                                             FT->getResultType(), SourceLocation());
@@ -3920,7 +3920,7 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp) {
     assert(1 && "RewriteBlockClass: Bad type");
   }
   assert(CPT && "RewriteBlockClass: Bad type");
-  const FunctionType *FT = CPT->getPointeeType()->getAsFunctionType();
+  const FunctionType *FT = CPT->getPointeeType()->getAs<FunctionType>();
   assert(FT && "RewriteBlockClass: Bad type");
   const FunctionProtoType *FTP = dyn_cast<FunctionProtoType>(FT);
   // FTP will be null for closures that don't take arguments.
@@ -4087,11 +4087,11 @@ bool RewriteObjC::PointerTypeTakesAnyBlockArguments(QualType QT) {
   const FunctionProtoType *FTP;
   const PointerType *PT = QT->getAs<PointerType>();
   if (PT) {
-    FTP = PT->getPointeeType()->getAsFunctionProtoType();
+    FTP = PT->getPointeeType()->getAs<FunctionProtoType>();
   } else {
     const BlockPointerType *BPT = QT->getAs<BlockPointerType>();
     assert(BPT && "BlockPointerTypeTakeAnyBlockArguments(): not a block pointer type");
-    FTP = BPT->getPointeeType()->getAsFunctionProtoType();
+    FTP = BPT->getPointeeType()->getAs<FunctionProtoType>();
   }
   if (FTP) {
     for (FunctionProtoType::arg_type_iterator I = FTP->arg_type_begin(),
index a8a6095079f67b585493314037e38cdd48da4618..1e26c3507bbf5f1aeefa69e727a1c640af755db5 100644 (file)
@@ -199,7 +199,7 @@ bool Sema::CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall) {
       bool HasVAListArg = Format->getFirstArg() == 0;
       if (!HasVAListArg) {
         if (const FunctionProtoType *Proto
-            = FDecl->getType()->getAsFunctionProtoType())
+            = FDecl->getType()->getAs<FunctionProtoType>())
         HasVAListArg = !Proto->isVariadic();
       }
       CheckPrintfArguments(TheCall, HasVAListArg, Format->getFormatIdx() - 1,
@@ -234,7 +234,7 @@ bool Sema::CheckBlockCall(NamedDecl *NDecl, CallExpr *TheCall) {
   bool HasVAListArg = Format->getFirstArg() == 0;
   if (!HasVAListArg) {
     const FunctionType *FT =
-      Ty->getAs<BlockPointerType>()->getPointeeType()->getAsFunctionType();
+      Ty->getAs<BlockPointerType>()->getPointeeType()->getAs<FunctionType>();
     if (const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FT))
       HasVAListArg = !Proto->isVariadic();
   }
@@ -372,7 +372,7 @@ bool Sema::SemaBuiltinAtomicOverloaded(CallExpr *TheCall) {
     cast<FunctionDecl>(LazilyCreateBuiltin(NewBuiltinII, NewBuiltinID,
                                            TUScope, false, DRE->getLocStart()));
   const FunctionProtoType *BuiltinFT =
-    NewBuiltinDecl->getType()->getAsFunctionProtoType();
+    NewBuiltinDecl->getType()->getAs<FunctionProtoType>();
   ValType = BuiltinFT->getArgType(0)->getAs<PointerType>()->getPointeeType();
 
   // If the first type needs to be converted (e.g. void** -> int*), do it now.
@@ -633,7 +633,7 @@ Action::OwningExprResult Sema::SemaBuiltinShuffleVector(CallExpr *TheCall) {
       return ExprError();
     }
 
-    numElements = FAType->getAsVectorType()->getNumElements();
+    numElements = FAType->getAs<VectorType>()->getNumElements();
     if (TheCall->getNumArgs() != numElements+2) {
       if (TheCall->getNumArgs() < numElements+2)
         return ExprError(Diag(TheCall->getLocEnd(),
@@ -694,7 +694,7 @@ bool Sema::SemaBuiltinPrefetch(CallExpr *TheCall) {
 
     QualType RWType = Arg->getType();
 
-    const BuiltinType *BT = RWType->getAsBuiltinType();
+    const BuiltinType *BT = RWType->getAs<BuiltinType>();
     llvm::APSInt Result;
     if (!BT || BT->getKind() != BuiltinType::Int)
       return Diag(TheCall->getLocStart(), diag::err_prefetch_invalid_argument)
@@ -733,7 +733,7 @@ bool Sema::SemaBuiltinObjectSize(CallExpr *TheCall) {
     return false;
 
   QualType ArgType = Arg->getType();
-  const BuiltinType *BT = ArgType->getAsBuiltinType();
+  const BuiltinType *BT = ArgType->getAs<BuiltinType>();
   llvm::APSInt Result(32);
   if (!BT || BT->getKind() != BuiltinType::Int)
     return Diag(TheCall->getLocStart(), diag::err_object_size_invalid_argument)
@@ -1092,7 +1092,7 @@ void Sema::CheckPrintfString(const StringLiteral *FExpr,
 
         // Perform type checking on width/precision specifier.
         const Expr *E = TheCall->getArg(format_idx+numConversions);
-        if (const BuiltinType *BT = E->getType()->getAsBuiltinType())
+        if (const BuiltinType *BT = E->getType()->getAs<BuiltinType>())
           if (BT->getKind() == BuiltinType::Int)
             break;
 
index f5a3dc42525f681504f8e14338d57cef076de463..084b2efcf36b8b9e13016f49f4b0d8814bdd7b16 100644 (file)
@@ -766,8 +766,8 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) {
   // duplicate function decls like "void f(int); void f(enum X);" properly.
   if (!getLangOptions().CPlusPlus &&
       Context.typesAreCompatible(OldQType, NewQType)) {
-    const FunctionType *OldFuncType = OldQType->getAsFunctionType();
-    const FunctionType *NewFuncType = NewQType->getAsFunctionType();
+    const FunctionType *OldFuncType = OldQType->getAs<FunctionType>();
+    const FunctionType *NewFuncType = NewQType->getAs<FunctionType>();
     const FunctionProtoType *OldProto = 0;
     if (isa<FunctionNoProtoType>(NewFuncType) &&
         (OldProto = dyn_cast<FunctionProtoType>(OldFuncType))) {
@@ -816,14 +816,14 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) {
   // C99 6.9.1p8.
   if (!getLangOptions().CPlusPlus &&
       Old->hasPrototype() && !New->hasPrototype() &&
-      New->getType()->getAsFunctionProtoType() &&
+      New->getType()->getAs<FunctionProtoType>() &&
       Old->getNumParams() == New->getNumParams()) {
     llvm::SmallVector<QualType, 16> ArgTypes;
     llvm::SmallVector<GNUCompatibleParamWarning, 16> Warnings;
     const FunctionProtoType *OldProto
-      = Old->getType()->getAsFunctionProtoType();
+      = Old->getType()->getAs<FunctionProtoType>();
     const FunctionProtoType *NewProto
-      = New->getType()->getAsFunctionProtoType();
+      = New->getType()->getAs<FunctionProtoType>();
 
     // Determine whether this is the GNU C extension.
     QualType MergedReturn = Context.mergeTypes(OldProto->getResultType(),
@@ -1195,7 +1195,7 @@ void Sema::CheckFallThroughForBlock(QualType BlockTy, Stmt *Body) {
     return;
   bool ReturnsVoid = false;
   bool HasNoReturn = false;
-  if (const FunctionType *FT = BlockTy->getPointeeType()->getAsFunctionType()) {
+  if (const FunctionType *FT = BlockTy->getPointeeType()->getAs<FunctionType>()) {
     if (FT->getResultType()->isVoidType())
       ReturnsVoid = true;
     if (FT->getNoReturnAttr())
@@ -2389,16 +2389,16 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
   // the class has been completely parsed.
   if (!DC->isRecord() &&
       RequireNonAbstractType(D.getIdentifierLoc(),
-                             R->getAsFunctionType()->getResultType(),
+                             R->getAs<FunctionType>()->getResultType(),
                              diag::err_abstract_type_in_decl,
                              AbstractReturnType))
     D.setInvalidType();
 
   // Do not allow returning a objc interface by-value.
-  if (R->getAsFunctionType()->getResultType()->isObjCInterfaceType()) {
+  if (R->getAs<FunctionType>()->getResultType()->isObjCInterfaceType()) {
     Diag(D.getIdentifierLoc(),
          diag::err_object_cannot_be_passed_returned_by_value) << 0
-      << R->getAsFunctionType()->getResultType();
+      << R->getAs<FunctionType>()->getResultType();
     D.setInvalidType();
   }
 
@@ -2641,7 +2641,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
       }
     }
 
-  } else if (const FunctionProtoType *FT = R->getAsFunctionProtoType()) {
+  } else if (const FunctionProtoType *FT = R->getAs<FunctionProtoType>()) {
     // When we're declaring a function with a typedef, typeof, etc as in the
     // following example, we'll need to synthesize (unnamed)
     // parameters for use in the declaration.
@@ -2824,14 +2824,14 @@ void Sema::CheckFunctionDeclaration(FunctionDecl *NewFD, NamedDecl *&PrevDecl,
 
       // Functions marked "overloadable" must have a prototype (that
       // we can't get through declaration merging).
-      if (!NewFD->getType()->getAsFunctionProtoType()) {
+      if (!NewFD->getType()->getAs<FunctionProtoType>()) {
         Diag(NewFD->getLocation(), diag::err_attribute_overloadable_no_prototype)
           << NewFD;
         Redeclaration = true;
 
         // Turn this into a variadic function with no parameters.
         QualType R = Context.getFunctionType(
-                       NewFD->getType()->getAsFunctionType()->getResultType(),
+                       NewFD->getType()->getAs<FunctionType>()->getResultType(),
                        0, 0, true, 0);
         NewFD->setType(R);
         return NewFD->setInvalidDecl();
@@ -2927,7 +2927,7 @@ void Sema::CheckMain(FunctionDecl* FD) {
 
   QualType T = FD->getType();
   assert(T->isFunctionType() && "function decl is not of function type");
-  const FunctionType* FT = T->getAsFunctionType();
+  const FunctionType* FT = T->getAs<FunctionType>();
 
   if (!Context.hasSameUnqualifiedType(FT->getResultType(), Context.IntTy)) {
     // TODO: add a replacement fixit to turn the return type into 'int'.
index 5987c96c2f2a3d4517ea3234a0caaab976240cfb..a23da410861133cc4264a99536d0e7ed918297a6 100644 (file)
@@ -41,7 +41,7 @@ static const FunctionType *getFunctionType(const Decl *d,
   else if (blocksToo && Ty->isBlockPointerType())
     Ty = Ty->getAs<BlockPointerType>()->getPointeeType();
 
-  return Ty->getAsFunctionType();
+  return Ty->getAs<FunctionType>();
 }
 
 // FIXME: We should provide an abstraction around a method or function
@@ -124,11 +124,11 @@ static bool isFunctionOrMethodVariadic(const Decl *d) {
 }
 
 static inline bool isNSStringType(QualType T, ASTContext &Ctx) {
-  const ObjCObjectPointerType *PT = T->getAsObjCObjectPointerType();
+  const ObjCObjectPointerType *PT = T->getAs<ObjCObjectPointerType>();
   if (!PT)
     return false;
 
-  const ObjCInterfaceType *ClsT =PT->getPointeeType()->getAsObjCInterfaceType();
+  const ObjCInterfaceType *ClsT =PT->getPointeeType()->getAs<ObjCInterfaceType>();
   if (!ClsT)
     return false;
 
@@ -750,7 +750,7 @@ static void HandleSentinelAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   }
 
   if (FunctionDecl *FD = dyn_cast<FunctionDecl>(d)) {
-    const FunctionType *FT = FD->getType()->getAsFunctionType();
+    const FunctionType *FT = FD->getType()->getAs<FunctionType>();
     assert(FT && "FunctionDecl has non-function type?");
 
     if (isa<FunctionNoProtoType>(FT)) {
@@ -775,7 +775,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->getAs<BlockPointerType>()->getPointeeType()->getAsFunctionType();
+        : Ty->getAs<BlockPointerType>()->getPointeeType()->getAs<FunctionType>();
       if (!cast<FunctionProtoType>(FT)->isVariadic()) {
         int m = Ty->isFunctionPointerType() ? 0 : 1;
         S.Diag(Attr.getLoc(), diag::warn_attribute_sentinel_not_variadic) << m;
@@ -1549,7 +1549,7 @@ static void HandleModeAttr(Decl *D, const AttributeList &Attr, Sema &S) {
     return;
   }
 
-  if (!OldTy->getAsBuiltinType() && !OldTy->isComplexType())
+  if (!OldTy->getAs<BuiltinType>() && !OldTy->isComplexType())
     S.Diag(Attr.getLoc(), diag::err_mode_not_primitive);
   else if (IntegerMode) {
     if (!OldTy->isIntegralType())
@@ -1746,7 +1746,7 @@ static void HandleNSReturnsRetainedAttr(Decl *d, const AttributeList &Attr,
   }
 
   if (!(S.Context.isObjCNSObjectType(RetTy) || RetTy->getAs<PointerType>()
-        || RetTy->getAsObjCObjectPointerType())) {
+        || RetTy->getAs<ObjCObjectPointerType>())) {
     SourceLocation L = Attr.getLoc();
     S.Diag(d->getLocStart(), diag::warn_ns_attribute_wrong_return_type)
       << SourceRange(L, L) << Attr.getName();
index 75718ddec9e78dd64cd76aa8829e3843c7c31b80..1896fb0dc30fdd0d6491757f0e8e13f8f7ce7ad4 100644 (file)
@@ -325,8 +325,8 @@ bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old) {
   }
 
   if (CheckEquivalentExceptionSpec(
-          Old->getType()->getAsFunctionProtoType(), Old->getLocation(),
-          New->getType()->getAsFunctionProtoType(), New->getLocation())) {
+          Old->getType()->getAs<FunctionProtoType>(), Old->getLocation(),
+          New->getType()->getAs<FunctionProtoType>(), New->getLocation())) {
     Invalid = true;
   }
 
@@ -1632,7 +1632,7 @@ namespace {
       }
 
       // Check the return type.
-      QualType RTy = FD->getType()->getAsFunctionType()->getResultType();
+      QualType RTy = FD->getType()->getAs<FunctionType>()->getResultType();
       bool Invalid =
         SemaRef.RequireNonAbstractType(FD->getLocation(), RTy,
                                        diag::err_abstract_type_in_decl,
@@ -2062,7 +2062,7 @@ QualType Sema::CheckConstructorDeclarator(Declarator &D, QualType R,
   // return type, since constructors don't have return types. We
   // *always* have to do this, because GetTypeForDeclarator will
   // put in a result type of "int" when none was specified.
-  const FunctionProtoType *Proto = R->getAsFunctionProtoType();
+  const FunctionProtoType *Proto = R->getAs<FunctionProtoType>();
   return Context.getFunctionType(Context.VoidTy, Proto->arg_type_begin(),
                                  Proto->getNumArgs(),
                                  Proto->isVariadic(), 0);
@@ -2229,7 +2229,7 @@ void Sema::CheckConversionDeclarator(Declarator &D, QualType &R,
   }
 
   // Make sure we don't have any parameters.
-  if (R->getAsFunctionProtoType()->getNumArgs() > 0) {
+  if (R->getAs<FunctionProtoType>()->getNumArgs() > 0) {
     Diag(D.getIdentifierLoc(), diag::err_conv_function_with_params);
 
     // Delete the parameters.
@@ -2238,7 +2238,7 @@ void Sema::CheckConversionDeclarator(Declarator &D, QualType &R,
   }
 
   // Make sure the conversion function isn't variadic.
-  if (R->getAsFunctionProtoType()->isVariadic() && !D.isInvalidType()) {
+  if (R->getAs<FunctionProtoType>()->isVariadic() && !D.isInvalidType()) {
     Diag(D.getIdentifierLoc(), diag::err_conv_function_variadic);
     D.setInvalidType();
   }
@@ -2261,7 +2261,7 @@ void Sema::CheckConversionDeclarator(Declarator &D, QualType &R,
   // of the errors above fired) and with the conversion type as the
   // return type.
   R = Context.getFunctionType(ConvType, 0, 0, false,
-                              R->getAsFunctionProtoType()->getTypeQuals());
+                              R->getAs<FunctionProtoType>()->getTypeQuals());
 
   // C++0x explicit conversion operators.
   if (D.getDeclSpec().isExplicitSpecified() && !getLangOptions().CPlusPlus0x)
@@ -3799,7 +3799,7 @@ bool Sema::CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl) {
 
   // Overloaded operators other than operator() cannot be variadic.
   if (Op != OO_Call &&
-      FnDecl->getType()->getAsFunctionProtoType()->isVariadic()) {
+      FnDecl->getType()->getAs<FunctionProtoType>()->isVariadic()) {
     return Diag(FnDecl->getLocation(), diag::err_operator_overload_variadic)
       << FnDecl->getDeclName();
   }
@@ -3824,7 +3824,7 @@ bool Sema::CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl) {
   if ((Op == OO_PlusPlus || Op == OO_MinusMinus) && NumParams == 2) {
     ParmVarDecl *LastParam = FnDecl->getParamDecl(FnDecl->getNumParams() - 1);
     bool ParamIsInt = false;
-    if (const BuiltinType *BT = LastParam->getType()->getAsBuiltinType())
+    if (const BuiltinType *BT = LastParam->getType()->getAs<BuiltinType>())
       ParamIsInt = BT->getKind() == BuiltinType::Int;
 
     if (!ParamIsInt)
@@ -4382,8 +4382,8 @@ void Sema::DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock) {
 
 bool Sema::CheckOverridingFunctionReturnType(const CXXMethodDecl *New,
                                              const CXXMethodDecl *Old) {
-  QualType NewTy = New->getType()->getAsFunctionType()->getResultType();
-  QualType OldTy = Old->getType()->getAsFunctionType()->getResultType();
+  QualType NewTy = New->getType()->getAs<FunctionType>()->getResultType();
+  QualType OldTy = Old->getType()->getAs<FunctionType>()->getResultType();
 
   QualType CNewTy = Context.getCanonicalType(NewTy);
   QualType COldTy = Context.getCanonicalType(OldTy);
@@ -4465,9 +4465,9 @@ bool Sema::CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New,
                                                 const CXXMethodDecl *Old) {
   return CheckExceptionSpecSubset(diag::err_override_exception_spec,
                                   diag::note_overridden_virtual_function,
-                                  Old->getType()->getAsFunctionProtoType(),
+                                  Old->getType()->getAs<FunctionProtoType>(),
                                   Old->getLocation(),
-                                  New->getType()->getAsFunctionProtoType(),
+                                  New->getType()->getAs<FunctionProtoType>(),
                                   New->getLocation());
 }
 
index 43d38f06799734e31deeb957d7b006d227075cd8..c11b4e06667b822fca0a18bb015d890fb67b628d 100644 (file)
@@ -143,7 +143,7 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
         if (const TypedefDecl *TDecl = dyn_cast_or_null<TypedefDecl>(PrevDecl)) {
           QualType T = TDecl->getUnderlyingType();
           if (T->isObjCInterfaceType()) {
-            if (NamedDecl *IDecl = T->getAsObjCInterfaceType()->getDecl())
+            if (NamedDecl *IDecl = T->getAs<ObjCInterfaceType>()->getDecl())
               SuperClassDecl = dyn_cast<ObjCInterfaceDecl>(IDecl);
           }
         }
@@ -209,7 +209,7 @@ Sema::DeclPtrTy Sema::ActOnCompatiblityAlias(SourceLocation AtLoc,
   if (const TypedefDecl *TDecl = dyn_cast_or_null<TypedefDecl>(CDeclU)) {
     QualType T = TDecl->getUnderlyingType();
     if (T->isObjCInterfaceType()) {
-      if (NamedDecl *IDecl = T->getAsObjCInterfaceType()->getDecl()) {
+      if (NamedDecl *IDecl = T->getAs<ObjCInterfaceType>()->getDecl()) {
         ClassName = IDecl->getIdentifier();
         CDeclU = LookupName(TUScope, ClassName, LookupOrdinaryName);
       }
@@ -1939,7 +1939,7 @@ Sema::DeclPtrTy Sema::ActOnProperty(Scope *S, SourceLocation AtLoc,
       if (T->isObjCObjectPointerType()) {
         QualType InterfaceTy = T->getPointeeType();
         if (const ObjCInterfaceType *OIT =
-              InterfaceTy->getAsObjCInterfaceType()) {
+              InterfaceTy->getAs<ObjCInterfaceType>()) {
         ObjCInterfaceDecl *IDecl = OIT->getDecl();
         if (IDecl)
           if (ObjCProtocolDecl* PNSCopying =
index 70e137462f46f1ba852d8babd27706b00160c075..333cd35f893d82ca94a531594db75b5891b615db 100644 (file)
@@ -132,8 +132,8 @@ void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
     QualType Ty = V->getType();
     if (Ty->isBlockPointerType() || Ty->isFunctionPointerType()) {
       const FunctionType *FT = Ty->isFunctionPointerType()
-      ? Ty->getAs<PointerType>()->getPointeeType()->getAsFunctionType()
-      : Ty->getAs<BlockPointerType>()->getPointeeType()->getAsFunctionType();
+      ? Ty->getAs<PointerType>()->getPointeeType()->getAs<FunctionType>()
+      : Ty->getAs<BlockPointerType>()->getPointeeType()->getAs<FunctionType>();
       if (const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FT)) {
         unsigned NumArgsInProto = Proto->getNumArgs();
         unsigned k;
@@ -261,7 +261,7 @@ void Sema::DefaultArgumentPromotion(Expr *&Expr) {
   assert(!Ty.isNull() && "DefaultArgumentPromotion - missing type");
 
   // If this is a 'float' (CVR qualified or typedef) promote to double.
-  if (const BuiltinType *BT = Ty->getAsBuiltinType())
+  if (const BuiltinType *BT = Ty->getAs<BuiltinType>())
     if (BT->getKind() == BuiltinType::Float)
       return ImpCastExprToType(Expr, Context.DoubleTy);
 
@@ -842,7 +842,7 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
 
       QualType T = Func->getType();
       QualType NoProtoType = T;
-      if (const FunctionProtoType *Proto = T->getAsFunctionProtoType())
+      if (const FunctionProtoType *Proto = T->getAs<FunctionProtoType>())
         NoProtoType = Context.getFunctionNoProtoType(Proto->getResultType());
       return BuildDeclRefExpr(Func, NoProtoType, Loc, false, false, SS);
     }
@@ -1483,7 +1483,7 @@ QualType Sema::CheckRealImagOperand(Expr *&V, SourceLocation Loc, bool isReal) {
     return Context.DependentTy;
 
   // These operators return the element type of a complex type.
-  if (const ComplexType *CT = V->getType()->getAsComplexType())
+  if (const ComplexType *CT = V->getType()->getAs<ComplexType>())
     return CT->getElementType();
 
   // Otherwise they pass through real integer and floating point types here.
@@ -1562,7 +1562,7 @@ Sema::ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
 
         // Determine the result type
         QualType ResultTy
-          = FnDecl->getType()->getAsFunctionType()->getResultType();
+          = FnDecl->getType()->getAs<FunctionType>()->getResultType();
         ResultTy = ResultTy.getNonReferenceType();
 
         // Build the actual expression node.
@@ -1678,7 +1678,7 @@ Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc,
 
         // Determine the result type
         QualType ResultTy
-          = FnDecl->getType()->getAsFunctionType()->getResultType();
+          = FnDecl->getType()->getAs<FunctionType>()->getResultType();
         ResultTy = ResultTy.getNonReferenceType();
 
         // Build the actual expression node.
@@ -1759,17 +1759,17 @@ Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc,
     IndexExpr = LHSExp;
     ResultType = PTy->getPointeeType();
   } else if (const ObjCObjectPointerType *PTy =
-               LHSTy->getAsObjCObjectPointerType()) {
+               LHSTy->getAs<ObjCObjectPointerType>()) {
     BaseExpr = LHSExp;
     IndexExpr = RHSExp;
     ResultType = PTy->getPointeeType();
   } else if (const ObjCObjectPointerType *PTy =
-               RHSTy->getAsObjCObjectPointerType()) {
+               RHSTy->getAs<ObjCObjectPointerType>()) {
      // Handle the uncommon case of "123[Ptr]".
     BaseExpr = RHSExp;
     IndexExpr = LHSExp;
     ResultType = PTy->getPointeeType();
-  } else if (const VectorType *VTy = LHSTy->getAsVectorType()) {
+  } else if (const VectorType *VTy = LHSTy->getAs<VectorType>()) {
     BaseExpr = LHSExp;    // vectors: V[123]
     IndexExpr = RHSExp;
 
@@ -1847,7 +1847,7 @@ QualType Sema::
 CheckExtVectorComponent(QualType baseType, SourceLocation OpLoc,
                         const IdentifierInfo *CompName,
                         SourceLocation CompLoc) {
-  const ExtVectorType *vecType = baseType->getAsExtVectorType();
+  const ExtVectorType *vecType = baseType->getAs<ExtVectorType>();
 
   // The vector accessor can't exceed the number of elements.
   const char *compStr = CompName->getName();
@@ -2355,9 +2355,9 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
   // (*Obj).ivar.
   if ((OpKind == tok::arrow && BaseType->isObjCObjectPointerType()) ||
       (OpKind == tok::period && BaseType->isObjCInterfaceType())) {
-    const ObjCObjectPointerType *OPT = BaseType->getAsObjCObjectPointerType();
+    const ObjCObjectPointerType *OPT = BaseType->getAs<ObjCObjectPointerType>();
     const ObjCInterfaceType *IFaceT =
-      OPT ? OPT->getInterfaceType() : BaseType->getAsObjCInterfaceType();
+      OPT ? OPT->getInterfaceType() : BaseType->getAs<ObjCInterfaceType>();
     if (IFaceT) {
       IdentifierInfo *Member = MemberName.getAsIdentifierInfo();
 
@@ -2419,7 +2419,7 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
   // Handle properties on 'id' and qualified "id".
   if (OpKind == tok::period && (BaseType->isObjCIdType() ||
                                 BaseType->isObjCQualifiedIdType())) {
-    const ObjCObjectPointerType *QIdTy = BaseType->getAsObjCObjectPointerType();
+    const ObjCObjectPointerType *QIdTy = BaseType->getAs<ObjCObjectPointerType>();
     IdentifierInfo *Member = MemberName.getAsIdentifierInfo();
 
     // Check protocols on qualified interfaces.
@@ -2936,10 +2936,10 @@ Sema::ActOnCallExpr(Scope *S, ExprArg fn, SourceLocation LParenLoc,
     if (PT == 0)
       return ExprError(Diag(LParenLoc, diag::err_typecheck_call_not_function)
         << Fn->getType() << Fn->getSourceRange());
-    FuncT = PT->getPointeeType()->getAsFunctionType();
+    FuncT = PT->getPointeeType()->getAs<FunctionType>();
   } else { // This is a block call.
     FuncT = Fn->getType()->getAs<BlockPointerType>()->getPointeeType()->
-                getAsFunctionType();
+                getAs<FunctionType>();
   }
   if (FuncT == 0)
     return ExprError(Diag(LParenLoc, diag::err_typecheck_call_not_function)
@@ -2969,7 +2969,7 @@ Sema::ActOnCallExpr(Scope *S, ExprArg fn, SourceLocation LParenLoc,
       const FunctionDecl *Def = 0;
       if (FDecl->getBody(Def) && NumArgs != Def->param_size()) {
         const FunctionProtoType *Proto =
-            Def->getType()->getAsFunctionProtoType();
+            Def->getType()->getAs<FunctionProtoType>();
         if (!Proto || !(Proto->isVariadic() && NumArgs >= Def->param_size())) {
           Diag(RParenLoc, diag::warn_call_wrong_number_of_arguments)
             << (NumArgs > Def->param_size()) << FDecl << Fn->getSourceRange();
@@ -3422,8 +3422,8 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS,
       // Two identical object pointer types are always compatible.
       return LHSTy;
     }
-    const ObjCObjectPointerType *LHSOPT = LHSTy->getAsObjCObjectPointerType();
-    const ObjCObjectPointerType *RHSOPT = RHSTy->getAsObjCObjectPointerType();
+    const ObjCObjectPointerType *LHSOPT = LHSTy->getAs<ObjCObjectPointerType>();
+    const ObjCObjectPointerType *RHSOPT = RHSTy->getAs<ObjCObjectPointerType>();
     QualType compositeType = LHSTy;
 
     // If both operands are interfaces and either operand can be
@@ -3470,7 +3470,7 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS,
   // Check Objective-C object pointer types and 'void *'
   if (LHSTy->isVoidPointerType() && RHSTy->isObjCObjectPointerType()) {
     QualType lhptee = LHSTy->getAs<PointerType>()->getPointeeType();
-    QualType rhptee = RHSTy->getAsObjCObjectPointerType()->getPointeeType();
+    QualType rhptee = RHSTy->getAs<ObjCObjectPointerType>()->getPointeeType();
     QualType destPointee = lhptee.getQualifiedType(rhptee.getCVRQualifiers());
     QualType destType = Context.getPointerType(destPointee);
     ImpCastExprToType(LHS, destType); // add qualifiers if necessary
@@ -3478,7 +3478,7 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS,
     return destType;
   }
   if (LHSTy->isObjCObjectPointerType() && RHSTy->isVoidPointerType()) {
-    QualType lhptee = LHSTy->getAsObjCObjectPointerType()->getPointeeType();
+    QualType lhptee = LHSTy->getAs<ObjCObjectPointerType>()->getPointeeType();
     QualType rhptee = RHSTy->getAs<PointerType>()->getPointeeType();
     QualType destPointee = rhptee.getQualifiedType(lhptee.getCVRQualifiers());
     QualType destType = Context.getPointerType(destPointee);
@@ -4021,8 +4021,8 @@ inline QualType Sema::CheckVectorOperands(SourceLocation Loc, Expr *&lex,
   // type.  It would be nice if we only had one vector type someday.
   if (getLangOptions().LaxVectorConversions) {
     // FIXME: Should we warn here?
-    if (const VectorType *LV = lhsType->getAsVectorType()) {
-      if (const VectorType *RV = rhsType->getAsVectorType())
+    if (const VectorType *LV = lhsType->getAs<VectorType>()) {
+      if (const VectorType *RV = rhsType->getAs<VectorType>())
         if (LV->getElementType() == RV->getElementType() &&
             LV->getNumElements() == RV->getNumElements()) {
           return lhsType->isExtVectorType() ? lhsType : rhsType;
@@ -4040,7 +4040,7 @@ inline QualType Sema::CheckVectorOperands(SourceLocation Loc, Expr *&lex,
   }
 
   // Handle the case of an ext vector and scalar.
-  if (const ExtVectorType *LV = lhsType->getAsExtVectorType()) {
+  if (const ExtVectorType *LV = lhsType->getAs<ExtVectorType>()) {
     QualType EltTy = LV->getElementType();
     if (EltTy->isIntegralType() && rhsType->isIntegralType()) {
       if (Context.getIntegerTypeOrder(EltTy, rhsType) >= 0) {
@@ -4695,7 +4695,7 @@ QualType Sema::CheckVectorCompareOperands(Expr *&lex, Expr *&rex,
   if (lType->isIntegerType())
     return lType;
 
-  const VectorType *VTy = lType->getAsVectorType();
+  const VectorType *VTy = lType->getAs<VectorType>();
   unsigned TypeSize = Context.getTypeSize(VTy->getElementType());
   if (TypeSize == Context.getTypeSize(Context.IntTy))
     return Context.getExtVectorType(Context.IntTy, VTy->getNumElements());
@@ -5132,7 +5132,7 @@ QualType Sema::CheckIndirectionOperand(Expr *Op, SourceLocation OpLoc) {
   if (const PointerType *PT = Ty->getAs<PointerType>())
     return PT->getPointeeType();
 
-  if (const ObjCObjectPointerType *OPT = Ty->getAsObjCObjectPointerType())
+  if (const ObjCObjectPointerType *OPT = Ty->getAs<ObjCObjectPointerType>())
     return OPT->getPointeeType();
 
   Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer)
@@ -5735,7 +5735,7 @@ void Sema::ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope) {
            diag::warn_attribute_sentinel_not_variadic) << 1;
       // FIXME: remove the attribute.
     }
-    QualType RetTy = T.getTypePtr()->getAsFunctionType()->getResultType();
+    QualType RetTy = T.getTypePtr()->getAs<FunctionType>()->getResultType();
 
     // Do not allow returning a objc interface by-value.
     if (RetTy->isObjCInterfaceType()) {
@@ -5787,7 +5787,7 @@ void Sema::ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope) {
 
   // Analyze the return type.
   QualType T = GetTypeForDeclarator(ParamInfo, CurScope);
-  QualType RetTy = T->getAsFunctionType()->getResultType();
+  QualType RetTy = T->getAs<FunctionType>()->getResultType();
 
   // Do not allow returning a objc interface by-value.
   if (RetTy->isObjCInterfaceType()) {
index 503e318afa908835ca552335d827bf8b62867211..b11f39795da5e4ff10978ff80861e7532e5c8fcf 100644 (file)
@@ -966,7 +966,7 @@ Sema::IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType) {
   if (StringLiteral *StrLit = dyn_cast<StringLiteral>(From))
     if (const PointerType *ToPtrType = ToType->getAs<PointerType>())
       if (const BuiltinType *ToPointeeType
-          = ToPtrType->getPointeeType()->getAsBuiltinType()) {
+          = ToPtrType->getPointeeType()->getAs<BuiltinType>()) {
         // This conversion is considered only when there is an
         // explicit appropriate pointer target type (C++ 4.2p2).
         if (ToPtrType->getPointeeType().getCVRQualifiers() == 0 &&
@@ -1856,7 +1856,7 @@ Sema::OwningExprResult Sema::MaybeBindToTemporary(Expr *E) {
     if (const PointerType *PT = Ty->getAs<PointerType>())
       Ty = PT->getPointeeType();
     
-    const FunctionType *FTy = Ty->getAsFunctionType();
+    const FunctionType *FTy = Ty->getAs<FunctionType>();
     if (FTy->getResultType()->isReferenceType())
       return Owned(E);
   }
index 2616c5c0bd1e7ce94ac7cee25c3adb95436ead6e..2023f7b27bb9f9bed799cdc3273580596d615b5e 100644 (file)
@@ -415,7 +415,7 @@ Sema::ExprResult Sema::ActOnClassMessage(
     NamedDecl *IDecl = LookupName(TUScope, receiverName, LookupOrdinaryName);
     if (TypedefDecl *OCTD = dyn_cast_or_null<TypedefDecl>(IDecl)) {
       const ObjCInterfaceType *OCIT;
-      OCIT = OCTD->getUnderlyingType()->getAsObjCInterfaceType();
+      OCIT = OCTD->getUnderlyingType()->getAs<ObjCInterfaceType>();
       if (!OCIT) {
         Diag(receiverLoc, diag::err_invalid_receiver_to_message);
         return true;
index 6574524d14d0d67df2416d9346e2a9c491c2f89e..c430751c2e26af60305a872528c1667dc62e1130 100644 (file)
@@ -421,7 +421,7 @@ void InitListChecker::FillInValueInitializations(InitListExpr *ILE) {
     ElementType = AType->getElementType();
     if (const ConstantArrayType *CAType = dyn_cast<ConstantArrayType>(AType))
       NumElements = CAType->getSize().getZExtValue();
-  } else if (const VectorType *VType = ILE->getType()->getAsVectorType()) {
+  } else if (const VectorType *VType = ILE->getType()->getAs<VectorType>()) {
     ElementType = VType->getElementType();
     NumElements = VType->getNumElements();
   } else
@@ -499,7 +499,7 @@ void InitListChecker::CheckImplicitInitList(InitListExpr *ParentIList,
   else if (T->isStructureType() || T->isUnionType())
     maxElements = numStructUnionElements(T);
   else if (T->isVectorType())
-    maxElements = T->getAsVectorType()->getNumElements();
+    maxElements = T->getAs<VectorType>()->getNumElements();
   else
     assert(0 && "CheckImplicitInitList(): Illegal type");
 
@@ -835,7 +835,7 @@ void InitListChecker::CheckVectorType(InitListExpr *IList, QualType DeclType,
                                       InitListExpr *StructuredList,
                                       unsigned &StructuredIndex) {
   if (Index < IList->getNumInits()) {
-    const VectorType *VT = DeclType->getAsVectorType();
+    const VectorType *VT = DeclType->getAs<VectorType>();
     unsigned maxElements = VT->getNumElements();
     unsigned numEltsInit = 0;
     QualType elementType = VT->getElementType();
@@ -860,7 +860,7 @@ void InitListChecker::CheckVectorType(InitListExpr *IList, QualType DeclType,
                               StructuredList, StructuredIndex);
           ++numEltsInit;
         } else {
-          const VectorType *IVT = IType->getAsVectorType();
+          const VectorType *IVT = IType->getAs<VectorType>();
           unsigned numIElts = IVT->getNumElements();
           QualType VecType = SemaRef.Context.getExtVectorType(elementType,
                                                               numIElts);
@@ -1625,7 +1625,7 @@ InitListChecker::getStructuredSubobjectInit(InitListExpr *IList, unsigned Index,
       if (NumInits && NumElements > NumInits)
         NumElements = 0;
     }
-  } else if (const VectorType *VType = CurrentObjectType->getAsVectorType())
+  } else if (const VectorType *VType = CurrentObjectType->getAs<VectorType>())
     NumElements = VType->getNumElements();
   else if (const RecordType *RType = CurrentObjectType->getAs<RecordType>()) {
     RecordDecl *RDecl = RType->getDecl();
index 70befd630c59464d4277890d8c613529b492497e..44641b72e4af981ebbb67681acfbcc4deaf1d9c8 100644 (file)
@@ -1444,7 +1444,7 @@ addAssociatedClassesAndNamespaces(QualType T,
 
   //     -- If T is a fundamental type, its associated sets of
   //        namespaces and classes are both empty.
-  if (T->getAsBuiltinType())
+  if (T->getAs<BuiltinType>())
     return;
 
   //     -- If T is a class type (including unions), its associated
@@ -1465,7 +1465,7 @@ addAssociatedClassesAndNamespaces(QualType T,
   //        the namespace in which it is defined. If it is class
   //        member, its associated class is the member’s class; else
   //        it has no associated class.
-  if (const EnumType *EnumT = T->getAsEnumType()) {
+  if (const EnumType *EnumT = T->getAs<EnumType>()) {
     EnumDecl *Enum = EnumT->getDecl();
 
     DeclContext *Ctx = Enum->getDeclContext();
@@ -1483,13 +1483,13 @@ addAssociatedClassesAndNamespaces(QualType T,
   //     -- If T is a function type, its associated namespaces and
   //        classes are those associated with the function parameter
   //        types and those associated with the return type.
-  if (const FunctionType *FunctionType = T->getAsFunctionType()) {
+  if (const FunctionType *FnType = T->getAs<FunctionType>()) {
     // Return type
-    addAssociatedClassesAndNamespaces(FunctionType->getResultType(),
+    addAssociatedClassesAndNamespaces(FnType->getResultType(),
                                       Context,
                                       AssociatedNamespaces, AssociatedClasses);
 
-    const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FunctionType);
+    const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FnType);
     if (!Proto)
       return;
 
@@ -1629,7 +1629,7 @@ IsAcceptableNonMemberOperatorCandidate(FunctionDecl *Fn,
   if (T1->isRecordType() || (!T2.isNull() && T2->isRecordType()))
     return true;
 
-  const FunctionProtoType *Proto = Fn->getType()->getAsFunctionProtoType();
+  const FunctionProtoType *Proto = Fn->getType()->getAs<FunctionProtoType>();
   if (Proto->getNumArgs() < 1)
     return false;
 
index 33766f9a79653d31fbdc088d3a14705b6a98a2ee..2ff0c0544af540445fe7196ff5ed6a18c43c9564 100644 (file)
@@ -686,7 +686,7 @@ Sema::IsStandardConversion(Expr* From, QualType ToType,
 /// ToType is an integral promotion (C++ 4.5). If so, returns true and
 /// sets PromotedType to the promoted type.
 bool Sema::IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType) {
-  const BuiltinType *To = ToType->getAsBuiltinType();
+  const BuiltinType *To = ToType->getAs<BuiltinType>();
   // All integers are built-in.
   if (!To) {
     return false;
@@ -720,7 +720,7 @@ bool Sema::IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType) {
     // unsigned.
     bool FromIsSigned;
     uint64_t FromSize = Context.getTypeSize(FromType);
-    if (const EnumType *FromEnumType = FromType->getAsEnumType()) {
+    if (const EnumType *FromEnumType = FromType->getAs<EnumType>()) {
       QualType UnderlyingType = FromEnumType->getDecl()->getIntegerType();
       FromIsSigned = UnderlyingType->isSignedIntegerType();
     } else {
@@ -798,8 +798,8 @@ bool Sema::IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType) {
 bool Sema::IsFloatingPointPromotion(QualType FromType, QualType ToType) {
   /// An rvalue of type float can be converted to an rvalue of type
   /// double. (C++ 4.6p1).
-  if (const BuiltinType *FromBuiltin = FromType->getAsBuiltinType())
-    if (const BuiltinType *ToBuiltin = ToType->getAsBuiltinType()) {
+  if (const BuiltinType *FromBuiltin = FromType->getAs<BuiltinType>())
+    if (const BuiltinType *ToBuiltin = ToType->getAs<BuiltinType>()) {
       if (FromBuiltin->getKind() == BuiltinType::Float &&
           ToBuiltin->getKind() == BuiltinType::Double)
         return true;
@@ -823,11 +823,11 @@ bool Sema::IsFloatingPointPromotion(QualType FromType, QualType ToType) {
 /// where the conversion between the underlying real types is a
 /// floating-point or integral promotion.
 bool Sema::IsComplexPromotion(QualType FromType, QualType ToType) {
-  const ComplexType *FromComplex = FromType->getAsComplexType();
+  const ComplexType *FromComplex = FromType->getAs<ComplexType>();
   if (!FromComplex)
     return false;
 
-  const ComplexType *ToComplex = ToType->getAsComplexType();
+  const ComplexType *ToComplex = ToType->getAs<ComplexType>();
   if (!ToComplex)
     return false;
 
@@ -1003,9 +1003,9 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
     return false;
 
   // First, we handle all conversions on ObjC object pointer types.
-  const ObjCObjectPointerType* ToObjCPtr = ToType->getAsObjCObjectPointerType();
+  const ObjCObjectPointerType* ToObjCPtr = ToType->getAs<ObjCObjectPointerType>();
   const ObjCObjectPointerType *FromObjCPtr =
-    FromType->getAsObjCObjectPointerType();
+    FromType->getAs<ObjCObjectPointerType>();
 
   if (ToObjCPtr && FromObjCPtr) {
     // Objective C++: We're able to convert between "id" or "Class" and a
@@ -1070,9 +1070,9 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
   // pointer conversions. If so, we permit the conversion (but
   // complain about it).
   const FunctionProtoType *FromFunctionType
-    = FromPointeeType->getAsFunctionProtoType();
+    = FromPointeeType->getAs<FunctionProtoType>();
   const FunctionProtoType *ToFunctionType
-    = ToPointeeType->getAsFunctionProtoType();
+    = ToPointeeType->getAs<FunctionProtoType>();
   if (FromFunctionType && ToFunctionType) {
     // If the function types are exactly the same, this isn't an
     // Objective-C pointer conversion.
@@ -1160,9 +1160,9 @@ bool Sema::CheckPointerConversion(Expr *From, QualType ToType,
       }
     }
   if (const ObjCObjectPointerType *FromPtrType =
-        FromType->getAsObjCObjectPointerType())
+        FromType->getAs<ObjCObjectPointerType>())
     if (const ObjCObjectPointerType *ToPtrType =
-          ToType->getAsObjCObjectPointerType()) {
+          ToType->getAs<ObjCObjectPointerType>()) {
       // Objective-C++ conversions are always okay.
       // FIXME: We should have a different class of conversions for the
       // Objective-C++ implicit conversions.
@@ -1644,8 +1644,8 @@ Sema::CompareStandardConversionSequences(const StandardConversionSequence& SCS1,
 
     // Objective-C++: If one interface is more specific than the
     // other, it is the better one.
-    const ObjCInterfaceType* FromIface1 = FromPointee1->getAsObjCInterfaceType();
-    const ObjCInterfaceType* FromIface2 = FromPointee2->getAsObjCInterfaceType();
+    const ObjCInterfaceType* FromIface1 = FromPointee1->getAs<ObjCInterfaceType>();
+    const ObjCInterfaceType* FromIface2 = FromPointee2->getAs<ObjCInterfaceType>();
     if (FromIface1 && FromIface1) {
       if (Context.canAssignObjCInterfaces(FromIface2, FromIface1))
         return ImplicitConversionSequence::Better;
@@ -1832,10 +1832,10 @@ Sema::CompareDerivedToBaseConversions(const StandardConversionSequence& SCS1,
     QualType ToPointee2
       = ToType2->getAs<PointerType>()->getPointeeType().getUnqualifiedType();
 
-    const ObjCInterfaceType* FromIface1 = FromPointee1->getAsObjCInterfaceType();
-    const ObjCInterfaceType* FromIface2 = FromPointee2->getAsObjCInterfaceType();
-    const ObjCInterfaceType* ToIface1 = ToPointee1->getAsObjCInterfaceType();
-    const ObjCInterfaceType* ToIface2 = ToPointee2->getAsObjCInterfaceType();
+    const ObjCInterfaceType* FromIface1 = FromPointee1->getAs<ObjCInterfaceType>();
+    const ObjCInterfaceType* FromIface2 = FromPointee2->getAs<ObjCInterfaceType>();
+    const ObjCInterfaceType* ToIface1 = ToPointee1->getAs<ObjCInterfaceType>();
+    const ObjCInterfaceType* ToIface2 = ToPointee2->getAs<ObjCInterfaceType>();
 
     //   -- conversion of C* to B* is better than conversion of C* to A*,
     if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
@@ -2129,7 +2129,7 @@ Sema::AddOverloadCandidate(FunctionDecl *Function,
                            bool SuppressUserConversions,
                            bool ForceRValue) {
   const FunctionProtoType* Proto
-    = dyn_cast<FunctionProtoType>(Function->getType()->getAsFunctionType());
+    = dyn_cast<FunctionProtoType>(Function->getType()->getAs<FunctionType>());
   assert(Proto && "Functions without a prototype cannot be overloaded");
   assert(!isa<CXXConversionDecl>(Function) &&
          "Use AddConversionCandidate for conversion functions");
@@ -2247,7 +2247,7 @@ Sema::AddMethodCandidate(CXXMethodDecl *Method, Expr *Object,
                          OverloadCandidateSet& CandidateSet,
                          bool SuppressUserConversions, bool ForceRValue) {
   const FunctionProtoType* Proto
-    = dyn_cast<FunctionProtoType>(Method->getType()->getAsFunctionType());
+    = dyn_cast<FunctionProtoType>(Method->getType()->getAs<FunctionType>());
   assert(Proto && "Methods without a prototype cannot be overloaded");
   assert(!isa<CXXConversionDecl>(Method) &&
          "Use AddConversionCandidate for conversion functions");
@@ -3865,7 +3865,7 @@ Sema::PrintOverloadCandidates(OverloadCandidateSet& CandidateSet,
           isPointer = true;
         }
         // Desugar down to a function type.
-        FnType = QualType(FnType->getAsFunctionType(), 0);
+        FnType = QualType(FnType->getAs<FunctionType>(), 0);
         // Reconstruct the pointer/reference as appropriate.
         if (isPointer) FnType = Context.getPointerType(FnType);
         if (isRValueReference) FnType = Context.getRValueReferenceType(FnType);
@@ -4318,7 +4318,7 @@ Sema::OwningExprResult Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc,
 
       // Determine the result type
       QualType ResultTy
-        = FnDecl->getType()->getAsFunctionType()->getResultType();
+        = FnDecl->getType()->getAs<FunctionType>()->getResultType();
       ResultTy = ResultTy.getNonReferenceType();
 
       // Build the actual expression node.
@@ -4476,7 +4476,7 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
 
         // Determine the result type
         QualType ResultTy
-          = FnDecl->getType()->getAsFunctionType()->getResultType();
+          = FnDecl->getType()->getAs<FunctionType>()->getResultType();
         ResultTy = ResultTy.getNonReferenceType();
 
         // Build the actual expression node.
@@ -4714,7 +4714,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object,
       if (const PointerType *ConvPtrType = ConvType->getAs<PointerType>())
         ConvType = ConvPtrType->getPointeeType();
 
-      if (const FunctionProtoType *Proto = ConvType->getAsFunctionProtoType())
+      if (const FunctionProtoType *Proto = ConvType->getAs<FunctionProtoType>())
         AddSurrogateCandidate(Conv, Proto, Object, Args, NumArgs, CandidateSet);
     }
   }
@@ -4783,7 +4783,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object,
   // that calls this method, using Object for the implicit object
   // parameter and passing along the remaining arguments.
   CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
-  const FunctionProtoType *Proto = Method->getType()->getAsFunctionProtoType();
+  const FunctionProtoType *Proto = Method->getType()->getAs<FunctionProtoType>();
 
   unsigned NumArgsInProto = Proto->getNumArgs();
   unsigned NumArgsToCheck = NumArgs;
index e6597f52f7e253fa0205580dd926a013300a2bc7..97b5b52ce54167dc3777f37afa4e8f6d2e4ba792 100644 (file)
@@ -1625,7 +1625,7 @@ bool Sema::CheckTemplateArgument(TemplateTypeParmDecl *Param,
   //
   // FIXME: Perform the recursive and no-linkage type checks.
   const TagType *Tag = 0;
-  if (const EnumType *EnumT = Arg->getAsEnumType())
+  if (const EnumType *EnumT = Arg->getAs<EnumType>())
     Tag = EnumT;
   else if (const RecordType *RecordT = Arg->getAs<RecordType>())
     Tag = RecordT;
@@ -1890,7 +1890,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
     }
 
     QualType IntegerType = Context.getCanonicalType(ParamType);
-    if (const EnumType *Enum = IntegerType->getAsEnumType())
+    if (const EnumType *Enum = IntegerType->getAs<EnumType>())
       IntegerType = Context.getCanonicalType(Enum->getDecl()->getIntegerType());
 
     if (!Arg->isValueDependent()) {
@@ -3209,7 +3209,7 @@ Sema::ActOnTypenameType(SourceLocation TypenameLoc, const CXXScopeSpec &SS,
   NestedNameSpecifier *NNS
     = static_cast<NestedNameSpecifier *>(SS.getScopeRep());
   const TemplateSpecializationType *TemplateId
-    = T->getAsTemplateSpecializationType();
+    = T->getAs<TemplateSpecializationType>();
   assert(TemplateId && "Expected a template specialization type");
 
   if (computeDeclContext(SS, false)) {
index 5a5d63edc2966a0b2fc3782f15eeaebc6fa6a5d6..8d4999bf6d66a4bcb32a438d967a0f56794e2512 100644 (file)
@@ -410,7 +410,7 @@ DeduceTemplateArguments(ASTContext &Context,
   //     T
   //     cv-list T
   if (const TemplateTypeParmType *TemplateTypeParm
-        = Param->getAsTemplateTypeParmType()) {
+        = Param->getAs<TemplateTypeParmType>()) {
     unsigned Index = TemplateTypeParm->getIndex();
     bool RecanonicalizeArg = false;
 
@@ -1040,7 +1040,7 @@ Sema::DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial,
 /// \brief Determine whether the given type T is a simple-template-id type.
 static bool isSimpleTemplateIdType(QualType T) {
   if (const TemplateSpecializationType *Spec
-        = T->getAsTemplateSpecializationType())
+        = T->getAs<TemplateSpecializationType>())
     return Spec->getTemplateName().getAsTemplateDecl() != 0;
 
   return false;
@@ -1157,7 +1157,7 @@ Sema::SubstituteExplicitTemplateArguments(
   if (FunctionType) {
     // FIXME: exception-specifications?
     const FunctionProtoType *Proto
-      = Function->getType()->getAsFunctionProtoType();
+      = Function->getType()->getAs<FunctionProtoType>();
     assert(Proto && "Function template does not have a prototype?");
 
     QualType ResultType
@@ -1310,7 +1310,7 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
     return TDK_TooFewArguments;
   else if (NumArgs > Function->getNumParams()) {
     const FunctionProtoType *Proto
-      = Function->getType()->getAsFunctionProtoType();
+      = Function->getType()->getAs<FunctionProtoType>();
     if (!Proto->isVariadic())
       return TDK_TooManyArguments;
 
@@ -1384,7 +1384,7 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
       //   the argument is an lvalue, the type A& is used in place of A for
       //   type deduction.
       if (isa<RValueReferenceType>(ParamRefType) &&
-          ParamRefType->getAsTemplateTypeParmType() &&
+          ParamRefType->getAs<TemplateTypeParmType>() &&
           Args[I]->isLvalue(Context) == Expr::LV_Valid)
         ArgType = Context.getLValueReferenceType(ArgType);
     }
index a43413e275212b3c8081a9f9698320901467b65e..0564cbefa63775e87f7c05024fdef33a4cb3eb34 100644 (file)
@@ -592,7 +592,7 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D,
   } else if (CXXConversionDecl *Conversion = dyn_cast<CXXConversionDecl>(D)) {
     CanQualType ConvTy
       = SemaRef.Context.getCanonicalType(
-                                      T->getAsFunctionType()->getResultType());
+                                      T->getAs<FunctionType>()->getResultType());
     Name = SemaRef.Context.DeclarationNames.getCXXConversionFunctionName(
                                                                       ConvTy);
     Method = CXXConversionDecl::Create(SemaRef.Context, Record,
@@ -867,7 +867,7 @@ TemplateDeclInstantiator::SubstFunctionType(FunctionDecl *D,
   if (InvalidDecl)
     return QualType();
 
-  const FunctionProtoType *Proto = D->getType()->getAsFunctionProtoType();
+  const FunctionProtoType *Proto = D->getType()->getAs<FunctionProtoType>();
   assert(Proto && "Missing prototype?");
   QualType ResultType
     = SemaRef.SubstType(Proto->getResultType(), TemplateArgs,
index a56e1ae7b248febe2c06c899a475e55a4b280b2d..6fee787a74eb09a51ad186d2229f2f2c5fcc3086 100644 (file)
@@ -214,7 +214,7 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS,
     Result = GetTypeFromParser(DS.getTypeRep());
 
     if (DeclSpec::ProtocolQualifierListTy PQ = DS.getProtocolQualifiers()) {
-      if (const ObjCInterfaceType *Interface = Result->getAsObjCInterfaceType())
+      if (const ObjCInterfaceType *Interface = Result->getAs<ObjCInterfaceType>())
         // It would be nice if protocol qualifiers were only stored with the
         // ObjCObjectPointerType. Unfortunately, this isn't possible due
         // to the following typedef idiom (which is uncommon, but allowed):
@@ -949,7 +949,7 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
         // Build the type anyway.
       }
       if (getLangOptions().ObjC1 && T->isObjCInterfaceType()) {
-        const ObjCInterfaceType *OIT = T->getAsObjCInterfaceType();
+        const ObjCInterfaceType *OIT = T->getAs<ObjCInterfaceType>();
         T = Context.getObjCObjectPointerType(T,
                                          (ObjCProtocolDecl **)OIT->qual_begin(),
                                          OIT->getNumProtocols());
@@ -1141,7 +1141,7 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
           } else if (!FTI.hasPrototype) {
             if (ArgTy->isPromotableIntegerType()) {
               ArgTy = Context.getPromotedIntegerType(ArgTy);
-            } else if (const BuiltinType* BTy = ArgTy->getAsBuiltinType()) {
+            } else if (const BuiltinType* BTy = ArgTy->getAs<BuiltinType>()) {
               if (BTy->getKind() == BuiltinType::Float)
                 ArgTy = Context.DoubleTy;
             }
@@ -1223,7 +1223,7 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
   }
 
   if (getLangOptions().CPlusPlus && T->isFunctionType()) {
-    const FunctionProtoType *FnTy = T->getAsFunctionProtoType();
+    const FunctionProtoType *FnTy = T->getAs<FunctionProtoType>();
     assert(FnTy && "Why oh why is there not a FunctionProtoType here ?");
 
     // C++ 8.3.5p4: A cv-qualifier-seq shall only be part of the function type
@@ -1400,7 +1400,7 @@ bool Sema::CheckDistantExceptionSpec(QualType T) {
   else
     return false;
 
-  const FunctionProtoType *FnT = T->getAsFunctionProtoType();
+  const FunctionProtoType *FnT = T->getAs<FunctionProtoType>();
   if (!FnT)
     return false;
 
@@ -1816,7 +1816,7 @@ bool Sema::RequireCompleteType(SourceLocation Loc, QualType T,
   const TagType *Tag = 0;
   if (const RecordType *Record = T->getAs<RecordType>())
     Tag = Record;
-  else if (const EnumType *Enum = T->getAsEnumType())
+  else if (const EnumType *Enum = T->getAs<EnumType>())
     Tag = Enum;
 
   if (Tag && !Tag->getDecl()->isInvalidDecl())