Skip to content

Commit dddf747

Browse files
committed
[unittests] Use {} instead of std::nullopt to initialize empty ArrayRef
Follow up to llvm#109133.
1 parent 9e73159 commit dddf747

16 files changed

+183
-183
lines changed

llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ TEST_F(AArch64SelectionDAGTest, ReplaceAllUsesWith) {
709709
EXPECT_FALSE(DAG->getHeapAllocSite(N2.getNode()));
710710
EXPECT_FALSE(DAG->getNoMergeSiteInfo(N2.getNode()));
711711
EXPECT_FALSE(DAG->getPCSections(N2.getNode()));
712-
MDNode *MD = MDNode::get(Context, std::nullopt);
712+
MDNode *MD = MDNode::get(Context, {});
713713
DAG->addHeapAllocSite(N2.getNode(), MD);
714714
DAG->addNoMergeSiteInfo(N2.getNode(), true);
715715
DAG->addPCSections(N2.getNode(), MD);

llvm/unittests/CodeGen/InstrRefLDVTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class InstrRefLDVTest : public testing::Test {
103103
OurCU =
104104
DIB.createCompileUnit(dwarf::DW_LANG_C99, OurFile, "nou", false, "", 0);
105105
auto OurSubT =
106-
DIB.createSubroutineType(DIB.getOrCreateTypeArray(std::nullopt));
106+
DIB.createSubroutineType(DIB.getOrCreateTypeArray({}));
107107
OurFunc =
108108
DIB.createFunction(OurCU, "bees", "", OurFile, 1, OurSubT, 1,
109109
DINode::FlagZero, DISubprogram::SPFlagDefinition);

llvm/unittests/CodeGen/LexicalScopesTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class LexicalScopesTest : public testing::Test {
104104
OurCU =
105105
DIB.createCompileUnit(dwarf::DW_LANG_C99, OurFile, "nou", false, "", 0);
106106
auto OurSubT =
107-
DIB.createSubroutineType(DIB.getOrCreateTypeArray(std::nullopt));
107+
DIB.createSubroutineType(DIB.getOrCreateTypeArray({}));
108108
OurFunc =
109109
DIB.createFunction(OurCU, "bees", "", OurFile, 1, OurSubT, 1,
110110
DINode::FlagZero, DISubprogram::SPFlagDefinition);

llvm/unittests/CodeGen/MFCommon.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public:
3333
getCalleeSavedRegs(const MachineFunction *MF) const override {
3434
return nullptr;
3535
}
36-
ArrayRef<const uint32_t *> getRegMasks() const override { return std::nullopt; }
37-
ArrayRef<const char *> getRegMaskNames() const override { return std::nullopt; }
36+
ArrayRef<const uint32_t *> getRegMasks() const override { return {}; }
37+
ArrayRef<const char *> getRegMaskNames() const override { return {}; }
3838
BitVector getReservedRegs(const MachineFunction &MF) const override {
3939
return BitVector();
4040
}

llvm/unittests/CodeGen/MachineBasicBlockTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ TEST(FindDebugLocTest, DifferentIterators) {
4343
DICompileUnit *OurCU =
4444
DIB.createCompileUnit(dwarf::DW_LANG_C99, OurFile, "", false, "", 0);
4545
auto OurSubT =
46-
DIB.createSubroutineType(DIB.getOrCreateTypeArray(std::nullopt));
46+
DIB.createSubroutineType(DIB.getOrCreateTypeArray({}));
4747
DISubprogram *OurFunc =
4848
DIB.createFunction(OurCU, "bees", "", OurFile, 1, OurSubT, 1,
4949
DINode::FlagZero, DISubprogram::SPFlagDefinition);

llvm/unittests/CodeGen/MachineInstrTest.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ TEST(MachineInstrExtraInfo, AddExtraInfo) {
276276
MMOs.push_back(MMO);
277277
MCSymbol *Sym1 = MC->createTempSymbol("pre_label", false);
278278
MCSymbol *Sym2 = MC->createTempSymbol("post_label", false);
279-
MDNode *HAM = MDNode::getDistinct(Ctx, std::nullopt);
280-
MDNode *PCS = MDNode::getDistinct(Ctx, std::nullopt);
279+
MDNode *HAM = MDNode::getDistinct(Ctx, {});
280+
MDNode *PCS = MDNode::getDistinct(Ctx, {});
281281
MDNode *MMRA = MMRAMetadata::getTagMD(Ctx, "foo", "bar");
282282

283283
ASSERT_TRUE(MI->memoperands_empty());
@@ -357,8 +357,8 @@ TEST(MachineInstrExtraInfo, ChangeExtraInfo) {
357357
MMOs.push_back(MMO);
358358
MCSymbol *Sym1 = MC->createTempSymbol("pre_label", false);
359359
MCSymbol *Sym2 = MC->createTempSymbol("post_label", false);
360-
MDNode *HAM = MDNode::getDistinct(Ctx, std::nullopt);
361-
MDNode *PCS = MDNode::getDistinct(Ctx, std::nullopt);
360+
MDNode *HAM = MDNode::getDistinct(Ctx, {});
361+
MDNode *PCS = MDNode::getDistinct(Ctx, {});
362362

363363
MDNode *MMRA1 = MMRAMetadata::getTagMD(Ctx, "foo", "bar");
364364
MDNode *MMRA2 = MMRAMetadata::getTagMD(Ctx, "bar", "bux");
@@ -413,8 +413,8 @@ TEST(MachineInstrExtraInfo, RemoveExtraInfo) {
413413
MMOs.push_back(MMO);
414414
MCSymbol *Sym1 = MC->createTempSymbol("pre_label", false);
415415
MCSymbol *Sym2 = MC->createTempSymbol("post_label", false);
416-
MDNode *HAM = MDNode::getDistinct(Ctx, std::nullopt);
417-
MDNode *PCS = MDNode::getDistinct(Ctx, std::nullopt);
416+
MDNode *HAM = MDNode::getDistinct(Ctx, {});
417+
MDNode *PCS = MDNode::getDistinct(Ctx, {});
418418

419419
MDNode *MMRA = MDTuple::get(Ctx, {});
420420

@@ -506,8 +506,8 @@ MATCHER_P(HasMIMetadata, MIMD, "") {
506506

507507
TEST(MachineInstrBuilder, BuildMI) {
508508
LLVMContext Ctx;
509-
MDNode *PCS = MDNode::getDistinct(Ctx, std::nullopt);
510-
MDNode *DI = MDNode::getDistinct(Ctx, std::nullopt);
509+
MDNode *PCS = MDNode::getDistinct(Ctx, {});
510+
MDNode *DI = MDNode::getDistinct(Ctx, {});
511511
DebugLoc DL(DI);
512512
MIMetadata MIMD(DL, PCS);
513513
EXPECT_EQ(MIMD.getDL(), DL);

llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class OpenMPIRBuilderTest : public testing::Test {
176176
auto CU =
177177
DIB.createCompileUnit(dwarf::DW_LANG_C, File, "llvm-C", true, "", 0);
178178
auto Type =
179-
DIB.createSubroutineType(DIB.getOrCreateTypeArray(std::nullopt));
179+
DIB.createSubroutineType(DIB.getOrCreateTypeArray({}));
180180
auto SP = DIB.createFunction(
181181
CU, "foo", "", File, 1, Type, 1, DINode::FlagZero,
182182
DISubprogram::SPFlagDefinition | DISubprogram::SPFlagOptimized);

llvm/unittests/IR/IRBuilderTest.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ TEST_F(IRBuilderTest, ConstrainedFPFunctionCall) {
438438
// Now call the empty constrained FP function.
439439
Builder.setIsFPConstrained(true);
440440
Builder.setConstrainedFPFunctionAttr();
441-
CallInst *FCall = Builder.CreateCall(Callee, std::nullopt);
441+
CallInst *FCall = Builder.CreateCall(Callee, {});
442442

443443
// Check the attributes to verify the strictfp attribute is on the call.
444444
EXPECT_TRUE(
@@ -697,24 +697,24 @@ TEST_F(IRBuilderTest, FastMathFlags) {
697697
auto Callee =
698698
Function::Create(CalleeTy, Function::ExternalLinkage, "", M.get());
699699

700-
FCall = Builder.CreateCall(Callee, std::nullopt);
700+
FCall = Builder.CreateCall(Callee, {});
701701
EXPECT_FALSE(FCall->hasNoNaNs());
702702

703703
Function *V =
704704
Function::Create(CalleeTy, Function::ExternalLinkage, "", M.get());
705-
FCall = Builder.CreateCall(V, std::nullopt);
705+
FCall = Builder.CreateCall(V, {});
706706
EXPECT_FALSE(FCall->hasNoNaNs());
707707

708708
FMF.clear();
709709
FMF.setNoNaNs();
710710
Builder.setFastMathFlags(FMF);
711711

712-
FCall = Builder.CreateCall(Callee, std::nullopt);
712+
FCall = Builder.CreateCall(Callee, {});
713713
EXPECT_TRUE(Builder.getFastMathFlags().any());
714714
EXPECT_TRUE(Builder.getFastMathFlags().NoNaNs);
715715
EXPECT_TRUE(FCall->hasNoNaNs());
716716

717-
FCall = Builder.CreateCall(V, std::nullopt);
717+
FCall = Builder.CreateCall(V, {});
718718
EXPECT_TRUE(Builder.getFastMathFlags().any());
719719
EXPECT_TRUE(Builder.getFastMathFlags().NoNaNs);
720720
EXPECT_TRUE(FCall->hasNoNaNs());
@@ -856,7 +856,7 @@ TEST_F(IRBuilderTest, createFunction) {
856856
auto File = DIB.createFile("error.swift", "/");
857857
auto CU =
858858
DIB.createCompileUnit(dwarf::DW_LANG_Swift, File, "swiftc", true, "", 0);
859-
auto Type = DIB.createSubroutineType(DIB.getOrCreateTypeArray(std::nullopt));
859+
auto Type = DIB.createSubroutineType(DIB.getOrCreateTypeArray({}));
860860
auto NoErr = DIB.createFunction(
861861
CU, "noerr", "", File, 1, Type, 1, DINode::FlagZero,
862862
DISubprogram::SPFlagDefinition | DISubprogram::SPFlagOptimized);
@@ -897,7 +897,7 @@ TEST_F(IRBuilderTest, DIBuilder) {
897897
DIB.createFile("F.CBL", "/"),
898898
"llvm-cobol74", true, "", 0);
899899
auto Type =
900-
DIB.createSubroutineType(DIB.getOrCreateTypeArray(std::nullopt));
900+
DIB.createSubroutineType(DIB.getOrCreateTypeArray({}));
901901
auto SP = DIB.createFunction(
902902
CU, "foo", "", File, 1, Type, 1, DINode::FlagZero,
903903
DISubprogram::SPFlagDefinition | DISubprogram::SPFlagOptimized);
@@ -1014,7 +1014,7 @@ TEST_F(IRBuilderTest, createArtificialSubprogram) {
10141014
auto CU = DIB.createCompileUnit(dwarf::DW_LANG_C, File, "clang",
10151015
/*isOptimized=*/true, /*Flags=*/"",
10161016
/*Runtime Version=*/0);
1017-
auto Type = DIB.createSubroutineType(DIB.getOrCreateTypeArray(std::nullopt));
1017+
auto Type = DIB.createSubroutineType(DIB.getOrCreateTypeArray({}));
10181018
auto SP = DIB.createFunction(
10191019
CU, "foo", /*LinkageName=*/"", File,
10201020
/*LineNo=*/1, Type, /*ScopeLine=*/2, DINode::FlagZero,
@@ -1169,7 +1169,7 @@ TEST_F(IRBuilderTest, DebugLoc) {
11691169
DIB.createFile("tmp.cpp", "/"), "", true, "",
11701170
0);
11711171
auto SPType =
1172-
DIB.createSubroutineType(DIB.getOrCreateTypeArray(std::nullopt));
1172+
DIB.createSubroutineType(DIB.getOrCreateTypeArray({}));
11731173
auto SP =
11741174
DIB.createFunction(CU, "foo", "foo", File, 1, SPType, 1, DINode::FlagZero,
11751175
DISubprogram::SPFlagDefinition);
@@ -1183,13 +1183,13 @@ TEST_F(IRBuilderTest, DebugLoc) {
11831183
IRBuilder<> Builder(Ctx);
11841184
Builder.SetInsertPoint(Br);
11851185
EXPECT_EQ(DL1, Builder.getCurrentDebugLocation());
1186-
auto Call1 = Builder.CreateCall(Callee, std::nullopt);
1186+
auto Call1 = Builder.CreateCall(Callee, {});
11871187
EXPECT_EQ(DL1, Call1->getDebugLoc());
11881188

11891189
Call1->setDebugLoc(DL2);
11901190
Builder.SetInsertPoint(Call1->getParent(), Call1->getIterator());
11911191
EXPECT_EQ(DL2, Builder.getCurrentDebugLocation());
1192-
auto Call2 = Builder.CreateCall(Callee, std::nullopt);
1192+
auto Call2 = Builder.CreateCall(Callee, {});
11931193
EXPECT_EQ(DL2, Call2->getDebugLoc());
11941194

11951195
DIB.finalize();
@@ -1202,7 +1202,7 @@ TEST_F(IRBuilderTest, DIImportedEntity) {
12021202
auto CU = DIB.createCompileUnit(dwarf::DW_LANG_Cobol74,
12031203
F, "llvm-cobol74",
12041204
true, "", 0);
1205-
MDTuple *Elements = MDTuple::getDistinct(Ctx, std::nullopt);
1205+
MDTuple *Elements = MDTuple::getDistinct(Ctx, {});
12061206

12071207
DIB.createImportedDeclaration(CU, nullptr, F, 1);
12081208
DIB.createImportedDeclaration(CU, nullptr, F, 1);

llvm/unittests/IR/InstructionsTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ TEST(InstructionsTest, AlterCallBundles) {
756756
AttrBuilder AB(C);
757757
AB.addAttribute(Attribute::Cold);
758758
Call->setAttributes(AttributeList::get(C, AttributeList::FunctionIndex, AB));
759-
Call->setDebugLoc(DebugLoc(MDNode::get(C, std::nullopt)));
759+
Call->setDebugLoc(DebugLoc(MDNode::get(C, {})));
760760

761761
OperandBundleDef NewBundle("after", ConstantInt::get(Int32Ty, 7));
762762
std::unique_ptr<CallInst> Clone(CallInst::Create(Call.get(), NewBundle));
@@ -786,7 +786,7 @@ TEST(InstructionsTest, AlterInvokeBundles) {
786786
AB.addAttribute(Attribute::Cold);
787787
Invoke->setAttributes(
788788
AttributeList::get(C, AttributeList::FunctionIndex, AB));
789-
Invoke->setDebugLoc(DebugLoc(MDNode::get(C, std::nullopt)));
789+
Invoke->setDebugLoc(DebugLoc(MDNode::get(C, {})));
790790

791791
OperandBundleDef NewBundle("after", ConstantInt::get(Int32Ty, 7));
792792
std::unique_ptr<InvokeInst> Clone(

0 commit comments

Comments
 (0)