aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2009-09-21 23:43:11 +0000
committerJohn McCall <rjmccall@apple.com>2009-09-21 23:43:11 +0000
commit183700f494ec9b6701b6efe82bcb25f4c79ba561 (patch)
tree797f214407f66937802226652d130f95d596e33b
parentc32b24452ebb537934b20b7133a3a0cbce447666 (diff)
Change all the Type::getAsFoo() methods to specializations of Type::getAs().
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
-rw-r--r--include/clang/AST/Decl.h2
-rw-r--r--include/clang/AST/DeclCXX.h4
-rw-r--r--include/clang/AST/Type.h59
-rw-r--r--include/clang/AST/TypeNodes.def17
-rw-r--r--include/clang/Frontend/DeclXML.def8
-rw-r--r--lib/AST/ASTContext.cpp58
-rw-r--r--lib/AST/Decl.cpp2
-rw-r--r--lib/AST/DeclCXX.cpp6
-rw-r--r--lib/AST/DeclPrinter.cpp6
-rw-r--r--lib/AST/Expr.cpp8
-rw-r--r--lib/AST/ExprConstant.cpp10
-rw-r--r--lib/AST/StmtPrinter.cpp2
-rw-r--r--lib/AST/Type.cpp148
-rw-r--r--lib/Analysis/BasicObjCFoundationChecks.cpp2
-rw-r--r--lib/Analysis/CFRefCount.cpp14
-rw-r--r--lib/Analysis/CheckNSError.cpp4
-rw-r--r--lib/Analysis/GRExprEngine.cpp2
-rw-r--r--lib/Analysis/RegionStore.cpp2
-rw-r--r--lib/CodeGen/CGBlocks.cpp4
-rw-r--r--lib/CodeGen/CGCXX.cpp36
-rw-r--r--lib/CodeGen/CGCall.cpp4
-rw-r--r--lib/CodeGen/CGExpr.cpp12
-rw-r--r--lib/CodeGen/CGExprComplex.cpp20
-rw-r--r--lib/CodeGen/CGExprScalar.cpp10
-rw-r--r--lib/CodeGen/CGObjCGNU.cpp6
-rw-r--r--lib/CodeGen/CGObjCMac.cpp12
-rw-r--r--lib/CodeGen/CodeGenFunction.cpp2
-rw-r--r--lib/CodeGen/CodeGenModule.cpp2
-rw-r--r--lib/CodeGen/Mangle.cpp2
-rw-r--r--lib/CodeGen/TargetABIInfo.cpp20
-rw-r--r--lib/Frontend/DocumentXML.cpp2
-rw-r--r--lib/Frontend/PCHReader.cpp6
-rw-r--r--lib/Frontend/RewriteBlocks.cpp6
-rw-r--r--lib/Frontend/RewriteObjC.cpp18
-rw-r--r--lib/Sema/SemaChecking.cpp14
-rw-r--r--lib/Sema/SemaDecl.cpp26
-rw-r--r--lib/Sema/SemaDeclAttr.cpp14
-rw-r--r--lib/Sema/SemaDeclCXX.cpp26
-rw-r--r--lib/Sema/SemaDeclObjC.cpp6
-rw-r--r--lib/Sema/SemaExpr.cpp56
-rw-r--r--lib/Sema/SemaExprCXX.cpp4
-rw-r--r--lib/Sema/SemaExprObjC.cpp2
-rw-r--r--lib/Sema/SemaInit.cpp10
-rw-r--r--lib/Sema/SemaLookup.cpp12
-rw-r--r--lib/Sema/SemaOverload.cpp50
-rw-r--r--lib/Sema/SemaTemplate.cpp6
-rw-r--r--lib/Sema/SemaTemplateDeduction.cpp10
-rw-r--r--lib/Sema/SemaTemplateInstantiateDecl.cpp4
-rw-r--r--lib/Sema/SemaType.cpp12
49 files changed, 326 insertions, 442 deletions
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index 231e36ab5f..4ea5e1a734 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -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; }
diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h
index 4d7c674835..cf86bf0b7e 100644
--- a/include/clang/AST/DeclCXX.h
+++ b/include/clang/AST/DeclCXX.h
@@ -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.
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index 4ebda908a3..7871830314 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -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;
diff --git a/include/clang/AST/TypeNodes.def b/include/clang/AST/TypeNodes.def
index f1d3b362ce..a2838439c7 100644
--- a/include/clang/AST/TypeNodes.def
+++ b/include/clang/AST/TypeNodes.def
@@ -31,6 +31,12 @@
// 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
diff --git a/include/clang/Frontend/DeclXML.def b/include/clang/Frontend/DeclXML.def
index 956d9719f9..36323c260c 100644
--- a/include/clang/Frontend/DeclXML.def
+++ b/include/clang/Frontend/DeclXML.def
@@ -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")
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index f701ae4732..a12ac207d9 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -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:
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 77c085a355..1a7aaac6f7 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -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();
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
index 53e2b84067..f3ea04305b 100644
--- a/lib/AST/DeclCXX.cpp
+++ b/lib/AST/DeclCXX.cpp
@@ -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());
}
diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp
index 8aae742ef1..f448144d28 100644
--- a/lib/AST/DeclPrinter.cpp
+++ b/lib/AST/DeclPrinter.cpp
@@ -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) {
SubPol