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
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp
index 59e2ee8..41b49c7 100644
--- a/lib/CodeGen/CGBlocks.cpp
+++ b/lib/CodeGen/CGBlocks.cpp
@@ -417,13 +417,13 @@
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);
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp
index 715f1b0..91b984a 100644
--- a/lib/CodeGen/CGCXX.cpp
+++ b/lib/CodeGen/CGCXX.cpp
@@ -183,7 +183,7 @@
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 @@
// 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 @@
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 @@
}
}
- 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 @@
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 @@
// Call delete.
FunctionDecl *DeleteFD = E->getOperatorDelete();
const FunctionProtoType *DeleteFTy =
- DeleteFD->getType()->getAsFunctionProtoType();
+ DeleteFD->getType()->getAs<FunctionProtoType>();
CallArgList DeleteArgs;
@@ -872,9 +872,9 @@
// 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
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 @@
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 @@
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);
}
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp
index c58c0f6..1dbb6e6 100644
--- a/lib/CodeGen/CGCall.cpp
+++ b/lib/CodeGen/CGCall.cpp
@@ -69,7 +69,7 @@
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 @@
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>(),
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 2539387..a7eebbf 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -143,7 +143,7 @@
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 @@
// 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 @@
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 @@
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 @@
"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.
diff --git a/lib/CodeGen/CGExprComplex.cpp b/lib/CodeGen/CGExprComplex.cpp
index 4fcfe06..9e81e4f 100644
--- a/lib/CodeGen/CGExprComplex.cpp
+++ b/lib/CodeGen/CGExprComplex.cpp
@@ -181,13 +181,13 @@
}
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 @@
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 @@
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 @@
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 @@
// 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 @@
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 @@
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 @@
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);
}
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index 682d14c..308376c 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -494,7 +494,7 @@
// 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 @@
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 @@
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 @@
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()) {
diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp
index 89493db..e19debc 100644
--- a/lib/CodeGen/CGObjCGNU.cpp
+++ b/lib/CodeGen/CGObjCGNU.cpp
@@ -1688,10 +1688,10 @@
// 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 @@
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));
}
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index f6cdd27..df60583 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -1539,7 +1539,7 @@
: 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 @@
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 @@
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 @@
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 @@
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 @@
} 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.");
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index 0ed61bf..f21984e 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -224,7 +224,7 @@
}
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)
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index fca6ebe..af9f7e9 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -1099,7 +1099,7 @@
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 {
diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp
index 48445e6..973f0d1 100644
--- a/lib/CodeGen/Mangle.cpp
+++ b/lib/CodeGen/Mangle.cpp
@@ -241,7 +241,7 @@
FD = PrimaryTemplate->getTemplatedDecl();
}
- mangleBareFunctionType(FD->getType()->getAsFunctionType(), MangleReturnType);
+ mangleBareFunctionType(FD->getType()->getAs<FunctionType>(), MangleReturnType);
}
static bool isStdNamespace(const DeclContext *DC) {
diff --git a/lib/CodeGen/TargetABIInfo.cpp b/lib/CodeGen/TargetABIInfo.cpp
index a9d883b..3ad8cfc 100644
--- a/lib/CodeGen/TargetABIInfo.cpp
+++ b/lib/CodeGen/TargetABIInfo.cpp
@@ -159,7 +159,7 @@
}
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 @@
}
// 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 @@
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 @@
// 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 @@
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 @@
}
// 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 @@
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 @@
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 @@
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: