@@ -6714,8 +6714,8 @@ ExprResult Sema::BuildVectorLiteral(SourceLocation LParenLoc,
6714
6714
assert(Ty->isVectorType() && "Expected vector type");
6715
6715
6716
6716
SmallVector<Expr *, 8> initExprs;
6717
- const VectorType *VTy = Ty->getAs <VectorType>();
6718
- unsigned numElems = Ty->getAs<VectorType>() ->getNumElements();
6717
+ const VectorType *VTy = Ty->castAs <VectorType>();
6718
+ unsigned numElems = VTy ->getNumElements();
6719
6719
6720
6720
// '(...)' form of vector initialization in AltiVec: the number of
6721
6721
// initializers must be one or must match the size of the vector.
@@ -6726,7 +6726,7 @@ ExprResult Sema::BuildVectorLiteral(SourceLocation LParenLoc,
6726
6726
// vector. If a single value is specified in the initializer then it will
6727
6727
// be replicated to all the components of the vector
6728
6728
if (numExprs == 1) {
6729
- QualType ElemTy = Ty->getAs<VectorType>() ->getElementType();
6729
+ QualType ElemTy = VTy ->getElementType();
6730
6730
ExprResult Literal = DefaultLvalueConversion(exprs[0]);
6731
6731
if (Literal.isInvalid())
6732
6732
return ExprError();
@@ -6748,7 +6748,7 @@ ExprResult Sema::BuildVectorLiteral(SourceLocation LParenLoc,
6748
6748
if (getLangOpts().OpenCL &&
6749
6749
VTy->getVectorKind() == VectorType::GenericVector &&
6750
6750
numExprs == 1) {
6751
- QualType ElemTy = Ty->getAs<VectorType>() ->getElementType();
6751
+ QualType ElemTy = VTy ->getElementType();
6752
6752
ExprResult Literal = DefaultLvalueConversion(exprs[0]);
6753
6753
if (Literal.isInvalid())
6754
6754
return ExprError();
@@ -7047,8 +7047,8 @@ checkConditionalObjectPointersCompatibility(Sema &S, ExprResult &LHS,
7047
7047
QualType RHSTy = RHS.get()->getType();
7048
7048
7049
7049
// get the "pointed to" types
7050
- QualType lhptee = LHSTy->getAs <PointerType>()->getPointeeType();
7051
- QualType rhptee = RHSTy->getAs <PointerType>()->getPointeeType();
7050
+ QualType lhptee = LHSTy->castAs <PointerType>()->getPointeeType();
7051
+ QualType rhptee = RHSTy->castAs <PointerType>()->getPointeeType();
7052
7052
7053
7053
// ignore qualifiers on void (C99 6.5.15p3, clause 6)
7054
7054
if (lhptee->isVoidType() && rhptee->isIncompleteOrObjectType()) {
@@ -7533,8 +7533,8 @@ QualType Sema::FindCompositeObjCPointerType(ExprResult &LHS, ExprResult &RHS,
7533
7533
LHS = RHS = true;
7534
7534
return QualType();
7535
7535
}
7536
- QualType lhptee = LHSTy->getAs <PointerType>()->getPointeeType();
7537
- QualType rhptee = RHSTy->getAs <ObjCObjectPointerType>()->getPointeeType();
7536
+ QualType lhptee = LHSTy->castAs <PointerType>()->getPointeeType();
7537
+ QualType rhptee = RHSTy->castAs <ObjCObjectPointerType>()->getPointeeType();
7538
7538
QualType destPointee
7539
7539
= Context.getQualifiedType(lhptee, rhptee.getQualifiers());
7540
7540
QualType destType = Context.getPointerType(destPointee);
@@ -7553,8 +7553,8 @@ QualType Sema::FindCompositeObjCPointerType(ExprResult &LHS, ExprResult &RHS,
7553
7553
LHS = RHS = true;
7554
7554
return QualType();
7555
7555
}
7556
- QualType lhptee = LHSTy->getAs <ObjCObjectPointerType>()->getPointeeType();
7557
- QualType rhptee = RHSTy->getAs <PointerType>()->getPointeeType();
7556
+ QualType lhptee = LHSTy->castAs <ObjCObjectPointerType>()->getPointeeType();
7557
+ QualType rhptee = RHSTy->castAs <PointerType>()->getPointeeType();
7558
7558
QualType destPointee
7559
7559
= Context.getQualifiedType(rhptee, lhptee.getQualifiers());
7560
7560
QualType destType = Context.getPointerType(destPointee);
@@ -8059,8 +8059,8 @@ checkObjCPointerTypesForAssignment(Sema &S, QualType LHSType,
8059
8059
return Sema::IncompatiblePointer;
8060
8060
return Sema::Compatible;
8061
8061
}
8062
- QualType lhptee = LHSType->getAs <ObjCObjectPointerType>()->getPointeeType();
8063
- QualType rhptee = RHSType->getAs <ObjCObjectPointerType>()->getPointeeType();
8062
+ QualType lhptee = LHSType->castAs <ObjCObjectPointerType>()->getPointeeType();
8063
+ QualType rhptee = RHSType->castAs <ObjCObjectPointerType>()->getPointeeType();
8064
8064
8065
8065
if (!lhptee.isAtLeastAsQualifiedAs(rhptee) &&
8066
8066
// make an exception for id<P>
@@ -9401,8 +9401,8 @@ static bool checkArithmeticBinOpPointerOperands(Sema &S, SourceLocation Loc,
9401
9401
9402
9402
// if both are pointers check if operation is valid wrt address spaces
9403
9403
if (S.getLangOpts().OpenCL && isLHSPointer && isRHSPointer) {
9404
- const PointerType *lhsPtr = LHSExpr->getType()->getAs <PointerType>();
9405
- const PointerType *rhsPtr = RHSExpr->getType()->getAs <PointerType>();
9404
+ const PointerType *lhsPtr = LHSExpr->getType()->castAs <PointerType>();
9405
+ const PointerType *rhsPtr = RHSExpr->getType()->castAs <PointerType>();
9406
9406
if (!lhsPtr->isAddressSpaceOverlapping(*rhsPtr)) {
9407
9407
S.Diag(Loc,
9408
9408
diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
@@ -10495,7 +10495,7 @@ static QualType checkArithmeticOrEnumeralThreeWayCompare(Sema &S,
10495
10495
return QualType();
10496
10496
}
10497
10497
QualType IntType =
10498
- LHSStrippedType->getAs <EnumType>()->getDecl()->getIntegerType();
10498
+ LHSStrippedType->castAs <EnumType>()->getDecl()->getIntegerType();
10499
10499
assert(IntType->isArithmeticType());
10500
10500
10501
10501
// We can't use `CK_IntegralCast` when the underlying type is 'bool', so we
@@ -10778,8 +10778,8 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
10778
10778
if (LCanPointeeTy != RCanPointeeTy) {
10779
10779
// Treat NULL constant as a special case in OpenCL.
10780
10780
if (getLangOpts().OpenCL && !LHSIsNull && !RHSIsNull) {
10781
- const PointerType *LHSPtr = LHSType->getAs <PointerType>();
10782
- if (!LHSPtr->isAddressSpaceOverlapping(*RHSType->getAs <PointerType>())) {
10781
+ const PointerType *LHSPtr = LHSType->castAs <PointerType>();
10782
+ if (!LHSPtr->isAddressSpaceOverlapping(*RHSType->castAs <PointerType>())) {
10783
10783
Diag(Loc,
10784
10784
diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
10785
10785
<< LHSType << RHSType << 0 /* comparison */
@@ -11044,7 +11044,7 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
11044
11044
// the largest type to the smallest type to avoid cases where long long == long,
11045
11045
// where long gets picked over long long.
11046
11046
QualType Sema::GetSignedVectorType(QualType V) {
11047
- const VectorType *VTy = V->getAs <VectorType>();
11047
+ const VectorType *VTy = V->castAs <VectorType>();
11048
11048
unsigned TypeSize = Context.getTypeSize(VTy->getElementType());
11049
11049
11050
11050
if (isa<ExtVectorType>(VTy)) {
@@ -11099,7 +11099,7 @@ QualType Sema::CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS,
11099
11099
// If AltiVec, the comparison results in a numeric type, i.e.
11100
11100
// bool for C++, int for C
11101
11101
if (getLangOpts().AltiVec &&
11102
- vType->getAs <VectorType>()->getVectorKind() == VectorType::AltiVecVector)
11102
+ vType->castAs <VectorType>()->getVectorKind() == VectorType::AltiVecVector)
11103
11103
return Context.getLogicalOperationType();
11104
11104
11105
11105
// For non-floating point types, check for self-comparisons of the form
@@ -12108,11 +12108,11 @@ static QualType CheckIncrementDecrementOperand(Sema &S, Expr *Op,
12108
12108
} else if (S.getLangOpts().AltiVec && ResType->isVectorType()) {
12109
12109
// OK! ( C/C++ Language Extensions for CBEA(Version 2.6) 10.3 )
12110
12110
} else if (S.getLangOpts().ZVector && ResType->isVectorType() &&
12111
- (ResType->getAs <VectorType>()->getVectorKind() !=
12111
+ (ResType->castAs <VectorType>()->getVectorKind() !=
12112
12112
VectorType::AltiVecBool)) {
12113
12113
// The z vector extensions allow ++ and -- for non-bool vectors.
12114
12114
} else if(S.getLangOpts().OpenCL && ResType->isVectorType() &&
12115
- ResType->getAs <VectorType>()->getElementType()->isIntegerType()) {
12115
+ ResType->castAs <VectorType>()->getElementType()->isIntegerType()) {
12116
12116
// OpenCL V1.2 6.3 says dec/inc ops operate on integer vector types.
12117
12117
} else {
12118
12118
S.Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
@@ -12698,7 +12698,7 @@ static ExprResult convertHalfVecBinOp(Sema &S, ExprResult LHS, ExprResult RHS,
12698
12698
LHS = convertVector(LHS.get(), Context.FloatTy, S);
12699
12699
auto *BO = new (Context) BinaryOperator(LHS.get(), RHS.get(), Opc, BinOpResTy,
12700
12700
VK, OK, OpLoc, FPFeatures);
12701
- return convertVector(BO, ResultTy->getAs <VectorType>()->getElementType(), S);
12701
+ return convertVector(BO, ResultTy->castAs <VectorType>()->getElementType(), S);
12702
12702
}
12703
12703
12704
12704
static std::pair<ExprResult, ExprResult>
@@ -13454,7 +13454,7 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc,
13454
13454
else if (resultType->isVectorType() &&
13455
13455
// The z vector extensions don't allow + or - with bool vectors.
13456
13456
(!Context.getLangOpts().ZVector ||
13457
- resultType->getAs <VectorType>()->getVectorKind() !=
13457
+ resultType->castAs <VectorType>()->getVectorKind() !=
13458
13458
VectorType::AltiVecBool))
13459
13459
break;
13460
13460
else if (getLangOpts().CPlusPlus && // C++ [expr.unary.op]p6
@@ -13483,7 +13483,7 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc,
13483
13483
else if (resultType->isExtVectorType() && Context.getLangOpts().OpenCL) {
13484
13484
// OpenCL v1.1 s6.3.f: The bitwise operator not (~) does not operate
13485
13485
// on vector float types.
13486
- QualType T = resultType->getAs <ExtVectorType>()->getElementType();
13486
+ QualType T = resultType->castAs <ExtVectorType>()->getElementType();
13487
13487
if (!T->isIntegerType())
13488
13488
return ExprError(Diag(OpLoc, diag::err_typecheck_unary_expr)
13489
13489
<< resultType << Input.get()->getSourceRange());
@@ -13528,7 +13528,7 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc,
13528
13528
!Context.getLangOpts().OpenCLCPlusPlus) {
13529
13529
// OpenCL v1.1 6.3.h: The logical operator not (!) does not
13530
13530
// operate on vector float types.
13531
- QualType T = resultType->getAs <ExtVectorType>()->getElementType();
13531
+ QualType T = resultType->castAs <ExtVectorType>()->getElementType();
13532
13532
if (!T->isIntegerType())
13533
13533
return ExprError(Diag(OpLoc, diag::err_typecheck_unary_expr)
13534
13534
<< resultType << Input.get()->getSourceRange());
@@ -14193,7 +14193,7 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
14193
14193
14194
14194
// If the user wrote a function type in some form, try to use that.
14195
14195
if (!BSI->FunctionType.isNull()) {
14196
- const FunctionType *FTy = BSI->FunctionType->getAs <FunctionType>();
14196
+ const FunctionType *FTy = BSI->FunctionType->castAs <FunctionType>();
14197
14197
14198
14198
FunctionType::ExtInfo Ext = FTy->getExtInfo();
14199
14199
if (NoReturn && !Ext.getNoReturn()) Ext = Ext.withNoReturn(true);
@@ -14665,24 +14665,24 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
14665
14665
case IncompatibleObjCQualifiedId: {
14666
14666
if (SrcType->isObjCQualifiedIdType()) {
14667
14667
const ObjCObjectPointerType *srcOPT =
14668
- SrcType->getAs <ObjCObjectPointerType>();
14668
+ SrcType->castAs <ObjCObjectPointerType>();
14669
14669
for (auto *srcProto : srcOPT->quals()) {
14670
14670
PDecl = srcProto;
14671
14671
break;
14672
14672
}
14673
14673
if (const ObjCInterfaceType *IFaceT =
14674
- DstType->getAs <ObjCObjectPointerType>()->getInterfaceType())
14674
+ DstType->castAs <ObjCObjectPointerType>()->getInterfaceType())
14675
14675
IFace = IFaceT->getDecl();
14676
14676
}
14677
14677
else if (DstType->isObjCQualifiedIdType()) {
14678
14678
const ObjCObjectPointerType *dstOPT =
14679
- DstType->getAs <ObjCObjectPointerType>();
14679
+ DstType->castAs <ObjCObjectPointerType>();
14680
14680
for (auto *dstProto : dstOPT->quals()) {
14681
14681
PDecl = dstProto;
14682
14682
break;
14683
14683
}
14684
14684
if (const ObjCInterfaceType *IFaceT =
14685
- SrcType->getAs <ObjCObjectPointerType>()->getInterfaceType())
14685
+ SrcType->castAs <ObjCObjectPointerType>()->getInterfaceType())
14686
14686
IFace = IFaceT->getDecl();
14687
14687
}
14688
14688
DiagKind = diag::warn_incompatible_qualified_id;
0 commit comments