Skip to content

[flang][NFC] Update flang/unittests to the new create APIs #152056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions flang/unittests/Optimizer/Builder/Runtime/AllocatableTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ TEST_F(RuntimeCallTest, genMoveAlloc) {
mlir::Location loc = firBuilder->getUnknownLoc();
mlir::Type seqTy =
fir::SequenceType::get(fir::SequenceType::Shape(1, 10), i32Ty);
mlir::Value from = firBuilder->create<fir::UndefOp>(loc, seqTy);
mlir::Value to = firBuilder->create<fir::UndefOp>(loc, seqTy);
mlir::Value errMsg = firBuilder->create<fir::UndefOp>(loc, seqTy);
mlir::Value from = fir::UndefOp::create(*firBuilder, loc, seqTy);
mlir::Value to = fir::UndefOp::create(*firBuilder, loc, seqTy);
mlir::Value errMsg = fir::UndefOp::create(*firBuilder, loc, seqTy);
mlir::Value hasStat = firBuilder->createBool(loc, false);
fir::runtime::genMoveAlloc(*firBuilder, loc, to, from, hasStat, errMsg);
checkCallOpFromResultBox(to, "_FortranAMoveAlloc", 5);
Expand Down
4 changes: 2 additions & 2 deletions flang/unittests/Optimizer/Builder/Runtime/AssignTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ TEST_F(RuntimeCallTest, genDerivedTypeAssign) {
auto loc = firBuilder->getUnknownLoc();
mlir::Type seqTy =
fir::SequenceType::get(fir::SequenceType::Shape(1, 10), i32Ty);
mlir::Value source = firBuilder->create<fir::UndefOp>(loc, seqTy);
mlir::Value dest = firBuilder->create<fir::UndefOp>(loc, seqTy);
mlir::Value source = fir::UndefOp::create(*firBuilder, loc, seqTy);
mlir::Value dest = fir::UndefOp::create(*firBuilder, loc, seqTy);
fir::runtime::genAssign(*firBuilder, loc, dest, source);
checkCallOpFromResultBox(dest, "_FortranAAssign", 2);
}
48 changes: 24 additions & 24 deletions flang/unittests/Optimizer/Builder/Runtime/CharacterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ using namespace mlir;

TEST_F(RuntimeCallTest, genAdjustLTest) {
auto loc = firBuilder->getUnknownLoc();
mlir::Value result = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value string = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value result = fir::UndefOp::create(*firBuilder, loc, boxTy);
mlir::Value string = fir::UndefOp::create(*firBuilder, loc, boxTy);
fir::runtime::genAdjustL(*firBuilder, loc, result, string);
checkCallOpFromResultBox(result, "_FortranAAdjustl", 2);
}

TEST_F(RuntimeCallTest, genAdjustRTest) {
auto loc = firBuilder->getUnknownLoc();
mlir::Value result = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value string = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value result = fir::UndefOp::create(*firBuilder, loc, boxTy);
mlir::Value string = fir::UndefOp::create(*firBuilder, loc, boxTy);
fir::runtime::genAdjustR(*firBuilder, loc, result, string);
checkCallOpFromResultBox(result, "_FortranAAdjustr", 2);
}
Expand Down Expand Up @@ -115,40 +115,40 @@ TEST_F(RuntimeCallTest, genIndexTest) {

TEST_F(RuntimeCallTest, genIndexDescriptorTest) {
auto loc = firBuilder->getUnknownLoc();
mlir::Value resultBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value stringBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value substringBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value backOpt = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value kind = firBuilder->create<fir::UndefOp>(loc, i32Ty);
mlir::Value resultBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
mlir::Value stringBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
mlir::Value substringBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
mlir::Value backOpt = fir::UndefOp::create(*firBuilder, loc, boxTy);
mlir::Value kind = fir::UndefOp::create(*firBuilder, loc, i32Ty);
fir::runtime::genIndexDescriptor(
*firBuilder, loc, resultBox, stringBox, substringBox, backOpt, kind);
checkCallOpFromResultBox(resultBox, "_FortranAIndex", 5);
}

TEST_F(RuntimeCallTest, genRepeatTest) {
auto loc = firBuilder->getUnknownLoc();
mlir::Value resultBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value stringBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value ncopies = firBuilder->create<fir::UndefOp>(loc, i32Ty);
mlir::Value resultBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
mlir::Value stringBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
mlir::Value ncopies = fir::UndefOp::create(*firBuilder, loc, i32Ty);
fir::runtime::genRepeat(*firBuilder, loc, resultBox, stringBox, ncopies);
checkCallOpFromResultBox(resultBox, "_FortranARepeat", 3);
}

TEST_F(RuntimeCallTest, genTrimTest) {
auto loc = firBuilder->getUnknownLoc();
mlir::Value resultBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value stringBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value resultBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
mlir::Value stringBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
fir::runtime::genTrim(*firBuilder, loc, resultBox, stringBox);
checkCallOpFromResultBox(resultBox, "_FortranATrim", 2);
}

TEST_F(RuntimeCallTest, genScanDescriptorTest) {
auto loc = firBuilder->getUnknownLoc();
mlir::Value resultBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value stringBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value setBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value backBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value kind = firBuilder->create<fir::UndefOp>(loc, i32Ty);
mlir::Value resultBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
mlir::Value stringBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
mlir::Value setBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
mlir::Value backBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
mlir::Value kind = fir::UndefOp::create(*firBuilder, loc, i32Ty);
fir::runtime::genScanDescriptor(
*firBuilder, loc, resultBox, stringBox, setBox, backBox, kind);
checkCallOpFromResultBox(resultBox, "_FortranAScan", 5);
Expand Down Expand Up @@ -178,11 +178,11 @@ TEST_F(RuntimeCallTest, genScanTest) {

TEST_F(RuntimeCallTest, genVerifyDescriptorTest) {
auto loc = firBuilder->getUnknownLoc();
mlir::Value resultBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value stringBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value setBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value backBox = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value kind = firBuilder->create<fir::UndefOp>(loc, i32Ty);
mlir::Value resultBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
mlir::Value stringBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
mlir::Value setBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
mlir::Value backBox = fir::UndefOp::create(*firBuilder, loc, boxTy);
mlir::Value kind = fir::UndefOp::create(*firBuilder, loc, i32Ty);
fir::runtime::genVerifyDescriptor(
*firBuilder, loc, resultBox, stringBox, setBox, backBox, kind);
checkCallOpFromResultBox(resultBox, "_FortranAVerify", 5);
Expand Down
18 changes: 9 additions & 9 deletions flang/unittests/Optimizer/Builder/Runtime/CommandTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ TEST_F(RuntimeCallTest, genGetCommandArgument) {
mlir::Location loc = firBuilder->getUnknownLoc();
mlir::Type intTy = firBuilder->getDefaultIntegerType();
mlir::Type boxTy = fir::BoxType::get(firBuilder->getNoneType());
mlir::Value number = firBuilder->create<fir::UndefOp>(loc, intTy);
mlir::Value value = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value length = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value errmsg = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value number = fir::UndefOp::create(*firBuilder, loc, intTy);
mlir::Value value = fir::UndefOp::create(*firBuilder, loc, boxTy);
mlir::Value length = fir::UndefOp::create(*firBuilder, loc, boxTy);
mlir::Value errmsg = fir::UndefOp::create(*firBuilder, loc, boxTy);
mlir::Value result = fir::runtime::genGetCommandArgument(
*firBuilder, loc, number, value, length, errmsg);
checkCallOp(result.getDefiningOp(), "_FortranAGetCommandArgument",
Expand All @@ -34,11 +34,11 @@ TEST_F(RuntimeCallTest, genGetCommandArgument) {

TEST_F(RuntimeCallTest, genGetEnvVariable) {
mlir::Location loc = firBuilder->getUnknownLoc();
mlir::Value name = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value value = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value length = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value trimName = firBuilder->create<fir::UndefOp>(loc, i1Ty);
mlir::Value errmsg = firBuilder->create<fir::UndefOp>(loc, boxTy);
mlir::Value name = fir::UndefOp::create(*firBuilder, loc, boxTy);
mlir::Value value = fir::UndefOp::create(*firBuilder, loc, boxTy);
mlir::Value length = fir::UndefOp::create(*firBuilder, loc, boxTy);
mlir::Value trimName = fir::UndefOp::create(*firBuilder, loc, i1Ty);
mlir::Value errmsg = fir::UndefOp::create(*firBuilder, loc, boxTy);
mlir::Value result = fir::runtime::genGetEnvVariable(
*firBuilder, loc, name, value, length, trimName, errmsg);
checkCallOp(result.getDefiningOp(), "_FortranAGetEnvVariable", /*nbArgs=*/5,
Expand Down
4 changes: 2 additions & 2 deletions flang/unittests/Optimizer/Builder/Runtime/DerivedTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ TEST_F(RuntimeCallTest, genDerivedTypeInitialize) {
auto loc = firBuilder->getUnknownLoc();
mlir::Type seqTy =
fir::SequenceType::get(fir::SequenceType::Shape(1, 10), i32Ty);
mlir::Value box = firBuilder->create<fir::UndefOp>(loc, seqTy);
mlir::Value box = fir::UndefOp::create(*firBuilder, loc, seqTy);
fir::runtime::genDerivedTypeInitialize(*firBuilder, loc, box);
checkCallOpFromResultBox(box, "_FortranAInitialize", 1);
}
Expand All @@ -23,7 +23,7 @@ TEST_F(RuntimeCallTest, genDerivedTypeDestroy) {
auto loc = firBuilder->getUnknownLoc();
mlir::Type seqTy =
fir::SequenceType::get(fir::SequenceType::Shape(1, 10), i32Ty);
mlir::Value box = firBuilder->create<fir::UndefOp>(loc, seqTy);
mlir::Value box = fir::UndefOp::create(*firBuilder, loc, seqTy);
fir::runtime::genDerivedTypeDestroy(*firBuilder, loc, box);
checkCallOpFromResultBox(box, "_FortranADestroy", 1, /*addLocArg=*/false);
}
4 changes: 2 additions & 2 deletions flang/unittests/Optimizer/Builder/Runtime/RaggedTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ TEST_F(RuntimeCallTest, genRaggedArrayAllocateTest) {
auto loc = firBuilder->getUnknownLoc();
mlir::TupleType headerTy =
fir::factory::getRaggedArrayHeaderType(*firBuilder);
mlir::Value header = firBuilder->create<fir::UndefOp>(loc, headerTy);
mlir::Value header = fir::UndefOp::create(*firBuilder, loc, headerTy);
mlir::Value eleSize = firBuilder->createIntegerConstant(loc, i32Ty, 1);
mlir::Value extent = firBuilder->createIntegerConstant(loc, i32Ty, 1);
// Use a dummy header just to test the correctness of the generated call.
Expand All @@ -29,7 +29,7 @@ TEST_F(RuntimeCallTest, genRaggedArrayDeallocateTest) {
mlir::TupleType headerTy =
fir::factory::getRaggedArrayHeaderType(*firBuilder);
// Use a dummy header just to test the correctness of the generated call.
mlir::Value header = firBuilder->create<fir::UndefOp>(loc, headerTy);
mlir::Value header = fir::UndefOp::create(*firBuilder, loc, headerTy);
fir::runtime::genRaggedArrayDeallocate(loc, *firBuilder, header);
checkCallOpFromResultBox(
header, "_FortranARaggedArrayDeallocate", 1, /*addLocArgs=*/false);
Expand Down
24 changes: 12 additions & 12 deletions flang/unittests/Optimizer/Builder/Runtime/ReductionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,50 @@

TEST_F(RuntimeCallTest, genAllTest) {
mlir::Location loc = firBuilder->getUnknownLoc();
mlir::Value undef = firBuilder->create<fir::UndefOp>(loc, seqTy10);
mlir::Value undef = fir::UndefOp::create(*firBuilder, loc, seqTy10);
mlir::Value dim = firBuilder->createIntegerConstant(loc, i32Ty, 1);
mlir::Value all = fir::runtime::genAll(*firBuilder, loc, undef, dim);
checkCallOp(all.getDefiningOp(), "_FortranAAll", 2);
}

TEST_F(RuntimeCallTest, genAllDescriptorTest) {
mlir::Location loc = firBuilder->getUnknownLoc();
mlir::Value result = firBuilder->create<fir::UndefOp>(loc, seqTy10);
mlir::Value mask = firBuilder->create<fir::UndefOp>(loc, seqTy10);
mlir::Value result = fir::UndefOp::create(*firBuilder, loc, seqTy10);
mlir::Value mask = fir::UndefOp::create(*firBuilder, loc, seqTy10);
mlir::Value dim = firBuilder->createIntegerConstant(loc, i32Ty, 1);
fir::runtime::genAllDescriptor(*firBuilder, loc, result, mask, dim);
checkCallOpFromResultBox(result, "_FortranAAllDim", 3);
}

TEST_F(RuntimeCallTest, genAnyTest) {
mlir::Location loc = firBuilder->getUnknownLoc();
mlir::Value undef = firBuilder->create<fir::UndefOp>(loc, seqTy10);
mlir::Value undef = fir::UndefOp::create(*firBuilder, loc, seqTy10);
mlir::Value dim = firBuilder->createIntegerConstant(loc, i32Ty, 1);
mlir::Value any = fir::runtime::genAny(*firBuilder, loc, undef, dim);
checkCallOp(any.getDefiningOp(), "_FortranAAny", 2);
}

TEST_F(RuntimeCallTest, genAnyDescriptorTest) {
mlir::Location loc = firBuilder->getUnknownLoc();
mlir::Value result = firBuilder->create<fir::UndefOp>(loc, seqTy10);
mlir::Value mask = firBuilder->create<fir::UndefOp>(loc, seqTy10);
mlir::Value result = fir::UndefOp::create(*firBuilder, loc, seqTy10);
mlir::Value mask = fir::UndefOp::create(*firBuilder, loc, seqTy10);
mlir::Value dim = firBuilder->createIntegerConstant(loc, i32Ty, 1);
fir::runtime::genAnyDescriptor(*firBuilder, loc, result, mask, dim);
checkCallOpFromResultBox(result, "_FortranAAnyDim", 3);
}

TEST_F(RuntimeCallTest, genCountTest) {
mlir::Location loc = firBuilder->getUnknownLoc();
mlir::Value undef = firBuilder->create<fir::UndefOp>(loc, seqTy10);
mlir::Value undef = fir::UndefOp::create(*firBuilder, loc, seqTy10);
mlir::Value dim = firBuilder->createIntegerConstant(loc, i32Ty, 1);
mlir::Value count = fir::runtime::genCount(*firBuilder, loc, undef, dim);
checkCallOp(count.getDefiningOp(), "_FortranACount", 2);
}

TEST_F(RuntimeCallTest, genCountDimTest) {
mlir::Location loc = firBuilder->getUnknownLoc();
mlir::Value result = firBuilder->create<fir::UndefOp>(loc, seqTy10);
mlir::Value mask = firBuilder->create<fir::UndefOp>(loc, seqTy10);
mlir::Value result = fir::UndefOp::create(*firBuilder, loc, seqTy10);
mlir::Value mask = fir::UndefOp::create(*firBuilder, loc, seqTy10);
mlir::Value dim = firBuilder->createIntegerConstant(loc, i32Ty, 1);
mlir::Value kind = firBuilder->createIntegerConstant(loc, i32Ty, 1);
fir::runtime::genCountDim(*firBuilder, loc, result, mask, dim, kind);
Expand Down Expand Up @@ -114,16 +114,16 @@ TEST_F(RuntimeCallTest, genMinValTest) {

TEST_F(RuntimeCallTest, genParityTest) {
mlir::Location loc = firBuilder->getUnknownLoc();
mlir::Value undef = firBuilder->create<fir::UndefOp>(loc, seqTy10);
mlir::Value undef = fir::UndefOp::create(*firBuilder, loc, seqTy10);
mlir::Value dim = firBuilder->createIntegerConstant(loc, i32Ty, 1);
mlir::Value parity = fir::runtime::genParity(*firBuilder, loc, undef, dim);
checkCallOp(parity.getDefiningOp(), "_FortranAParity", 2);
}

TEST_F(RuntimeCallTest, genParityDescriptorTest) {
mlir::Location loc = firBuilder->getUnknownLoc();
mlir::Value result = firBuilder->create<fir::UndefOp>(loc, seqTy10);
mlir::Value mask = firBuilder->create<fir::UndefOp>(loc, seqTy10);
mlir::Value result = fir::UndefOp::create(*firBuilder, loc, seqTy10);
mlir::Value mask = fir::UndefOp::create(*firBuilder, loc, seqTy10);
mlir::Value dim = firBuilder->createIntegerConstant(loc, i32Ty, 1);
fir::runtime::genParityDescriptor(*firBuilder, loc, result, mask, dim);
checkCallOpFromResultBox(result, "_FortranAParityDim", 3);
Expand Down
Loading