Skip to content

Commit af736d1

Browse files
committed
Remove deprecated methods (isa, cast, and dyn_cast)
1 parent c304f6c commit af736d1

File tree

6 files changed

+30
-20
lines changed

6 files changed

+30
-20
lines changed

clang/lib/CIR/Dialect/Transforms/TargetLowering/ABIInfoImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ bool classifyReturnType(const CIRCXXABI &CXXABI, LowerFunctionInfo &FI,
3131
}
3232

3333
Type useFirstFieldIfTransparentUnion(Type Ty) {
34-
if (auto RT = Ty.dyn_cast<StructType>()) {
34+
if (auto RT = dyn_cast<StructType>(Ty)) {
3535
if (RT.isUnion())
3636
llvm_unreachable("NYI");
3737
}

clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRLowerContext.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ clang::TypeInfo CIRLowerContext::getTypeInfoImpl(const Type T) const {
5050
// TODO(cir): We should implement a better way to identify type kinds and use
5151
// builting data layout interface for this.
5252
auto typeKind = clang::Type::Builtin;
53-
if (T.isa<IntType>()) {
53+
if (isa<IntType>(T)) {
5454
typeKind = clang::Type::Builtin;
5555
} else {
5656
llvm_unreachable("Unhandled type class");
@@ -66,7 +66,7 @@ clang::TypeInfo CIRLowerContext::getTypeInfoImpl(const Type T) const {
6666
// current level of CIR.
6767
switch (typeKind) {
6868
case clang::Type::Builtin: {
69-
if (auto intTy = T.dyn_cast<IntType>()) {
69+
if (auto intTy = dyn_cast<IntType>(T)) {
7070
// NOTE(cir): This assumes int types are already ABI-specific.
7171
// FIXME(cir): Use data layout interface here instead.
7272
Width = intTy.getWidth();
@@ -139,8 +139,8 @@ bool CIRLowerContext::isPromotableIntegerType(Type T) const {
139139
// FIXME(cir): CIR does not distinguish between char, short, etc. So we just
140140
// assume it is promotable if smaller than 32 bits. This is wrong since, for
141141
// example, Char32 is promotable. Improve CIR or add an AST query here.
142-
if (auto intTy = T.dyn_cast<IntType>()) {
143-
return T.cast<IntType>().getWidth() < 32;
142+
if (auto intTy = dyn_cast<IntType>(T)) {
143+
return cast<IntType>(T).getWidth() < 32;
144144
}
145145

146146
// Enumerated types are promotable to their compatible integer types

clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerFunction.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ LowerFunction::buildFunctionProlog(const LowerFunctionInfo &FI, FuncOp Fn,
113113
// Prepare parameter attributes. So far, only attributes for pointer
114114
// parameters are prepared. See
115115
// http://llvm.org/docs/LangRef.html#paramattrs.
116-
if (ArgI.getDirectOffset() == 0 && LTy.isa<PointerType>() &&
117-
ArgI.getCoerceToType().isa<PointerType>()) {
116+
if (ArgI.getDirectOffset() == 0 && isa<PointerType>(LTy) &&
117+
isa<PointerType>(ArgI.getCoerceToType())) {
118118
llvm_unreachable("NYI");
119119
}
120120

@@ -413,7 +413,7 @@ Value LowerFunction::rewriteCallOp(const LowerFunctionInfo &CallInfo,
413413
// NOTE(cir): While booleans are lowered directly as `i1`s in the
414414
// original codegen, in CIR they require a trivial bitcast. This is
415415
// handled here.
416-
if (info_it->type.isa<BoolType>()) {
416+
if (isa<BoolType>(info_it->type)) {
417417
IRCallArgs[FirstIRArg] =
418418
createBitcast(*I, ArgInfo.getCoerceToType(), *this);
419419
break;
@@ -424,7 +424,7 @@ Value LowerFunction::rewriteCallOp(const LowerFunctionInfo &CallInfo,
424424
ArgInfo.getDirectOffset() == 0) {
425425
assert(NumIRArgs == 1);
426426
Value V;
427-
if (!I->getType().isa<StructType>()) {
427+
if (isa<StructType>(!I->getType())) {
428428
V = *I;
429429
} else {
430430
llvm_unreachable("NYI");
@@ -435,7 +435,7 @@ Value LowerFunction::rewriteCallOp(const LowerFunctionInfo &CallInfo,
435435
}
436436

437437
if (ArgInfo.getCoerceToType() != V.getType() &&
438-
V.getType().isa<IntType>())
438+
isa<IntType>(V.getType()))
439439
llvm_unreachable("NYI");
440440

441441
if (FirstIRArg < IRFuncTy.getNumInputs() &&
@@ -517,7 +517,7 @@ Value LowerFunction::rewriteCallOp(const LowerFunctionInfo &CallInfo,
517517
// NOTE(cir): While booleans are lowered directly as `i1`s in the
518518
// original codegen, in CIR they require a trivial bitcast. This is
519519
// handled here.
520-
assert(!RetTy.isa<BoolType>());
520+
assert(!isa<BoolType>(RetTy));
521521

522522
Type RetIRTy = RetTy;
523523
if (RetAI.getCoerceToType() == RetIRTy && RetAI.getDirectOffset() == 0) {
@@ -562,9 +562,9 @@ Value LowerFunction::getUndefRValue(Type Ty) {
562562

563563
::cir::TypeEvaluationKind LowerFunction::getEvaluationKind(Type type) {
564564
// FIXME(cir): Implement type classes for CIR types.
565-
if (type.isa<StructType>())
565+
if (isa<StructType>(type))
566566
return ::cir::TypeEvaluationKind::TEK_Aggregate;
567-
if (type.isa<IntType, SingleType, DoubleType>())
567+
if (isa<IntType, SingleType, DoubleType>(type))
568568
return ::cir::TypeEvaluationKind::TEK_Scalar;
569569
llvm_unreachable("NYI");
570570
}

clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerTypes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ mlir::Type LowerTypes::convertType(Type T) {
112112
/// keeping it here for parity's sake.
113113

114114
// Certain CIR types are already ABI-specific, so we just return them.
115-
if (T.isa<IntType>()) {
115+
if (isa<IntType>(T)) {
116116
return T;
117117
}
118118

clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/LoweringPrepareAArch64CXXABI.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,15 @@ mlir::Value LoweringPrepareAArch64CXXABI::lowerAAPCSVAArg(
6363
auto opResTy = op.getType();
6464
// front end should not produce non-scalar type of VAArgOp
6565
bool isSupportedType =
66+
<<<<<<< HEAD
6667
mlir::isa<mlir::cir::IntType, mlir::cir::SingleType,
6768
mlir::cir::PointerType, mlir::cir::BoolType,
6869
mlir::cir::DoubleType, mlir::cir::ArrayType>(opResTy);
70+
=======
71+
isa<mlir::cir::IntType, mlir::cir::SingleType, mlir::cir::PointerType,
72+
mlir::cir::BoolType, mlir::cir::DoubleType, mlir::cir::ArrayType>(
73+
opResTy);
74+
>>>>>>> 92b5444bae17 (Remove deprecated methods (isa, cast, and dyn_cast))
6975

7076
// Homogenous Aggregate type not supported and indirect arg
7177
// passing not supported yet. And for these supported types,
@@ -82,7 +88,11 @@ mlir::Value LoweringPrepareAArch64CXXABI::lowerAAPCSVAArg(
8288
// but it depends on arg type indirectness and coercion defined by ABI.
8389
auto baseTy = opResTy;
8490

91+
<<<<<<< HEAD
8592
if (mlir::isa<mlir::cir::ArrayType>(baseTy)) {
93+
=======
94+
if (isa<mlir::cir::ArrayType>(baseTy)) {
95+
>>>>>>> 92b5444bae17 (Remove deprecated methods (isa, cast, and dyn_cast))
8696
llvm_unreachable("ArrayType VAArg loweing NYI");
8797
}
8898
// numRegs may not be 1 if ArrayType is supported.

clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/X86.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ void X86_64ABIInfo::classify(Type Ty, uint64_t OffsetBase, Class &Lo, Class &Hi,
114114
if (/*isBuitinType=*/true) {
115115
if (isa<VoidType>(Ty)) {
116116
Current = Class::NoClass;
117-
} else if (Ty.isa<IntType>()) {
117+
} else if (isa<IntType>(Ty)) {
118118

119119
// FIXME(cir): Clang's BuiltinType::Kind allow comparisons (GT, LT, etc).
120120
// We should implement this in CIR to simplify the conditions below. BTW,
121121
// I'm not sure if the comparisons below are truly equivalent to the ones
122122
// in Clang.
123-
if (Ty.isa<IntType>()) {
123+
if (isa<IntType>(Ty)) {
124124
Current = Class::Integer;
125125
}
126126
return;
@@ -226,12 +226,12 @@ ::cir::ABIArgInfo X86_64ABIInfo::classifyReturnType(Type RetTy) const {
226226

227227
// If we have a sign or zero extended integer, make sure to return Extend
228228
// so that the parameter gets the right LLVM IR attributes.
229-
if (Hi == Class::NoClass && resType.isa<IntType>()) {
229+
if (Hi == Class::NoClass && isa<IntType>(resType)) {
230230
// NOTE(cir): We skip enum types handling here since CIR represents
231231
// enums directly as their unerlying integer types. NOTE(cir): For some
232232
// reason, Clang does not set the coerce type here and delays it to
233233
// arrangeLLVMFunctionInfo. We do the same to keep parity.
234-
if (RetTy.isa<IntType>() && isPromotableIntegerTypeForABI(RetTy))
234+
if (isa<IntType>(RetTy) && isPromotableIntegerTypeForABI(RetTy))
235235
return ABIArgInfo::getExtend(RetTy);
236236
}
237237
break;
@@ -291,12 +291,12 @@ ABIArgInfo X86_64ABIInfo::classifyArgumentType(Type Ty, unsigned freeIntRegs,
291291

292292
// If we have a sign or zero extended integer, make sure to return Extend
293293
// so that the parameter gets the right LLVM IR attributes.
294-
if (Hi == Class::NoClass && ResType.isa<IntType>()) {
294+
if (Hi == Class::NoClass && isa<IntType>(ResType)) {
295295
// NOTE(cir): We skip enum types handling here since CIR represents
296296
// enums directly as their unerlying integer types. NOTE(cir): For some
297297
// reason, Clang does not set the coerce type here and delays it to
298298
// arrangeLLVMFunctionInfo. We do the same to keep parity.
299-
if (Ty.isa<IntType, BoolType>() && isPromotableIntegerTypeForABI(Ty))
299+
if (isa<IntType, BoolType>(Ty) && isPromotableIntegerTypeForABI(Ty))
300300
return ABIArgInfo::getExtend(Ty);
301301
}
302302

0 commit comments

Comments
 (0)