aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-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
44 files changed, 273 insertions, 405 deletions
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) {
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())
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 60458b4fb6..6e46c4f701 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -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;
}
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index 8df52c9377..9c34547db1 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -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))
diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp
index a6f2b823fe..05d0c26835 100644
--- a/lib/AST/StmtPrinter.cpp
+++ b/lib/AST/StmtPrinter.cpp
@@ -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;
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index 1a6ea0a136..2783211661 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -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->getNumProtocol