[flang-commits] [flang] [llvm] [mlir] [mlir] Mark `isa/dyn_cast/cast/...` member functions deprecated. (PR #89998)
via flang-commits
flang-commits at lists.llvm.org
Thu Apr 25 07:01:46 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff ed962a66c5a2257100ca20624521ef51c0abcfb3 e54f57ed46af6a88d1d86526df982f8038de01f5 -- flang/include/flang/Lower/Mangler.h flang/include/flang/Lower/PFTBuilder.h flang/include/flang/Optimizer/Analysis/TBAAForest.h flang/include/flang/Optimizer/Builder/BoxValue.h flang/include/flang/Optimizer/Builder/Factory.h flang/include/flang/Optimizer/Builder/HLFIRTools.h flang/include/flang/Optimizer/Builder/IntrinsicCall.h flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h flang/include/flang/Optimizer/Dialect/FIRType.h flang/include/flang/Optimizer/HLFIR/HLFIRDialect.h flang/include/flang/Optimizer/Support/Utils.h flang/include/flang/Tools/PointerModels.h flang/lib/Lower/Allocatable.cpp flang/lib/Lower/Bridge.cpp flang/lib/Lower/CallInterface.cpp flang/lib/Lower/ConvertArrayConstructor.cpp flang/lib/Lower/ConvertCall.cpp flang/lib/Lower/ConvertConstant.cpp flang/lib/Lower/ConvertExpr.cpp flang/lib/Lower/ConvertExprToHLFIR.cpp flang/lib/Lower/ConvertProcedureDesignator.cpp flang/lib/Lower/ConvertVariable.cpp flang/lib/Lower/CustomIntrinsicCall.cpp flang/lib/Lower/DirectivesCommon.h flang/lib/Lower/HlfirIntrinsics.cpp flang/lib/Lower/HostAssociations.cpp flang/lib/Lower/IO.cpp flang/lib/Lower/OpenACC.cpp flang/lib/Lower/OpenMP/ClauseProcessor.cpp flang/lib/Lower/OpenMP/OpenMP.cpp flang/lib/Lower/OpenMP/ReductionProcessor.cpp flang/lib/Lower/PFTBuilder.cpp flang/lib/Lower/VectorSubscripts.cpp flang/lib/Optimizer/Analysis/AliasAnalysis.cpp flang/lib/Optimizer/Builder/BoxValue.cpp flang/lib/Optimizer/Builder/Character.cpp flang/lib/Optimizer/Builder/Complex.cpp flang/lib/Optimizer/Builder/FIRBuilder.cpp flang/lib/Optimizer/Builder/HLFIRTools.cpp flang/lib/Optimizer/Builder/IntrinsicCall.cpp flang/lib/Optimizer/Builder/MutableBox.cpp flang/lib/Optimizer/Builder/PPCIntrinsicCall.cpp flang/lib/Optimizer/Builder/Runtime/Allocatable.cpp flang/lib/Optimizer/Builder/Runtime/Character.cpp flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp flang/lib/Optimizer/Builder/Runtime/Ragged.cpp flang/lib/Optimizer/Builder/Runtime/Reduction.cpp flang/lib/Optimizer/CodeGen/BoxedProcedure.cpp flang/lib/Optimizer/CodeGen/CGOps.cpp flang/lib/Optimizer/CodeGen/CodeGen.cpp flang/lib/Optimizer/CodeGen/FIROpPatterns.cpp flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp flang/lib/Optimizer/CodeGen/TBAABuilder.cpp flang/lib/Optimizer/CodeGen/Target.cpp flang/lib/Optimizer/CodeGen/TargetRewrite.cpp flang/lib/Optimizer/CodeGen/TypeConverter.cpp flang/lib/Optimizer/Dialect/FIRAttr.cpp flang/lib/Optimizer/Dialect/FIROps.cpp flang/lib/Optimizer/Dialect/FIRType.cpp flang/lib/Optimizer/Dialect/FortranVariableInterface.cpp flang/lib/Optimizer/HLFIR/IR/HLFIRDialect.cpp flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp flang/lib/Optimizer/HLFIR/Transforms/BufferizeHLFIR.cpp flang/lib/Optimizer/HLFIR/Transforms/ConvertToFIR.cpp flang/lib/Optimizer/HLFIR/Transforms/LowerHLFIRIntrinsics.cpp flang/lib/Optimizer/HLFIR/Transforms/LowerHLFIROrderedAssignments.cpp flang/lib/Optimizer/HLFIR/Transforms/OptimizedBufferization.cpp flang/lib/Optimizer/HLFIR/Transforms/SimplifyHLFIRIntrinsics.cpp flang/lib/Optimizer/Transforms/AbstractResult.cpp flang/lib/Optimizer/Transforms/AddDebugInfo.cpp flang/lib/Optimizer/Transforms/AffineDemotion.cpp flang/lib/Optimizer/Transforms/AffinePromotion.cpp flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp flang/lib/Optimizer/Transforms/CharacterConversion.cpp flang/lib/Optimizer/Transforms/LoopVersioning.cpp flang/lib/Optimizer/Transforms/MemoryAllocation.cpp flang/lib/Optimizer/Transforms/PolymorphicOpConversion.cpp flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp flang/lib/Optimizer/Transforms/StackArrays.cpp flang/unittests/Optimizer/Builder/ComplexTest.cpp flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp flang/unittests/Optimizer/RTBuilder.cpp llvm/include/llvm/ADT/TypeSwitch.h mlir/include/mlir/IR/Attributes.h mlir/include/mlir/IR/Location.h mlir/include/mlir/IR/Types.h mlir/include/mlir/IR/Value.h mlir/lib/Conversion/ComplexToStandard/ComplexToStandard.cpp mlir/lib/Dialect/Polynomial/IR/PolynomialAttributes.cpp mlir/lib/Dialect/Vector/Transforms/VectorLinearize.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/flang/include/flang/Optimizer/Support/Utils.h b/flang/include/flang/Optimizer/Support/Utils.h
index 709549891d..2da6f24da4 100644
--- a/flang/include/flang/Optimizer/Support/Utils.h
+++ b/flang/include/flang/Optimizer/Support/Utils.h
@@ -29,7 +29,9 @@
namespace fir {
/// Return the integer value of a arith::ConstantOp.
inline std::int64_t toInt(mlir::arith::ConstantOp cop) {
- return mlir::cast<mlir::IntegerAttr>(cop.getValue()).getValue().getSExtValue();
+ return mlir::cast<mlir::IntegerAttr>(cop.getValue())
+ .getValue()
+ .getSExtValue();
}
// Reconstruct binding tables for dynamic dispatch.
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 8f5f4c7084..876053b27c 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -892,7 +892,8 @@ public:
/// or a full subprogram context.
Fortran::lower::StatementContext &getFctCtx() override final {
if (!activeConstructStack.empty() &&
- activeConstructStack.back().mlir::isA<Fortran::parser::BlockConstruct>(eval))
+ activeConstructStack.back().mlir::isA<Fortran::parser::BlockConstruct>(
+ eval))
return activeConstructStack.back().stmtCtx;
return bridge.fctCtx();
}
@@ -3118,8 +3119,8 @@ private:
mlir::Value exactValue;
mlir::Type addrTy = attr.getType();
if (isArray) {
- auto seqTy = mlir::dyn_cast<fir::SequenceType>(fir::dyn_cast_ptrOrBoxEleTy(baseTy)
- );
+ auto seqTy = mlir::dyn_cast<fir::SequenceType>(
+ fir::dyn_cast_ptrOrBoxEleTy(baseTy));
addrTy = fir::SequenceType::get(seqTy.getShape(), attr.getType());
}
if (isPointer)
@@ -3158,11 +3159,12 @@ private:
} else if (std::holds_alternative<Fortran::parser::DerivedTypeSpec>(
guard.u)) {
// CLASS IS
- fir::SubclassAttr attr = mlir::dyn_cast<fir::SubclassAttr>(typeGuardAttr);
+ fir::SubclassAttr attr =
+ mlir::dyn_cast<fir::SubclassAttr>(typeGuardAttr);
mlir::Type addrTy = attr.getType();
if (isArray) {
- auto seqTy = mlir::dyn_cast<fir::SequenceType>(fir::dyn_cast_ptrOrBoxEleTy(baseTy)
- );
+ auto seqTy = mlir::dyn_cast<fir::SequenceType>(
+ fir::dyn_cast_ptrOrBoxEleTy(baseTy));
addrTy = fir::SequenceType::get(seqTy.getShape(), attr.getType());
}
if (isPointer)
diff --git a/flang/lib/Lower/ConvertArrayConstructor.cpp b/flang/lib/Lower/ConvertArrayConstructor.cpp
index 8fa0efed53..a5b5838fe6 100644
--- a/flang/lib/Lower/ConvertArrayConstructor.cpp
+++ b/flang/lib/Lower/ConvertArrayConstructor.cpp
@@ -702,7 +702,8 @@ static ArrayCtorLoweringStrategy selectArrayCtorLoweringStrategy(
// Based on what was gathered and the result of the analysis, select and
// instantiate the right lowering strategy for the array constructor.
if (!extent || needToEvaluateOneExprToGetLengthParameters ||
- analysis.anyArrayExpr || mlir::isa<fir::RecordType>(declaredType.getEleTy()))
+ analysis.anyArrayExpr ||
+ mlir::isa<fir::RecordType>(declaredType.getEleTy()))
return RuntimeTempStrategy(
loc, builder, stmtCtx, symMap, declaredType,
extent ? std::optional<mlir::Value>(extent) : std::nullopt, lengths,
diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp
index aba8a57d20..6867c9910c 100644
--- a/flang/lib/Lower/ConvertExpr.cpp
+++ b/flang/lib/Lower/ConvertExpr.cpp
@@ -1172,8 +1172,8 @@ public:
if (!charBox)
fir::emitFatalError(loc, "expected scalar character");
mlir::Value charAddr = charBox->getAddr();
- auto charType =
- mlir::cast<fir::CharacterType>(fir::unwrapPassByRefType(charAddr.getType()));
+ auto charType = mlir::cast<fir::CharacterType>(
+ fir::unwrapPassByRefType(charAddr.getType()));
if (charType.hasConstantLen()) {
// Erase previous constant length from the base type.
fir::CharacterType::LenType newLen = fir::CharacterType::unknownLen();
@@ -2331,7 +2331,8 @@ public:
builder.genIfThen(loc, *copyOutPair.restrictCopyAndFreeAtRuntime)
.genThen([&]() {
doCopyOut();
- if (mlir::isa<fir::RecordType>(fir::getElementTypeOf(copyOutPair.temp))) {
+ if (mlir::isa<fir::RecordType>(
+ fir::getElementTypeOf(copyOutPair.temp))) {
// Destroy components of the temporary (if any).
// If there are no components requiring destruction, then the call
// is a no-op.
@@ -2647,7 +2648,8 @@ public:
mlir::dyn_cast<mlir::FunctionType>(x.getAddr().getType());
if (funcTy && funcTy.getNumResults() == 1 &&
mlir::isa<fir::BoxCharType>(funcTy.getResult(0))) {
- auto boxTy = mlir::cast<fir::BoxCharType>(funcTy.getResult(0));
+ auto boxTy =
+ mlir::cast<fir::BoxCharType>(funcTy.getResult(0));
mlir::Value ref = builder.createConvert(
loc, builder.getRefType(boxTy.getEleTy()), x.getAddr());
auto len = builder.create<fir::UndefOp>(
@@ -3489,10 +3491,9 @@ public:
tempRes, dest.getSlice(),
dest.getTypeparams());
- auto arrTy =
- mlir::cast<fir::SequenceType>(fir::dyn_cast_ptrEleTy(tempRes.getType()));
- if (auto charTy =
- mlir::dyn_cast<fir::CharacterType>(arrTy.getEleTy())) {
+ auto arrTy = mlir::cast<fir::SequenceType>(
+ fir::dyn_cast_ptrEleTy(tempRes.getType()));
+ if (auto charTy = mlir::dyn_cast<fir::CharacterType>(arrTy.getEleTy())) {
if (fir::characterWithDynamicLen(charTy))
TODO(loc, "CHARACTER does not have constant LEN");
mlir::Value len = builder.createIntegerConstant(
diff --git a/flang/lib/Lower/CustomIntrinsicCall.cpp b/flang/lib/Lower/CustomIntrinsicCall.cpp
index c8ae1818db..30c6ce7f53 100644
--- a/flang/lib/Lower/CustomIntrinsicCall.cpp
+++ b/flang/lib/Lower/CustomIntrinsicCall.cpp
@@ -227,22 +227,23 @@ lowerIshftc(fir::FirOpBuilder &builder, mlir::Location loc,
args.push_back(getOperand(1, loadOperand));
auto iPC = isPresentCheck(2);
assert(iPC.has_value());
- args.push_back(builder
- .genIfOp(loc, {resultType}, *iPC,
- /*withElseRegion=*/true)
- .genThen([&]() {
- fir::ExtendedValue sizeExv = getOperand(2, loadOperand);
- mlir::Value size = builder.createConvert(
- loc, resultType, fir::getBase(sizeExv));
- builder.create<fir::ResultOp>(loc, size);
- })
- .genElse([&]() {
- mlir::Value bitSize = builder.createIntegerConstant(
- loc, resultType,
- mlir::cast<mlir::IntegerType>(resultType).getWidth());
- builder.create<fir::ResultOp>(loc, bitSize);
- })
- .getResults()[0]);
+ args.push_back(
+ builder
+ .genIfOp(loc, {resultType}, *iPC,
+ /*withElseRegion=*/true)
+ .genThen([&]() {
+ fir::ExtendedValue sizeExv = getOperand(2, loadOperand);
+ mlir::Value size =
+ builder.createConvert(loc, resultType, fir::getBase(sizeExv));
+ builder.create<fir::ResultOp>(loc, size);
+ })
+ .genElse([&]() {
+ mlir::Value bitSize = builder.createIntegerConstant(
+ loc, resultType,
+ mlir::cast<mlir::IntegerType>(resultType).getWidth());
+ builder.create<fir::ResultOp>(loc, bitSize);
+ })
+ .getResults()[0]);
return genIntrinsicCall(builder, loc, name, resultType, args, stmtCtx);
}
diff --git a/flang/lib/Lower/IO.cpp b/flang/lib/Lower/IO.cpp
index 4bfa4bf17a..ed0afad919 100644
--- a/flang/lib/Lower/IO.cpp
+++ b/flang/lib/Lower/IO.cpp
@@ -911,9 +911,10 @@ static void genInputItemList(Fortran::lower::AbstractConverter &converter,
mlir::Type itemTy = converter.genType(*expr);
mlir::func::FuncOp inputFunc =
getInputFunc(loc, builder, itemTy, isFormatted);
- auto itemExv = mlir::isa<fir::BoxType>(inputFunc.getFunctionType().getInput(1))
- ? converter.genExprBox(loc, *expr, stmtCtx)
- : converter.genExprAddr(loc, expr, stmtCtx);
+ auto itemExv =
+ mlir::isa<fir::BoxType>(inputFunc.getFunctionType().getInput(1))
+ ? converter.genExprBox(loc, *expr, stmtCtx)
+ : converter.genExprAddr(loc, expr, stmtCtx);
ok = createIoRuntimeCallForItem(converter, loc, inputFunc, cookie, itemExv);
}
}
diff --git a/flang/lib/Lower/PFTBuilder.cpp b/flang/lib/Lower/PFTBuilder.cpp
index 9b25e7fb1d..ea54a80527 100644
--- a/flang/lib/Lower/PFTBuilder.cpp
+++ b/flang/lib/Lower/PFTBuilder.cpp
@@ -566,7 +566,8 @@ private:
for (auto it = evaluationList.begin(), end = evaluationList.end();
it != end; ++it) {
auto &eval = *it;
- if (mlir::isA<parser::EntryStmt>(eval) || eval.isIntermediateConstructStmt()) {
+ if (mlir::isA<parser::EntryStmt>(eval) ||
+ eval.isIntermediateConstructStmt()) {
ifCandidateStack.clear();
continue;
}
@@ -613,7 +614,8 @@ private:
ifCandidateStack.pop_back();
}
}
- if (mlir::isA<parser::IfConstruct>(eval) && eval.evaluationList->size() == 3) {
+ if (mlir::isA<parser::IfConstruct>(eval) &&
+ eval.evaluationList->size() == 3) {
const auto bodyEval = std::next(eval.evaluationList->begin());
if (const auto *gotoStmt = bodyEval->getIf<parser::GotoStmt>()) {
if (!bodyEval->lexicalSuccessor->label)
diff --git a/flang/lib/Optimizer/Builder/Character.cpp b/flang/lib/Optimizer/Builder/Character.cpp
index ea7ceaf5cf..b7a7453efd 100644
--- a/flang/lib/Optimizer/Builder/Character.cpp
+++ b/flang/lib/Optimizer/Builder/Character.cpp
@@ -92,7 +92,8 @@ getCompileTimeLength(const fir::CharBoxValue &box) {
/// Detect the precondition that the value `str` does not reside in memory. Such
/// values will have a type `!fir.array<...x!fir.char<N>>` or `!fir.char<N>`.
LLVM_ATTRIBUTE_UNUSED static bool needToMaterialize(mlir::Value str) {
- return mlir::isa<fir::SequenceType>(str.getType()) || fir::isa_char(str.getType());
+ return mlir::isa<fir::SequenceType>(str.getType()) ||
+ fir::isa_char(str.getType());
}
/// This is called only if `str` does not reside in memory. Such a bare string
diff --git a/flang/lib/Optimizer/Builder/Complex.cpp b/flang/lib/Optimizer/Builder/Complex.cpp
index 3d1e9d6230..cbcd4f8500 100644
--- a/flang/lib/Optimizer/Builder/Complex.cpp
+++ b/flang/lib/Optimizer/Builder/Complex.cpp
@@ -14,7 +14,8 @@
mlir::Type
fir::factory::Complex::getComplexPartType(mlir::Type complexType) const {
- return builder.getRealType(mlir::cast<fir::ComplexType>(complexType).getFKind());
+ return builder.getRealType(
+ mlir::cast<fir::ComplexType>(complexType).getFKind());
}
mlir::Type fir::factory::Complex::getComplexPartType(mlir::Value cplx) const {
diff --git a/flang/lib/Optimizer/Builder/HLFIRTools.cpp b/flang/lib/Optimizer/Builder/HLFIRTools.cpp
index d905ebb501..fda50723aa 100644
--- a/flang/lib/Optimizer/Builder/HLFIRTools.cpp
+++ b/flang/lib/Optimizer/Builder/HLFIRTools.cpp
@@ -495,9 +495,8 @@ llvm::SmallVector<mlir::Value> getVariableExtents(mlir::Location loc,
variable = hlfir::derefPointersAndAllocatables(loc, builder, variable);
// Use the type shape information, and/or the fir.box/fir.class shape
// information if any extents are not static.
- fir::SequenceType seqTy =
- mlir::cast<fir::SequenceType>(hlfir::getFortranElementOrSequenceType(variable.getType())
- );
+ fir::SequenceType seqTy = mlir::cast<fir::SequenceType>(
+ hlfir::getFortranElementOrSequenceType(variable.getType()));
unsigned rank = seqTy.getShape().size();
for (unsigned dim = 0; dim < rank; ++dim)
extents.push_back(
@@ -562,9 +561,8 @@ mlir::Value hlfir::genExtent(mlir::Location loc, fir::FirOpBuilder &builder,
entity = hlfir::derefPointersAndAllocatables(loc, builder, entity);
// Use the type shape information, and/or the fir.box/fir.class shape
// information if any extents are not static.
- fir::SequenceType seqTy =
- mlir::cast<fir::SequenceType>(hlfir::getFortranElementOrSequenceType(entity.getType())
- );
+ fir::SequenceType seqTy = mlir::cast<fir::SequenceType>(
+ hlfir::getFortranElementOrSequenceType(entity.getType()));
return computeVariableExtent(loc, builder, entity, seqTy, dim);
}
TODO(loc, "get extent from HLFIR expr without producer holding the shape");
diff --git a/flang/lib/Optimizer/Builder/MutableBox.cpp b/flang/lib/Optimizer/Builder/MutableBox.cpp
index d1bb0c2362..76b920dba8 100644
--- a/flang/lib/Optimizer/Builder/MutableBox.cpp
+++ b/flang/lib/Optimizer/Builder/MutableBox.cpp
@@ -58,15 +58,16 @@ createNewFirBox(fir::FirOpBuilder &builder, mlir::Location loc,
// unknown or constant lengths.
auto bt = box.getBaseTy();
auto addrTy = addr.getType();
- auto type = mlir::isa<fir::HeapType>(addrTy) ? fir::HeapType::get(bt)
- : mlir::isa<fir::PointerType>(addrTy) ? fir::PointerType::get(bt)
- : builder.getRefType(bt);
+ auto type = mlir::isa<fir::HeapType>(addrTy) ? fir::HeapType::get(bt)
+ : mlir::isa<fir::PointerType>(addrTy)
+ ? fir::PointerType::get(bt)
+ : builder.getRefType(bt);
cleanedAddr = builder.createConvert(loc, type, addr);
if (charTy.getLen() == fir::CharacterType::unknownLen())
cleanedLengths.append(lengths.begin(), lengths.end());
} else if (fir::isUnlimitedPolymorphicType(box.getBoxTy())) {
- if (auto charTy = mlir::dyn_cast<fir::CharacterType>(fir::dyn_cast_ptrEleTy(addr.getType())
- )) {
+ if (auto charTy = mlir::dyn_cast<fir::CharacterType>(
+ fir::dyn_cast_ptrEleTy(addr.getType()))) {
if (charTy.getLen() == fir::CharacterType::unknownLen())
cleanedLengths.append(lengths.begin(), lengths.end());
}
diff --git a/flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp b/flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp
index d42eb68667..8b78a1688c 100644
--- a/flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp
+++ b/flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp
@@ -228,7 +228,8 @@ void fir::runtime::genSystemClock(fir::FirOpBuilder &builder,
fir::IfOp ifOp{};
const bool isOptionalArg =
fir::valueHasFirAttribute(arg, fir::getOptionalAttrName());
- if (mlir::dyn_cast<fir::PointerType>(type) || mlir::dyn_cast<fir::HeapType>(type)) {
+ if (mlir::dyn_cast<fir::PointerType>(type) ||
+ mlir::dyn_cast<fir::HeapType>(type)) {
// Check for a disassociated pointer or an unallocated allocatable.
assert(!isOptionalArg && "invalid optional argument");
ifOp = builder.create<fir::IfOp>(loc, builder.genIsNotNullAddr(loc, arg),
@@ -242,7 +243,8 @@ void fir::runtime::genSystemClock(fir::FirOpBuilder &builder,
builder.setInsertionPointToStart(&ifOp.getThenRegion().front());
mlir::Type kindTy = func.getFunctionType().getInput(0);
int integerKind = 8;
- if (auto intType = mlir::dyn_cast<mlir::IntegerType>(fir::unwrapRefType(type)))
+ if (auto intType =
+ mlir::dyn_cast<mlir::IntegerType>(fir::unwrapRefType(type)))
integerKind = intType.getWidth() / 8;
mlir::Value kind = builder.createIntegerConstant(loc, kindTy, integerKind);
mlir::Value res =
diff --git a/flang/lib/Optimizer/Builder/Runtime/Ragged.cpp b/flang/lib/Optimizer/Builder/Runtime/Ragged.cpp
index 4efdb1072d..e5d0fb0fb2 100644
--- a/flang/lib/Optimizer/Builder/Runtime/Ragged.cpp
+++ b/flang/lib/Optimizer/Builder/Runtime/Ragged.cpp
@@ -32,7 +32,8 @@ void fir::runtime::genRaggedArrayAllocate(mlir::Location loc,
// Position of the bufferPointer in the header struct.
auto one = builder.createIntegerConstant(loc, i32Ty, 1);
auto eleTy = fir::unwrapSequenceType(fir::unwrapRefType(header.getType()));
- auto ptrTy = builder.getRefType(mlir::cast<mlir::TupleType>(eleTy).getType(1));
+ auto ptrTy =
+ builder.getRefType(mlir::cast<mlir::TupleType>(eleTy).getType(1));
auto ptr = builder.create<fir::CoordinateOp>(loc, ptrTy, header, one);
auto heap = builder.create<fir::LoadOp>(loc, ptr);
auto cmp = builder.genIsNullAddr(loc, heap);
diff --git a/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp b/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp
index e8ef854f15..d4076067bf 100644
--- a/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp
+++ b/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp
@@ -1173,7 +1173,7 @@ mlir::Value fir::runtime::genSum(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::func::FuncOp func; \
auto ty = arrayBox.getType(); \
auto arrTy = fir::dyn_cast_ptrOrBoxEleTy(ty); \
- auto eleTy = mlir::cast<fir::SequenceType>(arrTy).getEleTy(); \
+ auto eleTy = mlir::cast<fir::SequenceType>(arrTy).getEleTy(); \
auto dim = builder.createIntegerConstant(loc, builder.getIndexType(), 0); \
\
if (eleTy.isInteger(builder.getKindMap().getIntegerBitsize(1))) \
diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
index 0c76119b35..620b0d7fc9 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -265,7 +265,8 @@ struct BoxAddrOpConversion : public fir::FIROpConversion<fir::BoxAddrOp> {
mlir::ConversionPatternRewriter &rewriter) const override {
mlir::Value a = adaptor.getOperands()[0];
auto loc = boxaddr.getLoc();
- if (auto argty = mlir::dyn_cast<fir::BaseBoxType>(boxaddr.getVal().getType())) {
+ if (auto argty =
+ mlir::dyn_cast<fir::BaseBoxType>(boxaddr.getVal().getType())) {
TypePair boxTyPair = getBoxTypePair(argty);
rewriter.replaceOp(boxaddr,
getBaseAddrFromBox(loc, boxTyPair, a, rewriter));
@@ -493,7 +494,8 @@ struct StringLitOpConversion : public fir::FIROpConversion<fir::StringLitOp> {
// convert each character to a precise bitsize
auto elemAttr = mlir::IntegerAttr::get(
intTy,
- mlir::cast<mlir::IntegerAttr>(a.value()).getValue().zextOrTrunc(bits));
+ mlir::cast<mlir::IntegerAttr>(a.value()).getValue().zextOrTrunc(
+ bits));
auto elemCst =
rewriter.create<mlir::LLVM::ConstantOp>(loc, intTy, elemAttr);
cst = rewriter.create<mlir::LLVM::InsertValueOp>(loc, cst, elemCst,
@@ -628,7 +630,8 @@ struct ConvertOpConversion : public fir::FIROpConversion<fir::ConvertOp> {
auto loc = convert.getLoc();
auto i1Type = mlir::IntegerType::get(convert.getContext(), 1);
- if (mlir::isa<fir::LogicalType>(fromFirTy) || mlir::isa<fir::LogicalType>(toFirTy)) {
+ if (mlir::isa<fir::LogicalType>(fromFirTy) ||
+ mlir::isa<fir::LogicalType>(toFirTy)) {
// By specification fir::LogicalType value may be any number,
// where non-zero value represents .true. and zero value represents
// .false.
@@ -641,7 +644,8 @@ struct ConvertOpConversion : public fir::FIROpConversion<fir::ConvertOp> {
// Conversion from narrow logical to wide logical may be implemented
// as a zero or sign extension of the input, but it may use value
// normalization as well.
- if (!mlir::isa<mlir::IntegerType>(fromTy) || !mlir::isa<mlir::IntegerType>(toTy))
+ if (!mlir::isa<mlir::IntegerType>(fromTy) ||
+ !mlir::isa<mlir::IntegerType>(toTy))
return mlir::emitError(loc)
<< "unsupported types for logical conversion: " << fromTy
<< " -> " << toTy;
@@ -979,9 +983,10 @@ static mlir::SymbolRefAttr getFree(fir::FreeMemOp op,
static unsigned getDimension(mlir::LLVM::LLVMArrayType ty) {
unsigned result = 1;
- for (auto eleTy = mlir::dyn_cast<mlir::LLVM::LLVMArrayType>(ty.getElementType());
- eleTy;
- eleTy = mlir::dyn_cast<mlir::LLVM::LLVMArrayType>(eleTy.getElementType()))
+ for (auto eleTy =
+ mlir::dyn_cast<mlir::LLVM::LLVMArrayType>(ty.getElementType());
+ eleTy; eleTy = mlir::dyn_cast<mlir::LLVM::LLVMArrayType>(
+ eleTy.getElementType()))
++result;
return result;
}
@@ -1084,14 +1089,16 @@ struct EmboxCommonConversion : public fir::FIROpConversion<OP> {
boxEleTy = eleTy;
if (auto seqTy = mlir::dyn_cast<fir::SequenceType>(boxEleTy))
return getSizeAndTypeCode(loc, rewriter, seqTy.getEleTy(), lenParams);
- if (mlir::isa<mlir::NoneType>(boxEleTy)) // unlimited polymorphic or assumed type
+ if (mlir::isa<mlir::NoneType>(
+ boxEleTy)) // unlimited polymorphic or assumed type
return {rewriter.create<mlir::LLVM::ConstantOp>(loc, i64Ty, 0),
this->genConstantOffset(loc, rewriter, CFI_type_other)};
mlir::Value typeCodeVal = this->genConstantOffset(
loc, rewriter,
fir::getTypeCode(boxEleTy, this->lowerTy().getKindMap()));
- if (fir::isa_integer(boxEleTy) || mlir::dyn_cast<fir::LogicalType>(boxEleTy) ||
- fir::isa_real(boxEleTy) || fir::isa_complex(boxEleTy))
+ if (fir::isa_integer(boxEleTy) ||
+ mlir::dyn_cast<fir::LogicalType>(boxEleTy) || fir::isa_real(boxEleTy) ||
+ fir::isa_complex(boxEleTy))
return {genTypeStrideInBytes(loc, i64Ty, rewriter,
this->convertType(boxEleTy)),
typeCodeVal};
@@ -1589,7 +1596,8 @@ struct XEmboxOpConversion : public EmboxCommonConversion<fir::cg::XEmboxOp> {
// Lower bound is normalized to 0 for BIND(C) interoperability.
mlir::Value lb = zero;
const bool isaPointerOrAllocatable =
- mlir::isa<fir::PointerType>() || mlir::isa<fir::HeapType>(eleTyeleTy);
+ mlir::isa<fir::PointerType>() ||
+ mlir::isa<fir::HeapType>(eleTyeleTy);
// Lower bound is defaults to 1 for POINTER, ALLOCATABLE, and
// denormalized descriptors.
if (isaPointerOrAllocatable || !normalizedLowerBound(xbox))
@@ -2107,7 +2115,8 @@ struct XArrayCoorOpConversion
mlir::Value offset = genConstantIndex(loc, idxTy, rewriter, 0);
const bool isShifted = !coor.getShift().empty();
const bool isSliced = !coor.getSlice().empty();
- const bool baseIsBoxed = mlir::isa<fir::BaseBoxType>(coor.getMemref().getType());
+ const bool baseIsBoxed =
+ mlir::isa<fir::BaseBoxType>(coor.getMemref().getType());
TypePair baseBoxTyPair =
baseIsBoxed ? getBoxTypePair(coor.getMemref().getType()) : TypePair{};
mlir::LLVM::IntegerOverflowFlags nsw =
@@ -2185,7 +2194,8 @@ struct XArrayCoorOpConversion
// components.
mlir::Type elementType =
getLlvmObjectTypeFromBoxType(coor.getMemref().getType());
- while (auto arrayTy = mlir::dyn_cast<mlir::LLVM::LLVMArrayType>(elementType))
+ while (auto arrayTy =
+ mlir::dyn_cast<mlir::LLVM::LLVMArrayType>(elementType))
elementType = arrayTy.getElementType();
args.clear();
args.push_back(0);
@@ -2279,7 +2289,8 @@ struct CoordinateOpConversion
return doRewriteBox(coor, operands, loc, rewriter);
// Reference, pointer or a heap type
- if (mlir::isa<fir::ReferenceType, fir::PointerType, fir::HeapType>(baseObjectTy))
+ if (mlir::isa<fir::ReferenceType, fir::PointerType, fir::HeapType>(
+ baseObjectTy))
return doRewriteRefOrPtr(coor, llvmObjectTy, operands, loc, rewriter);
return rewriter.notifyMatchFailure(
@@ -2357,7 +2368,8 @@ private:
mlir::Location loc,
mlir::ConversionPatternRewriter &rewriter) const {
mlir::Type boxObjTy = coor.getBaseType();
- assert(mlir::dyn_cast<fir::BaseBoxType>(boxObjTy) && "This is not a `fir.box`");
+ assert(mlir::dyn_cast<fir::BaseBoxType>(boxObjTy) &&
+ "This is not a `fir.box`");
TypePair boxTyPair = getBoxTypePair(boxObjTy);
mlir::Value boxBaseAddr = operands[0];
diff --git a/flang/lib/Optimizer/CodeGen/TypeConverter.cpp b/flang/lib/Optimizer/CodeGen/TypeConverter.cpp
index dc58388aa1..54647c665b 100644
--- a/flang/lib/Optimizer/CodeGen/TypeConverter.cpp
+++ b/flang/lib/Optimizer/CodeGen/TypeConverter.cpp
@@ -211,7 +211,8 @@ mlir::Type LLVMTypeConverter::convertBoxTypeAsStruct(BaseBoxType box,
ele = removeIndirection;
auto eleTy = convertType(ele);
// base_addr*
- if (mlir::isa<SequenceType>(ele) && mlir::isa<mlir::LLVM::LLVMPointerType>(eleTy))
+ if (mlir::isa<SequenceType>(ele) &&
+ mlir::isa<mlir::LLVM::LLVMPointerType>(eleTy))
dataDescFields.push_back(eleTy);
else
dataDescFields.push_back(
@@ -252,7 +253,8 @@ mlir::Type LLVMTypeConverter::convertBoxTypeAsStruct(BaseBoxType box,
auto rowTy =
getExtendedDescFieldTypeModel<kOptRowTypePosInBox>()(&getContext());
dataDescFields.push_back(mlir::LLVM::LLVMArrayType::get(rowTy, 1));
- if (auto recTy = mlir::dyn_cast<fir::RecordType>(fir::unwrapSequenceType(ele)))
+ if (auto recTy =
+ mlir::dyn_cast<fir::RecordType>(fir::unwrapSequenceType(ele)))
if (recTy.getNumLenParams() > 0) {
// The descriptor design needs to be clarified regarding the number of
// length parameters in the addendum. Since it can change for
diff --git a/flang/lib/Optimizer/HLFIR/Transforms/SimplifyHLFIRIntrinsics.cpp b/flang/lib/Optimizer/HLFIR/Transforms/SimplifyHLFIRIntrinsics.cpp
index 8525b3625b..b761563eba 100644
--- a/flang/lib/Optimizer/HLFIR/Transforms/SimplifyHLFIRIntrinsics.cpp
+++ b/flang/lib/Optimizer/HLFIR/Transforms/SimplifyHLFIRIntrinsics.cpp
@@ -103,7 +103,8 @@ public:
// by hlfir.elemental)
target.addDynamicallyLegalOp<hlfir::TransposeOp>(
[](hlfir::TransposeOp transpose) {
- return mlir::cast<hlfir::ExprType>(transpose.getType()).isPolymorphic();
+ return mlir::cast<hlfir::ExprType>(transpose.getType())
+ .isPolymorphic();
});
target.markUnknownOpDynamicallyLegal(
[](mlir::Operation *) { return true; });
diff --git a/flang/lib/Optimizer/Transforms/PolymorphicOpConversion.cpp b/flang/lib/Optimizer/Transforms/PolymorphicOpConversion.cpp
index 9b0d57fc62..5ca04ba99e 100644
--- a/flang/lib/Optimizer/Transforms/PolymorphicOpConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/PolymorphicOpConversion.cpp
@@ -168,8 +168,8 @@ struct DispatchOpConv : public OpConversionPattern<fir::DispatchOp> {
// Load the correct binding.
mlir::Value bindings = rewriter.create<fir::BoxAddrOp>(loc, bindingBox);
- fir::RecordType bindingTy =
- mlir::cast<fir::BaseBoxType>(fir::unwrapIfDerived(bindingBox.getType()));
+ fir::RecordType bindingTy = mlir::cast<fir::BaseBoxType>(
+ fir::unwrapIfDerived(bindingBox.getType()));
mlir::Type bindingAddrTy = fir::ReferenceType::get(bindingTy);
mlir::Value bindingIdxVal = rewriter.create<mlir::arith::ConstantOp>(
loc, rewriter.getIndexType(), rewriter.getIndexAttr(bindingIdx));
diff --git a/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp b/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp
index f5a9b0d834..2253a15621 100644
--- a/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp
+++ b/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp
@@ -217,8 +217,7 @@ TEST_F(FIRBuilderTest, createGlobal2) {
EXPECT_EQ(i32Type, global.getType());
EXPECT_TRUE(global.getInitVal().has_value());
EXPECT_TRUE(mlir::isa<mlir::IntegerAttr>(global.getInitVal().value()));
- EXPECT_EQ(
- 16,
+ EXPECT_EQ(16,
mlir::cast<mlir::IntegerAttr>(global.getInitVal().value()).getValue());
EXPECT_TRUE(global.getLinkName().has_value());
EXPECT_EQ(
@@ -272,14 +271,15 @@ TEST_F(FIRBuilderTest, locationToFilename) {
auto stringLitOps = global.getRegion().front().getOps<fir::StringLitOp>();
EXPECT_TRUE(llvm::hasSingleElement(stringLitOps));
for (auto stringLit : stringLitOps) {
- EXPECT_EQ(10,
- mlir::cast<mlir::IntegerAttr>(stringLit.getSize()).getValue());
+ EXPECT_EQ(
+ 10, mlir::cast<mlir::IntegerAttr>(stringLit.getSize()).getValue());
EXPECT_TRUE(mlir::isa<StringAttr>(stringLit.getValue()));
- EXPECT_EQ(0, strcmp("file1.f90\0",
- mlir::dyn_cast<StringAttr>(stringLit.getValue())
- .getValue()
- .str()
- .c_str()));
+ EXPECT_EQ(0,
+ strcmp("file1.f90\0",
+ mlir::dyn_cast<StringAttr>(stringLit.getValue())
+ .getValue()
+ .str()
+ .c_str()));
}
}
@@ -318,11 +318,11 @@ TEST_F(FIRBuilderTest, createStringLiteral) {
auto stringLitOps = global.getRegion().front().getOps<fir::StringLitOp>();
EXPECT_TRUE(llvm::hasSingleElement(stringLitOps));
for (auto stringLit : stringLitOps) {
- EXPECT_EQ(16,
- mlir::cast<mlir::IntegerAttr>(stringLit.getSize()).getValue());
+ EXPECT_EQ(
+ 16, mlir::cast<mlir::IntegerAttr>(stringLit.getSize()).getValue());
EXPECT_TRUE(mlir::isa<StringAttr>(stringLit.getValue()));
- EXPECT_EQ(strValue,
- mlir::dyn_cast<StringAttr>(stringLit.getValue()).getValue());
+ EXPECT_EQ(
+ strValue, mlir::dyn_cast<StringAttr>(stringLit.getValue()).getValue());
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/89998
More information about the flang-commits
mailing list