[llvm] b4482f7 - [tools] Use std::nullopt instead of None (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 2 21:11:58 PST 2022
Author: Kazu Hirata
Date: 2022-12-02T21:11:40-08:00
New Revision: b4482f7ca04e852cf610ef0e16542c888844d93d
URL: https://github.com/llvm/llvm-project/commit/b4482f7ca04e852cf610ef0e16542c888844d93d
DIFF: https://github.com/llvm/llvm-project/commit/b4482f7ca04e852cf610ef0e16542c888844d93d.diff
LOG: [tools] Use std::nullopt instead of None (NFC)
This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated. The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.
This is part of an effort to migrate from llvm::Optional to
std::optional:
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
Added:
Modified:
llvm/tools/bugpoint/ToolRunner.cpp
llvm/tools/dsymutil/MachODebugMapParser.cpp
llvm/tools/dsymutil/MachOUtils.cpp
llvm/tools/llvm-as/llvm-as.cpp
llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
llvm/tools/llvm-cov/CodeCoverage.cpp
llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
llvm/tools/llvm-cov/SourceCoverageViewText.cpp
llvm/tools/llvm-dwarfdump/Statistics.cpp
llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp
llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
llvm/tools/llvm-ifs/llvm-ifs.cpp
llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
llvm/tools/llvm-lipo/llvm-lipo.cpp
llvm/tools/llvm-nm/llvm-nm.cpp
llvm/tools/llvm-objdump/SourcePrinter.cpp
llvm/tools/llvm-objdump/XCOFFDump.cpp
llvm/tools/llvm-objdump/llvm-objdump.cpp
llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp
llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
llvm/tools/llvm-profgen/PerfReader.cpp
llvm/tools/llvm-readobj/ARMEHABIPrinter.h
llvm/tools/llvm-readobj/ELFDumper.cpp
llvm/tools/llvm-readobj/MachODumper.cpp
llvm/tools/llvm-readobj/XCOFFDumper.cpp
llvm/tools/llvm-reduce/TestRunner.cpp
llvm/tools/llvm-reduce/deltas/ReduceOpcodes.cpp
llvm/tools/llvm-reduce/deltas/RunIRPasses.cpp
llvm/tools/llvm-sim/llvm-sim.cpp
llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
llvm/tools/lto/lto.cpp
llvm/tools/obj2yaml/dwarf2yaml.cpp
llvm/tools/obj2yaml/elf2yaml.cpp
llvm/tools/opt/NewPMDriver.cpp
llvm/tools/opt/opt.cpp
Removed:
################################################################################
diff --git a/llvm/tools/bugpoint/ToolRunner.cpp b/llvm/tools/bugpoint/ToolRunner.cpp
index 3f4c6a6393c51..352588f01ac8a 100644
--- a/llvm/tools/bugpoint/ToolRunner.cpp
+++ b/llvm/tools/bugpoint/ToolRunner.cpp
@@ -59,8 +59,8 @@ static int RunProgramWithTimeout(StringRef ProgramPath,
unsigned MemoryLimit = 0,
std::string *ErrMsg = nullptr) {
std::optional<StringRef> Redirects[3] = {StdInFile, StdOutFile, StdErrFile};
- return sys::ExecuteAndWait(ProgramPath, Args, None, Redirects, NumSeconds,
- MemoryLimit, ErrMsg);
+ return sys::ExecuteAndWait(ProgramPath, Args, std::nullopt, Redirects,
+ NumSeconds, MemoryLimit, ErrMsg);
}
/// RunProgramRemotelyWithTimeout - This function runs the given program
@@ -76,8 +76,8 @@ static int RunProgramRemotelyWithTimeout(
std::optional<StringRef> Redirects[3] = {StdInFile, StdOutFile, StdErrFile};
// Run the program remotely with the remote client
- int ReturnCode = sys::ExecuteAndWait(RemoteClientPath, Args, None, Redirects,
- NumSeconds, MemoryLimit);
+ int ReturnCode = sys::ExecuteAndWait(RemoteClientPath, Args, std::nullopt,
+ Redirects, NumSeconds, MemoryLimit);
// Has the remote client fail?
if (255 == ReturnCode) {
diff --git a/llvm/tools/dsymutil/MachODebugMapParser.cpp b/llvm/tools/dsymutil/MachODebugMapParser.cpp
index 955272b72f566..26aeb39023487 100644
--- a/llvm/tools/dsymutil/MachODebugMapParser.cpp
+++ b/llvm/tools/dsymutil/MachODebugMapParser.cpp
@@ -151,7 +151,8 @@ void MachODebugMapParser::addCommonSymbols() {
// The main binary doesn't have an address for the given symbol.
continue;
}
- if (!CurrentDebugMapObject->addSymbol(CommonSymbol, None /*ObjectAddress*/,
+ if (!CurrentDebugMapObject->addSymbol(CommonSymbol,
+ std::nullopt /*ObjectAddress*/,
CommonAddr, 0 /*size*/)) {
// The symbol is already present.
continue;
@@ -533,9 +534,9 @@ void MachODebugMapParser::loadCurrentObjectFileSymbols(
// in the DebugMap, leave it unassigned for these symbols.
uint32_t Flags = cantFail(Sym.getFlags());
if (Flags & SymbolRef::SF_Absolute) {
- CurrentObjectAddresses[*Name] = None;
+ CurrentObjectAddresses[*Name] = std::nullopt;
} else if (Flags & SymbolRef::SF_Common) {
- CurrentObjectAddresses[*Name] = None;
+ CurrentObjectAddresses[*Name] = std::nullopt;
CommonSymbols.push_back(std::string(*Name));
} else {
CurrentObjectAddresses[*Name] = Addr;
diff --git a/llvm/tools/dsymutil/MachOUtils.cpp b/llvm/tools/dsymutil/MachOUtils.cpp
index a239ed2265b40..3ab748ce6a196 100644
--- a/llvm/tools/dsymutil/MachOUtils.cpp
+++ b/llvm/tools/dsymutil/MachOUtils.cpp
@@ -66,7 +66,8 @@ static bool runLipo(StringRef SDKPath, SmallVectorImpl<StringRef> &Args) {
}
std::string ErrMsg;
- int result = sys::ExecuteAndWait(*Path, Args, None, {}, 0, 0, &ErrMsg);
+ int result =
+ sys::ExecuteAndWait(*Path, Args, std::nullopt, {}, 0, 0, &ErrMsg);
if (result) {
WithColor::error() << "lipo: " << ErrMsg << "\n";
return false;
diff --git a/llvm/tools/llvm-as/llvm-as.cpp b/llvm/tools/llvm-as/llvm-as.cpp
index b777f7271dc60..e74c202ffc970 100644
--- a/llvm/tools/llvm-as/llvm-as.cpp
+++ b/llvm/tools/llvm-as/llvm-as.cpp
@@ -122,7 +122,7 @@ int main(int argc, char **argv) {
SMDiagnostic Err;
auto SetDataLayout = [](StringRef) -> Optional<std::string> {
if (ClDataLayout.empty())
- return None;
+ return std::nullopt;
return ClDataLayout;
};
ParsedModuleAndIndex ModuleAndIndex;
diff --git a/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
index cb86d3c2b332c..78c4251088bc0 100644
--- a/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
+++ b/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
@@ -114,7 +114,7 @@ int main(int argc, char **argv) {
BitcodeAnalyzer BA(MB->getBuffer(),
BlockInfoMB ? Optional<StringRef>(BlockInfoMB->getBuffer())
- : None);
+ : std::nullopt);
BCDumpOptions O(outs());
O.Histogram = !NoHistogram;
@@ -124,7 +124,7 @@ int main(int argc, char **argv) {
ExitOnErr(BA.analyze(
Dump ? Optional<BCDumpOptions>(O) : Optional<BCDumpOptions>(),
- CheckHash.empty() ? None : Optional<StringRef>(CheckHash)));
+ CheckHash.empty() ? std::nullopt : Optional<StringRef>(CheckHash)));
if (Dump)
outs() << "\n\n";
diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp
index fe35d8981be91..63732fab5889f 100644
--- a/llvm/tools/llvm-cov/CodeCoverage.cpp
+++ b/llvm/tools/llvm-cov/CodeCoverage.cpp
@@ -559,9 +559,10 @@ void CodeCoverageTool::demangleSymbols(const CoverageMapping &Coverage) {
std::optional<StringRef> Redirects[] = {
InputPath.str(), OutputPath.str(), {""}};
std::string ErrMsg;
- int RC = sys::ExecuteAndWait(ViewOpts.DemanglerOpts[0], ArgsV,
- /*env=*/None, Redirects, /*secondsToWait=*/0,
- /*memoryLimit=*/0, &ErrMsg);
+ int RC =
+ sys::ExecuteAndWait(ViewOpts.DemanglerOpts[0], ArgsV,
+ /*env=*/std::nullopt, Redirects, /*secondsToWait=*/0,
+ /*memoryLimit=*/0, &ErrMsg);
if (RC) {
error(ErrMsg, ViewOpts.DemanglerOpts[0]);
return;
diff --git a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
index 03f11070df5f8..48082cb1ee905 100644
--- a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
@@ -560,7 +560,7 @@ void SourceCoverageViewHTML::renderLine(raw_ostream &OS, LineRef L,
else if (CurSeg->Col == ExpansionCol)
Color = "cyan";
else
- Color = None;
+ Color = std::nullopt;
if (Color)
Snippets[I + 1] = Highlight(Snippets[I + 1], CurSeg->Col,
diff --git a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
index 5f3eca336a7e6..67556199dfe5a 100644
--- a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
@@ -128,7 +128,7 @@ void SourceCoverageViewText::renderLine(raw_ostream &OS, LineRef L,
else if (Col == ExpansionCol)
Highlight = raw_ostream::CYAN;
else
- Highlight = None;
+ Highlight = std::nullopt;
}
// Show the rest of the line.
diff --git a/llvm/tools/llvm-dwarfdump/Statistics.cpp b/llvm/tools/llvm-dwarfdump/Statistics.cpp
index ed92665e04839..a967abffc1b54 100644
--- a/llvm/tools/llvm-dwarfdump/Statistics.cpp
+++ b/llvm/tools/llvm-dwarfdump/Statistics.cpp
@@ -500,7 +500,8 @@ static void collectStatsRecursive(
return;
// Handle any kind of lexical scope.
- const bool HasAbstractOrigin = Die.find(dwarf::DW_AT_abstract_origin) != None;
+ const bool HasAbstractOrigin =
+ Die.find(dwarf::DW_AT_abstract_origin) != std::nullopt;
const bool IsFunction = Tag == dwarf::DW_TAG_subprogram;
const bool IsBlock = Tag == dwarf::DW_TAG_lexical_block;
const bool IsInlinedFunction = Tag == dwarf::DW_TAG_inlined_subroutine;
diff --git a/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp b/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp
index 5b1ded885cd52..3dafb62dc67cc 100644
--- a/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp
+++ b/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp
@@ -222,7 +222,8 @@ class ObjFileAddressMap : public AddressesMap {
bool isDeadAddress(uint64_t LowPC, uint16_t Version, TombstoneKind Tombstone,
uint8_t AddressByteSize) {
- return isDeadAddressRange(LowPC, None, Version, Tombstone, AddressByteSize);
+ return isDeadAddressRange(LowPC, std::nullopt, Version, Tombstone,
+ AddressByteSize);
}
private:
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
index 698c77d5bf84c..99c6567457bf5 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
@@ -102,7 +102,7 @@ struct YamlContext {
if (Iter != RegNameToRegNo.end())
return Iter->second;
ErrorStream << "No register with name '" << RegName << "'\n";
- return None;
+ return std::nullopt;
}
private:
diff --git a/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp b/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
index 476954668b5ab..be131d41b3e76 100644
--- a/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
+++ b/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
@@ -191,12 +191,12 @@ getImageBaseAddress(const object::ELFFile<ELFT> &ELFFile) {
auto PhdrRangeOrErr = ELFFile.program_headers();
if (!PhdrRangeOrErr) {
consumeError(PhdrRangeOrErr.takeError());
- return llvm::None;
+ return std::nullopt;
}
for (const typename ELFT::Phdr &Phdr : *PhdrRangeOrErr)
if (Phdr.p_type == ELF::PT_LOAD)
return (uint64_t)Phdr.p_vaddr;
- return llvm::None;
+ return std::nullopt;
}
/// Determine the virtual address that is considered the base address of mach-o
@@ -222,7 +222,7 @@ getImageBaseAddress(const object::MachOObjectFile *MachO) {
return SLC.vmaddr;
}
}
- return llvm::None;
+ return std::nullopt;
}
/// Determine the virtual address that is considered the base address of an
@@ -248,7 +248,7 @@ static llvm::Optional<uint64_t> getImageBaseAddress(object::ObjectFile &Obj) {
return getImageBaseAddress(ELFObj->getELFFile());
else if (const auto *ELFObj = dyn_cast<object::ELF64BEObjectFile>(&Obj))
return getImageBaseAddress(ELFObj->getELFFile());
- return llvm::None;
+ return std::nullopt;
}
static llvm::Error handleObjectFile(ObjectFile &Obj,
diff --git a/llvm/tools/llvm-ifs/llvm-ifs.cpp b/llvm/tools/llvm-ifs/llvm-ifs.cpp
index 646d4df68bf12..d704422163241 100644
--- a/llvm/tools/llvm-ifs/llvm-ifs.cpp
+++ b/llvm/tools/llvm-ifs/llvm-ifs.cpp
@@ -309,7 +309,7 @@ static DriverConfig parseArgs(int argc, char *const *argv) {
Config.InputFormat = StringSwitch<Optional<FileFormat>>(A->getValue())
.Case("IFS", FileFormat::IFS)
.Case("ELF", FileFormat::ELF)
- .Default(None);
+ .Default(std::nullopt);
if (!Config.InputFormat)
fatalError(Twine("invalid argument '") + A->getValue());
}
@@ -323,7 +323,7 @@ static DriverConfig parseArgs(int argc, char *const *argv) {
.Case("IFS", FileFormat::IFS)
.Case("ELF", FileFormat::ELF)
.Case("TBD", FileFormat::TBD)
- .Default(None);
+ .Default(std::nullopt);
if (!Config.OutputFormat)
OptionNotFound("--output-format", A->getValue());
}
@@ -344,7 +344,7 @@ static DriverConfig parseArgs(int argc, char *const *argv) {
StringSwitch<Optional<IFSEndiannessType>>(A->getValue())
.Case("little", IFSEndiannessType::Little)
.Case("big", IFSEndiannessType::Big)
- .Default(None);
+ .Default(std::nullopt);
if (!Config.OverrideEndianness)
OptionNotFound("--endianness", A->getValue());
}
diff --git a/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp b/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
index d3760a9ac30f9..9870bf25f13f6 100644
--- a/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
+++ b/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
@@ -136,7 +136,7 @@ static Expected<std::string> searchForFile(const Twine &FileName) {
GlobalDependencyInfo->addMissingInput(Path);
}
- return None;
+ return std::nullopt;
};
Optional<std::string> Found = FindLib(LibrarySearchDirs);
diff --git a/llvm/tools/llvm-lipo/llvm-lipo.cpp b/llvm/tools/llvm-lipo/llvm-lipo.cpp
index c1eef69145671..0537f071d6fa9 100644
--- a/llvm/tools/llvm-lipo/llvm-lipo.cpp
+++ b/llvm/tools/llvm-lipo/llvm-lipo.cpp
@@ -182,7 +182,7 @@ static Config parseLipoOptions(ArrayRef<const char *> ArgsArr) {
reportError("unknown argument '" + Arg->getAsString(InputArgs) + "'");
for (auto *Arg : InputArgs.filtered(LIPO_INPUT))
- C.InputFiles.push_back({None, Arg->getValue()});
+ C.InputFiles.push_back({std::nullopt, Arg->getValue()});
for (auto *Arg : InputArgs.filtered(LIPO_arch)) {
validateArchitectureName(Arg->getValue(0));
assert(Arg->getValue(1) && "file_name is missing");
diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp
index d2c90dd454c50..b19f9ee722fb8 100644
--- a/llvm/tools/llvm-nm/llvm-nm.cpp
+++ b/llvm/tools/llvm-nm/llvm-nm.cpp
@@ -651,7 +651,7 @@ static Optional<std::string> demangle(StringRef Name) {
std::string Demangled;
if (nonMicrosoftDemangle(Name.str().c_str(), Demangled))
return Demangled;
- return None;
+ return std::nullopt;
}
static Optional<std::string> demangleXCOFF(StringRef Name) {
@@ -662,7 +662,7 @@ static Optional<std::string> demangleXCOFF(StringRef Name) {
Optional<std::string> DemangledName = demangle(Name);
if (DemangledName)
return "." + *DemangledName;
- return None;
+ return std::nullopt;
}
static Optional<std::string> demangleMachO(StringRef Name) {
diff --git a/llvm/tools/llvm-objdump/SourcePrinter.cpp b/llvm/tools/llvm-objdump/SourcePrinter.cpp
index c8ea6b543245a..d0b80fde43869 100644
--- a/llvm/tools/llvm-objdump/SourcePrinter.cpp
+++ b/llvm/tools/llvm-objdump/SourcePrinter.cpp
@@ -31,7 +31,7 @@ unsigned getInstStartColumn(const MCSubtargetInfo &STI) {
}
bool LiveVariable::liveAtAddress(object::SectionedAddress Addr) {
- if (LocExpr.Range == None)
+ if (LocExpr.Range == std::nullopt)
return false;
return LocExpr.Range->SectionIndex == Addr.SectionIndex &&
LocExpr.Range->LowPC <= Addr.Address &&
diff --git a/llvm/tools/llvm-objdump/XCOFFDump.cpp b/llvm/tools/llvm-objdump/XCOFFDump.cpp
index dd1570e1736c3..116953269128d 100644
--- a/llvm/tools/llvm-objdump/XCOFFDump.cpp
+++ b/llvm/tools/llvm-objdump/XCOFFDump.cpp
@@ -49,11 +49,11 @@ objdump::getXCOFFSymbolCsectSMC(const XCOFFObjectFile &Obj,
const XCOFFSymbolRef SymRef = Obj.toSymbolRef(Sym.getRawDataRefImpl());
if (!SymRef.isCsectSymbol())
- return None;
+ return std::nullopt;
auto CsectAuxEntOrErr = SymRef.getXCOFFCsectAuxRef();
if (!CsectAuxEntOrErr)
- return None;
+ return std::nullopt;
return CsectAuxEntOrErr.get().getStorageMappingClass();
}
@@ -63,11 +63,11 @@ objdump::getXCOFFSymbolContainingSymbolRef(const XCOFFObjectFile &Obj,
const SymbolRef &Sym) {
const XCOFFSymbolRef SymRef = Obj.toSymbolRef(Sym.getRawDataRefImpl());
if (!SymRef.isCsectSymbol())
- return None;
+ return std::nullopt;
Expected<XCOFFCsectAuxRef> CsectAuxEntOrErr = SymRef.getXCOFFCsectAuxRef();
if (!CsectAuxEntOrErr || !CsectAuxEntOrErr.get().isLabel())
- return None;
+ return std::nullopt;
uint32_t Idx =
static_cast<uint32_t>(CsectAuxEntOrErr.get().getSectionOrLength());
DataRefImpl DRI;
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 0757e3bffa42c..7b95642bdd83f 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -869,7 +869,7 @@ static Optional<SectionRef> getWasmCodeSection(const WasmObjectFile &Obj) {
if (Section.Type == wasm::WASM_SEC_CODE)
return SecI;
}
- return None;
+ return std::nullopt;
}
static void
@@ -1101,7 +1101,7 @@ static SymbolInfoTy createDummySymbolInfo(const ObjectFile &Obj,
const uint64_t Addr, StringRef &Name,
uint8_t Type) {
if (Obj.isXCOFF() && SymbolDescription)
- return SymbolInfoTy(Addr, Name, None, None, false);
+ return SymbolInfoTy(Addr, Name, std::nullopt, std::nullopt, false);
else
return SymbolInfoTy(Addr, Name, Type);
}
@@ -1276,14 +1276,14 @@ static Optional<OwningBinary<Binary>>
fetchBinaryByBuildID(const ObjectFile &Obj) {
Optional<object::BuildIDRef> BuildID = getBuildID(&Obj);
if (!BuildID)
- return None;
+ return std::nullopt;
Optional<std::string> Path = BIDFetcher->fetch(*BuildID);
if (!Path)
- return None;
+ return std::nullopt;
Expected<OwningBinary<Binary>> DebugBinary = createBinary(*Path);
if (!DebugBinary) {
reportWarning(toString(DebugBinary.takeError()), *Path);
- return None;
+ return std::nullopt;
}
return std::move(*DebugBinary);
}
@@ -1423,13 +1423,12 @@ static void disassembleObject(const Target *TheTarget, ObjectFile &Obj,
LLVM_DEBUG(LVP.dump());
std::unordered_map<uint64_t, BBAddrMap> AddrToBBAddrMap;
- auto ReadBBAddrMap = [&](Optional<unsigned> SectionIndex = None) {
+ auto ReadBBAddrMap = [&](Optional<unsigned> SectionIndex = std::nullopt) {
AddrToBBAddrMap.clear();
if (const auto *Elf = dyn_cast<ELFObjectFileBase>(&Obj)) {
auto BBAddrMapsOrErr = Elf->readBBAddrMap(SectionIndex);
if (!BBAddrMapsOrErr)
- reportWarning(toString(BBAddrMapsOrErr.takeError()),
- Obj.getFileName());
+ reportWarning(toString(BBAddrMapsOrErr.takeError()), Obj.getFileName());
for (auto &FunctionBBAddrMap : *BBAddrMapsOrErr)
AddrToBBAddrMap.emplace(FunctionBBAddrMap.Addr,
std::move(FunctionBBAddrMap));
diff --git a/llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp b/llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp
index 13a5f6ea6fe73..ef9eb29fd6e60 100644
--- a/llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp
+++ b/llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp
@@ -131,7 +131,7 @@ Optional<uint32_t> ExplainOutputStyle::getPdbBlockStreamIndex() const {
continue;
return Entry.index();
}
- return None;
+ return std::nullopt;
}
bool ExplainOutputStyle::explainPdbBlockStatus() {
diff --git a/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp b/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
index 3859558b32ff4..214cc07a7e93b 100644
--- a/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
+++ b/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
@@ -865,7 +865,7 @@ static void yamlToPdb(StringRef Path) {
AppendingTypeTableBuilder TS(Allocator);
for (const auto &R : Tpi.Records) {
CVType Type = R.toCodeViewRecord(TS);
- TpiBuilder.addTypeRecord(Type.RecordData, None);
+ TpiBuilder.addTypeRecord(Type.RecordData, std::nullopt);
}
const auto &Ipi = YamlObj.IpiStream.value_or(DefaultIpiStream);
@@ -873,7 +873,7 @@ static void yamlToPdb(StringRef Path) {
IpiBuilder.setVersionHeader(Ipi.Version);
for (const auto &R : Ipi.Records) {
CVType Type = R.toCodeViewRecord(TS);
- IpiBuilder.addTypeRecord(Type.RecordData, None);
+ IpiBuilder.addTypeRecord(Type.RecordData, std::nullopt);
}
Builder.getStringTableBuilder().setStrings(*Strings.strings());
@@ -1353,10 +1353,10 @@ static void mergePdbs() {
auto &DestTpi = Builder.getTpiBuilder();
auto &DestIpi = Builder.getIpiBuilder();
MergedTpi.ForEachRecord([&DestTpi](TypeIndex TI, const CVType &Type) {
- DestTpi.addTypeRecord(Type.RecordData, None);
+ DestTpi.addTypeRecord(Type.RecordData, std::nullopt);
});
MergedIpi.ForEachRecord([&DestIpi](TypeIndex TI, const CVType &Type) {
- DestIpi.addTypeRecord(Type.RecordData, None);
+ DestIpi.addTypeRecord(Type.RecordData, std::nullopt);
});
Builder.getInfoBuilder().addFeature(PdbRaw_FeatureSig::VC140);
diff --git a/llvm/tools/llvm-profgen/PerfReader.cpp b/llvm/tools/llvm-profgen/PerfReader.cpp
index 0f27429f9bb63..14bc04b0543a0 100644
--- a/llvm/tools/llvm-profgen/PerfReader.cpp
+++ b/llvm/tools/llvm-profgen/PerfReader.cpp
@@ -396,7 +396,7 @@ PerfInputFile PerfScriptReader::convertPerfDataToTrace(
StringRef ScriptSampleArgs[] = {PerfPath, "script", "--show-mmap-events",
"-F", "ip,brstack", "--pid",
PIDs, "-i", PerfData};
- sys::ExecuteAndWait(PerfPath, ScriptSampleArgs, llvm::None, Redirects);
+ sys::ExecuteAndWait(PerfPath, ScriptSampleArgs, std::nullopt, Redirects);
return {PerfTraceFile, PerfFormat::PerfScript, PerfContent::UnknownContent};
}
diff --git a/llvm/tools/llvm-readobj/ARMEHABIPrinter.h b/llvm/tools/llvm-readobj/ARMEHABIPrinter.h
index d641b172eb91a..609104ae338af 100644
--- a/llvm/tools/llvm-readobj/ARMEHABIPrinter.h
+++ b/llvm/tools/llvm-readobj/ARMEHABIPrinter.h
@@ -502,7 +502,7 @@ void PrinterContext<ET>::PrintExceptionTable(const Elf_Shdr &EHT,
: PREL31(Word, EHT.sh_addr + TableEntryOffset);
SW.printHex("PersonalityRoutineAddress", Address);
Optional<unsigned> SecIndex =
- IsRelocatable ? Optional<unsigned>(EHT.sh_link) : None;
+ IsRelocatable ? Optional<unsigned>(EHT.sh_link) : std::nullopt;
if (ErrorOr<StringRef> Name = FunctionAtAddress(Address, SecIndex))
SW.printString("PersonalityRoutineName", *Name);
}
@@ -575,7 +575,7 @@ void PrinterContext<ET>::PrintIndexTable(unsigned SectionIndex,
// the sh_link field is not reliable, because we have one .ARM.exidx section
// normally, but might have many code sections.
Optional<unsigned> SecIndex =
- IsRelocatable ? Optional<unsigned>(IT->sh_link) : None;
+ IsRelocatable ? Optional<unsigned>(IT->sh_link) : std::nullopt;
if (ErrorOr<StringRef> Name = FunctionAtAddress(Address, SecIndex))
SW.printString("FunctionName", *Name);
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 7f662669e9d53..4ed62f6f2d2ad 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -942,7 +942,7 @@ ELFDumper<ELFT>::getSymbolSectionIndex(const Elf_Sym &Symbol, unsigned SymIndex,
return Ndx;
auto CreateErr = [&](const Twine &Name,
- std::optional<unsigned> Offset = None) {
+ std::optional<unsigned> Offset = std::nullopt) {
std::string Desc;
if (Offset)
Desc = (Name + "+0x" + Twine::utohexstr(*Offset)).str();
@@ -4640,7 +4640,7 @@ void GNUELFDumper<ELFT>::printVersionSymbolSection(const Elf_Shdr *Sec) {
bool IsDefault;
Expected<StringRef> NameOrErr = this->Obj.getSymbolVersionByIndex(
- Ndx, IsDefault, *VersionMap, /*IsSymHidden=*/None);
+ Ndx, IsDefault, *VersionMap, /*IsSymHidden=*/std::nullopt);
if (!NameOrErr) {
this->reportUniqueWarning("unable to get a version for entry " +
Twine(I) + " of " + this->describe(*Sec) +
@@ -5233,11 +5233,11 @@ template <typename ELFT>
static Optional<FreeBSDNote>
getFreeBSDNote(uint32_t NoteType, ArrayRef<uint8_t> Desc, bool IsCore) {
if (IsCore)
- return None; // No pretty-printing yet.
+ return std::nullopt; // No pretty-printing yet.
switch (NoteType) {
case ELF::NT_FREEBSD_ABI_TAG:
if (Desc.size() != 4)
- return None;
+ return std::nullopt;
return FreeBSDNote{
"ABI tag",
utostr(support::endian::read32<ELFT::TargetEndianness>(Desc.data()))};
@@ -5245,7 +5245,7 @@ getFreeBSDNote(uint32_t NoteType, ArrayRef<uint8_t> Desc, bool IsCore) {
return FreeBSDNote{"Arch tag", toStringRef(Desc).str()};
case ELF::NT_FREEBSD_FEATURE_CTL: {
if (Desc.size() != 4)
- return None;
+ return std::nullopt;
unsigned Value =
support::endian::read32<ELFT::TargetEndianness>(Desc.data());
std::string FlagsStr;
@@ -5258,7 +5258,7 @@ getFreeBSDNote(uint32_t NoteType, ArrayRef<uint8_t> Desc, bool IsCore) {
return FreeBSDNote{"Feature flags", OS.str()};
}
default:
- return None;
+ return std::nullopt;
}
}
@@ -5725,7 +5725,7 @@ static void printNotesHelper(
const typename ELFT::Phdr &P = (*PhdrsOrErr)[I];
if (P.p_type != PT_NOTE)
continue;
- StartNotesFn(/*SecName=*/None, P.p_offset, P.p_filesz);
+ StartNotesFn(/*SecName=*/std::nullopt, P.p_offset, P.p_filesz);
Error Err = Error::success();
size_t Index = 0;
for (const typename ELFT::Note Note : Obj.notes(P, Err)) {
@@ -6186,8 +6186,8 @@ void ELFDumper<ELFT>::printNonRelocatableStackSizes(
break;
}
uint64_t SymValue = Data.getAddress(&Offset);
- if (!printFunctionStackSize(SymValue, /*FunctionSec=*/None, Sec, Data,
- &Offset))
+ if (!printFunctionStackSize(SymValue, /*FunctionSec=*/std::nullopt, Sec,
+ Data, &Offset))
break;
}
}
@@ -6742,7 +6742,7 @@ void LLVMELFDumper<ELFT>::printSymbolSection(
return StringRef("Common");
if (Symbol.isReserved() && Symbol.st_shndx != SHN_XINDEX)
return StringRef("Reserved");
- return None;
+ return std::nullopt;
};
if (Optional<StringRef> Type = GetSectionSpecialType()) {
diff --git a/llvm/tools/llvm-readobj/MachODumper.cpp b/llvm/tools/llvm-readobj/MachODumper.cpp
index 4931ab575bb28..6ea1c500260eb 100644
--- a/llvm/tools/llvm-readobj/MachODumper.cpp
+++ b/llvm/tools/llvm-readobj/MachODumper.cpp
@@ -634,7 +634,7 @@ bool MachODumper::compareSymbolsByType(SymbolRef LHS, SymbolRef RHS) const {
return getSymbolType(LHS) < getSymbolType(RHS);
}
-void MachODumper::printSymbols() { printSymbols(None); }
+void MachODumper::printSymbols() { printSymbols(std::nullopt); }
void MachODumper::printSymbols(Optional<SymbolComparator> SymComp) {
ListScope Group(W, "Symbols");
diff --git a/llvm/tools/llvm-readobj/XCOFFDumper.cpp b/llvm/tools/llvm-readobj/XCOFFDumper.cpp
index fa9b5fe8c497a..2556f860fb50c 100644
--- a/llvm/tools/llvm-readobj/XCOFFDumper.cpp
+++ b/llvm/tools/llvm-readobj/XCOFFDumper.cpp
@@ -601,7 +601,7 @@ static void printUnexpectedRawAuxEnt(ScopedPrinter &W, uintptr_t AuxAddress) {
ArrayRef<uint8_t>(
reinterpret_cast<const uint8_t *>(AuxAddress),
XCOFF::SymbolTableEntrySize),
- None, XCOFF::SymbolTableEntrySize)
+ std::nullopt, XCOFF::SymbolTableEntrySize)
<< "\n";
}
diff --git a/llvm/tools/llvm-reduce/TestRunner.cpp b/llvm/tools/llvm-reduce/TestRunner.cpp
index e413f589eb22c..fe905b38edfdd 100644
--- a/llvm/tools/llvm-reduce/TestRunner.cpp
+++ b/llvm/tools/llvm-reduce/TestRunner.cpp
@@ -49,9 +49,9 @@ int TestRunner::run(StringRef Filename) const {
for (int i = 0; i < 3; ++i)
Redirects.push_back(Empty);
}
- int Result =
- sys::ExecuteAndWait(TestName, ProgramArgs, /*Env=*/None, Redirects,
- /*SecondsToWait=*/0, /*MemoryLimit=*/0, &ErrMsg);
+ int Result = sys::ExecuteAndWait(
+ TestName, ProgramArgs, /*Env=*/std::nullopt, Redirects,
+ /*SecondsToWait=*/0, /*MemoryLimit=*/0, &ErrMsg);
if (Result < 0) {
Error E = make_error<StringError>("Error running interesting-ness test: " +
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceOpcodes.cpp b/llvm/tools/llvm-reduce/deltas/ReduceOpcodes.cpp
index 75a00ae22ee41..4acc77bb883f4 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceOpcodes.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceOpcodes.cpp
@@ -27,7 +27,7 @@ static bool shouldIgnoreArgument(const Value *V) {
static Value *replaceIntrinsic(Module &M, IntrinsicInst *II,
Intrinsic::ID NewIID,
- ArrayRef<Type *> Tys = None) {
+ ArrayRef<Type *> Tys = std::nullopt) {
Function *NewFunc = Intrinsic::getDeclaration(&M, NewIID, Tys);
II->setCalledFunction(NewFunc);
return II;
diff --git a/llvm/tools/llvm-reduce/deltas/RunIRPasses.cpp b/llvm/tools/llvm-reduce/deltas/RunIRPasses.cpp
index 00710476b6139..51862393f3fe6 100644
--- a/llvm/tools/llvm-reduce/deltas/RunIRPasses.cpp
+++ b/llvm/tools/llvm-reduce/deltas/RunIRPasses.cpp
@@ -30,7 +30,7 @@ static void runPasses(Oracle &O, Module &Program) {
PassInstrumentationCallbacks PIC;
PIC.registerShouldRunOptionalPassCallback(
[&](StringRef, Any) { return !O.shouldKeep(); });
- PassBuilder PB(nullptr, PipelineTuningOptions(), None, &PIC);
+ PassBuilder PB(nullptr, PipelineTuningOptions(), std::nullopt, &PIC);
PB.registerModuleAnalyses(MAM);
PB.registerCGSCCAnalyses(CGAM);
diff --git a/llvm/tools/llvm-sim/llvm-sim.cpp b/llvm/tools/llvm-sim/llvm-sim.cpp
index 2b717d72e48a2..7b61ad748c9cb 100644
--- a/llvm/tools/llvm-sim/llvm-sim.cpp
+++ b/llvm/tools/llvm-sim/llvm-sim.cpp
@@ -47,7 +47,7 @@ getPositionInModule(const Instruction *I,
assert(I && "Instruction is nullptr!");
DenseMap<Instruction *, unsigned>::const_iterator It = LLVMInstNum.find(I);
if (It == LLVMInstNum.end())
- return None;
+ return std::nullopt;
return It->second;
}
diff --git a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
index a59364ade11ae..73750c2690269 100644
--- a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
+++ b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
@@ -260,7 +260,7 @@ static void symbolizeInput(const opt::InputArgList &Args,
uint64_t Offset = 0;
if (!parseCommand(Args.getLastArgValue(OPT_obj_EQ), IsAddr2Line,
StringRef(InputString), Cmd, ModuleName, BuildID, Offset)) {
- Printer.printInvalidCommand({ModuleName, None}, InputString);
+ Printer.printInvalidCommand({ModuleName, std::nullopt}, InputString);
return;
}
bool ShouldInline = Args.hasFlag(OPT_inlines, OPT_no_inlines, !IsAddr2Line);
@@ -348,8 +348,8 @@ static Optional<bool> parseColorArg(const opt::InputArgList &Args) {
return StringSwitch<Optional<bool>>(A->getValue())
.Case("always", true)
.Case("never", false)
- .Case("auto", None);
- return None;
+ .Case("auto", std::nullopt);
+ return std::nullopt;
}
static object::BuildID parseBuildIDArg(const opt::InputArgList &Args, int ID) {
diff --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp
index 1402565e27cf1..f50b6ac5ae3dc 100644
--- a/llvm/tools/lto/lto.cpp
+++ b/llvm/tools/lto/lto.cpp
@@ -396,7 +396,7 @@ bool lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model model) {
unwrap(cg)->setCodePICModel(Reloc::DynamicNoPIC);
return false;
case LTO_CODEGEN_PIC_MODEL_DEFAULT:
- unwrap(cg)->setCodePICModel(None);
+ unwrap(cg)->setCodePICModel(std::nullopt);
return false;
}
sLastErrorString = "Unknown PIC model";
@@ -673,7 +673,7 @@ lto_bool_t thinlto_codegen_set_pic_model(thinlto_code_gen_t cg,
unwrap(cg)->setCodePICModel(Reloc::DynamicNoPIC);
return false;
case LTO_CODEGEN_PIC_MODEL_DEFAULT:
- unwrap(cg)->setCodePICModel(None);
+ unwrap(cg)->setCodePICModel(std::nullopt);
return false;
}
sLastErrorString = "Unknown PIC model";
diff --git a/llvm/tools/obj2yaml/dwarf2yaml.cpp b/llvm/tools/obj2yaml/dwarf2yaml.cpp
index 24267053e287c..347fb3dbf0239 100644
--- a/llvm/tools/obj2yaml/dwarf2yaml.cpp
+++ b/llvm/tools/obj2yaml/dwarf2yaml.cpp
@@ -178,7 +178,7 @@ dumpPubSection(const DWARFContext &DCtx, const DWARFSection &Section,
[](Error Err) { consumeError(std::move(Err)); });
ArrayRef<DWARFDebugPubTable::Set> Sets = Table.getData();
if (Sets.empty())
- return None;
+ return std::nullopt;
// FIXME: Currently, obj2yaml only supports dumping the first pubtable.
Y.Format = Sets[0].Format;
diff --git a/llvm/tools/obj2yaml/elf2yaml.cpp b/llvm/tools/obj2yaml/elf2yaml.cpp
index e4def747fb5bf..f64e479d51a7e 100644
--- a/llvm/tools/obj2yaml/elf2yaml.cpp
+++ b/llvm/tools/obj2yaml/elf2yaml.cpp
@@ -550,7 +550,7 @@ Optional<DWARFYAML::Data> ELFDumper<ELFT>::dumpDWARFSections(
}
if (DWARF.getNonEmptySectionNames().empty())
- return None;
+ return std::nullopt;
return DWARF;
}
diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp
index 769ed96301df3..39a998ea0e470 100644
--- a/llvm/tools/opt/NewPMDriver.cpp
+++ b/llvm/tools/opt/NewPMDriver.cpp
@@ -350,7 +350,7 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
P = PGOOptions("", "", "", PGOOptions::NoAction, PGOOptions::NoCSAction,
DebugInfoForProfiling, PseudoProbeForProfiling);
else
- P = None;
+ P = std::nullopt;
}
if (CSPGOKindFlag != NoCSPGO) {
if (P && (P->Action == PGOOptions::IRInstr ||
diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index e06481db89fa2..556344265baf1 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/tools/opt/opt.cpp
@@ -515,7 +515,7 @@ int main(int argc, char **argv) {
// Load the input module...
auto SetDataLayout = [](StringRef) -> Optional<std::string> {
if (ClDataLayout.empty())
- return None;
+ return std::nullopt;
return ClDataLayout;
};
std::unique_ptr<Module> M;
More information about the llvm-commits
mailing list