[clang] eeee3fe - [Basic] Use std::nullopt instead of None (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sat Dec 3 11:34:39 PST 2022
Author: Kazu Hirata
Date: 2022-12-03T11:34:27-08:00
New Revision: eeee3fee37a65d68ebbfcb6e78b6b2e018180b0c
URL: https://github.com/llvm/llvm-project/commit/eeee3fee37a65d68ebbfcb6e78b6b2e018180b0c
DIFF: https://github.com/llvm/llvm-project/commit/eeee3fee37a65d68ebbfcb6e78b6b2e018180b0c.diff
LOG: [Basic] 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:
clang/include/clang/Basic/DirectoryEntry.h
clang/include/clang/Basic/FileEntry.h
clang/include/clang/Basic/SourceManager.h
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/DarwinSDKInfo.cpp
clang/lib/Basic/DiagnosticIDs.cpp
clang/lib/Basic/FileManager.cpp
clang/lib/Basic/ProfileList.cpp
clang/lib/Basic/SourceManager.cpp
clang/lib/Basic/TargetID.cpp
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Basic/Targets/ARC.h
clang/lib/Basic/Targets/AVR.h
clang/lib/Basic/Targets/BPF.h
clang/lib/Basic/Targets/DirectX.h
clang/lib/Basic/Targets/Lanai.h
clang/lib/Basic/Targets/Le64.h
clang/lib/Basic/Targets/M68k.cpp
clang/lib/Basic/Targets/MSP430.h
clang/lib/Basic/Targets/NVPTX.h
clang/lib/Basic/Targets/PNaCl.cpp
clang/lib/Basic/Targets/PNaCl.h
clang/lib/Basic/Targets/RISCV.cpp
clang/lib/Basic/Targets/SPIR.h
clang/lib/Basic/Targets/Sparc.h
clang/lib/Basic/Targets/SystemZ.h
clang/lib/Basic/Targets/TCE.h
clang/lib/Basic/Targets/WebAssembly.h
clang/lib/Basic/Targets/X86.cpp
clang/lib/Basic/Targets/X86.h
clang/lib/Basic/Targets/XCore.h
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/DirectoryEntry.h b/clang/include/clang/Basic/DirectoryEntry.h
index 46121e491f4f6..c8e10fb88b963 100644
--- a/clang/include/clang/Basic/DirectoryEntry.h
+++ b/clang/include/clang/Basic/DirectoryEntry.h
@@ -272,7 +272,7 @@ class OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr
OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr &
operator=(std::nullopt_t) {
- Optional<DirectoryEntryRef>::operator=(None);
+ Optional<DirectoryEntryRef>::operator=(std::nullopt);
return *this;
}
OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr &operator=(DirectoryEntryRef Ref) {
diff --git a/clang/include/clang/Basic/FileEntry.h b/clang/include/clang/Basic/FileEntry.h
index b001422a84404..3a2b9ffab0355 100644
--- a/clang/include/clang/Basic/FileEntry.h
+++ b/clang/include/clang/Basic/FileEntry.h
@@ -315,7 +315,7 @@ class OptionalFileEntryRefDegradesToFileEntryPtr
: Optional<FileEntryRef>(MaybeRef) {}
OptionalFileEntryRefDegradesToFileEntryPtr &operator=(std::nullopt_t) {
- Optional<FileEntryRef>::operator=(None);
+ Optional<FileEntryRef>::operator=(std::nullopt);
return *this;
}
OptionalFileEntryRefDegradesToFileEntryPtr &operator=(FileEntryRef Ref) {
diff --git a/clang/include/clang/Basic/SourceManager.h b/clang/include/clang/Basic/SourceManager.h
index 8ab519f8431f0..b482b6a271c21 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -179,8 +179,9 @@ class alignas(8) ContentCache {
mutable unsigned IsBufferInvalid : 1;
ContentCache()
- : OrigEntry(None), ContentsEntry(nullptr), BufferOverridden(false),
- IsFileVolatile(false), IsTransient(false), IsBufferInvalid(false) {}
+ : OrigEntry(std::nullopt), ContentsEntry(nullptr),
+ BufferOverridden(false), IsFileVolatile(false), IsTransient(false),
+ IsBufferInvalid(false) {}
ContentCache(FileEntryRef Ent) : ContentCache(Ent, Ent) {}
@@ -236,7 +237,7 @@ class alignas(8) ContentCache {
llvm::Optional<llvm::MemoryBufferRef> getBufferIfLoaded() const {
if (Buffer)
return Buffer->getMemBufferRef();
- return None;
+ return std::nullopt;
}
/// Return a StringRef to the source buffer data, only if it has already
@@ -244,7 +245,7 @@ class alignas(8) ContentCache {
llvm::Optional<StringRef> getBufferDataIfLoaded() const {
if (Buffer)
return Buffer->getBuffer();
- return None;
+ return std::nullopt;
}
/// Set the buffer.
@@ -1025,7 +1026,7 @@ class SourceManager : public RefCountedBase<SourceManager> {
if (auto *Entry = getSLocEntryForFile(FID))
return Entry->getFile().getContentCache().getBufferOrNone(
Diag, getFileManager(), Loc);
- return None;
+ return std::nullopt;
}
/// Return the buffer for the specified FileID.
@@ -1050,7 +1051,7 @@ class SourceManager : public RefCountedBase<SourceManager> {
Optional<FileEntryRef> getFileEntryRefForID(FileID FID) const {
if (auto *Entry = getSLocEntryForFile(FID))
return Entry->getFile().getContentCache().OrigEntry;
- return None;
+ return std::nullopt;
}
/// Returns the filename for the provided FileID, unless it's a built-in
diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h
index f010c559dc3e4..20813d91dfada 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -956,7 +956,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
/// Returns target-specific min and max values VScale_Range.
virtual Optional<std::pair<unsigned, unsigned>>
getVScaleRange(const LangOptions &LangOpts) const {
- return None;
+ return std::nullopt;
}
/// The __builtin_clz* and __builtin_ctz* built-in
/// functions are specified to have undefined results for zero inputs, but
@@ -1181,7 +1181,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
/// Replace some escaped characters with another string based on
/// target-specific rules
virtual llvm::Optional<std::string> handleAsmEscapedChar(char C) const {
- return llvm::None;
+ return std::nullopt;
}
/// Returns a string of target-specific clobbers, in LLVM format.
@@ -1199,7 +1199,9 @@ class TargetInfo : public virtual TransferrableTargetInfo,
}
/// Returns the target ID if supported.
- virtual llvm::Optional<std::string> getTargetID() const { return llvm::None; }
+ virtual llvm::Optional<std::string> getTargetID() const {
+ return std::nullopt;
+ }
const char *getDataLayoutString() const {
assert(!DataLayoutString.empty() && "Uninitialized DataLayout!");
@@ -1434,7 +1436,9 @@ class TargetInfo : public virtual TransferrableTargetInfo,
// Get the cache line size of a given cpu. This method switches over
// the given cpu and returns "None" if the CPU is not found.
- virtual Optional<unsigned> getCPUCacheLineSize() const { return None; }
+ virtual Optional<unsigned> getCPUCacheLineSize() const {
+ return std::nullopt;
+ }
// Returns maximal number of args passed in registers.
unsigned getRegParmMax() const {
@@ -1651,7 +1655,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
/// \returns Otherwise return None and no conversion will be emitted in the
/// DWARF.
virtual Optional<unsigned> getDWARFAddressSpace(unsigned AddressSpace) const {
- return None;
+ return std::nullopt;
}
/// \returns The version of the SDK which was used during the compilation if
@@ -1704,7 +1708,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
virtual ArrayRef<const char *> getGCCRegNames() const = 0;
virtual ArrayRef<GCCRegAlias> getGCCRegAliases() const = 0;
virtual ArrayRef<AddlRegName> getGCCAddlRegNames() const {
- return None;
+ return std::nullopt;
}
private:
diff --git a/clang/lib/Basic/DarwinSDKInfo.cpp b/clang/lib/Basic/DarwinSDKInfo.cpp
index 64bcb45a4cd85..ca2412008c03a 100644
--- a/clang/lib/Basic/DarwinSDKInfo.cpp
+++ b/clang/lib/Basic/DarwinSDKInfo.cpp
@@ -30,7 +30,7 @@ Optional<VersionTuple> DarwinSDKInfo::RelatedTargetVersionMapping::map(
if (Key.getMinor())
return map(VersionTuple(Key.getMajor()), MinimumValue, MaximumValue);
// If this a major only key, return None for a missing entry.
- return None;
+ return std::nullopt;
}
Optional<DarwinSDKInfo::RelatedTargetVersionMapping>
@@ -45,7 +45,7 @@ DarwinSDKInfo::RelatedTargetVersionMapping::parseJSON(
llvm::VersionTuple KeyVersion;
llvm::VersionTuple ValueVersion;
if (KeyVersion.tryParse(KV.getFirst()) || ValueVersion.tryParse(*Val))
- return None;
+ return std::nullopt;
Mapping[KeyVersion.normalize()] = ValueVersion;
if (KeyVersion < Min)
Min = KeyVersion;
@@ -56,7 +56,7 @@ DarwinSDKInfo::RelatedTargetVersionMapping::parseJSON(
}
}
if (Mapping.empty())
- return None;
+ return std::nullopt;
return RelatedTargetVersionMapping(
Min, Max, MinValue, MaximumDeploymentTarget, std::move(Mapping));
}
@@ -65,10 +65,10 @@ static Optional<VersionTuple> getVersionKey(const llvm::json::Object &Obj,
StringRef Key) {
auto Value = Obj.getString(Key);
if (!Value)
- return None;
+ return std::nullopt;
VersionTuple Version;
if (Version.tryParse(*Value))
- return None;
+ return std::nullopt;
return Version;
}
@@ -76,11 +76,11 @@ Optional<DarwinSDKInfo>
DarwinSDKInfo::parseDarwinSDKSettingsJSON(const llvm::json::Object *Obj) {
auto Version = getVersionKey(*Obj, "Version");
if (!Version)
- return None;
+ return std::nullopt;
auto MaximumDeploymentVersion =
getVersionKey(*Obj, "MaximumDeploymentTarget");
if (!MaximumDeploymentVersion)
- return None;
+ return std::nullopt;
llvm::DenseMap<OSEnvPair::StorageType, Optional<RelatedTargetVersionMapping>>
VersionMappings;
if (const auto *VM = Obj->getObject("VersionMap")) {
@@ -107,7 +107,7 @@ DarwinSDKInfo::parseDarwinSDKSettingsJSON(const llvm::json::Object *Obj) {
auto VersionMap = RelatedTargetVersionMapping::parseJSON(
*Mapping, *MaximumDeploymentVersion);
if (!VersionMap)
- return None;
+ return std::nullopt;
VersionMappings[OSEnvPair::macOStoMacCatalystPair().Value] =
std::move(VersionMap);
}
@@ -115,7 +115,7 @@ DarwinSDKInfo::parseDarwinSDKSettingsJSON(const llvm::json::Object *Obj) {
auto VersionMap = RelatedTargetVersionMapping::parseJSON(
*Mapping, *MaximumDeploymentVersion);
if (!VersionMap)
- return None;
+ return std::nullopt;
VersionMappings[OSEnvPair::macCatalystToMacOSPair().Value] =
std::move(VersionMap);
}
@@ -134,7 +134,7 @@ clang::parseDarwinSDKInfo(llvm::vfs::FileSystem &VFS, StringRef SDKRootPath) {
VFS.getBufferForFile(Filepath);
if (!File) {
// If the file couldn't be read, assume it just doesn't exist.
- return None;
+ return std::nullopt;
}
Expected<llvm::json::Value> Result =
llvm::json::parse(File.get()->getBuffer());
diff --git a/clang/lib/Basic/DiagnosticIDs.cpp b/clang/lib/Basic/DiagnosticIDs.cpp
index 1695a3c85372f..66f397974af56 100644
--- a/clang/lib/Basic/DiagnosticIDs.cpp
+++ b/clang/lib/Basic/DiagnosticIDs.cpp
@@ -639,14 +639,14 @@ DiagnosticIDs::getGroupForWarningOption(StringRef Name) {
const auto *Found = llvm::partition_point(
OptionTable, [=](const WarningOption &O) { return O.getName() < Name; });
if (Found == std::end(OptionTable) || Found->getName() != Name)
- return llvm::None;
+ return std::nullopt;
return static_cast<diag::Group>(Found - OptionTable);
}
llvm::Optional<diag::Group> DiagnosticIDs::getGroupForDiag(unsigned DiagID) {
if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID))
return static_cast<diag::Group>(Info->getOptionGroupIndex());
- return llvm::None;
+ return std::nullopt;
}
/// getWarningOptionForDiag - Return the lowest-level warning option that
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index 4ef25358ec82f..69ebd3bc078d7 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -474,7 +474,7 @@ llvm::Optional<FileEntryRef> FileManager::getBypassFile(FileEntryRef VF) {
// Stat of the file and return nullptr if it doesn't exist.
llvm::vfs::Status Status;
if (getStatValue(VF.getName(), Status, /*isFile=*/true, /*F=*/nullptr))
- return None;
+ return std::nullopt;
if (!SeenBypassFileEntries)
SeenBypassFileEntries = std::make_unique<
diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp
index 4c17a540aad66..0f049b11f52f6 100644
--- a/clang/lib/Basic/ProfileList.cpp
+++ b/clang/lib/Basic/ProfileList.cpp
@@ -111,7 +111,7 @@ ProfileList::inSection(StringRef Section, StringRef Prefix,
return Forbid;
if (SCL->inSection(Section, Prefix, Query))
return Allow;
- return None;
+ return std::nullopt;
}
llvm::Optional<ProfileList::ExclusionType>
@@ -125,7 +125,7 @@ ProfileList::isFunctionExcluded(StringRef FunctionName,
return Forbid;
if (SCL->inSection(Section, "fun", FunctionName))
return Allow;
- return None;
+ return std::nullopt;
}
llvm::Optional<ProfileList::ExclusionType>
@@ -145,5 +145,5 @@ ProfileList::isFileExcluded(StringRef FileName,
return Forbid;
if (SCL->inSection(Section, "src", FileName))
return Allow;
- return None;
+ return std::nullopt;
}
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp
index a5f673fadf6f8..44ced42c062e4 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -105,11 +105,11 @@ ContentCache::getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM,
// Lazily create the Buffer for ContentCaches that wrap files. If we already
// computed it, just return what we have.
if (IsBufferInvalid)
- return None;
+ return std::nullopt;
if (Buffer)
return Buffer->getMemBufferRef();
if (!ContentsEntry)
- return None;
+ return std::nullopt;
// Start with the assumption that the buffer is invalid to simplify early
// return paths.
@@ -131,7 +131,7 @@ ContentCache::getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM,
Diag.Report(Loc, diag::err_cannot_open_file)
<< ContentsEntry->getName() << BufferOrError.getError().message();
- return None;
+ return std::nullopt;
}
Buffer = std::move(*BufferOrError);
@@ -153,7 +153,7 @@ ContentCache::getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM,
Diag.Report(Loc, diag::err_file_too_large)
<< ContentsEntry->getName();
- return None;
+ return std::nullopt;
}
// Unless this is a named pipe (in which case we can handle a mismatch),
@@ -168,7 +168,7 @@ ContentCache::getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM,
Diag.Report(Loc, diag::err_file_modified)
<< ContentsEntry->getName();
- return None;
+ return std::nullopt;
}
// If the buffer is valid, check to see if it has a UTF Byte Order Mark
@@ -180,7 +180,7 @@ ContentCache::getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM,
if (InvalidBOM) {
Diag.Report(Loc, diag::err_unsupported_bom)
<< InvalidBOM << ContentsEntry->getName();
- return None;
+ return std::nullopt;
}
// Buffer has been validated.
@@ -720,7 +720,7 @@ SourceManager::bypassFileContentsOverride(FileEntryRef File) {
// If the file can't be found in the FS, give up.
if (!BypassFile)
- return None;
+ return std::nullopt;
(void)getOrCreateContentCache(*BypassFile);
return BypassFile;
@@ -735,7 +735,7 @@ SourceManager::getNonBuiltinFilenameForID(FileID FID) const {
if (const SrcMgr::SLocEntry *Entry = getSLocEntryForFile(FID))
if (Entry->getFile().getContentCache().OrigEntry)
return Entry->getFile().getName();
- return None;
+ return std::nullopt;
}
StringRef SourceManager::getBufferData(FileID FID, bool *Invalid) const {
@@ -749,7 +749,7 @@ llvm::Optional<StringRef>
SourceManager::getBufferDataIfLoaded(FileID FID) const {
if (const SrcMgr::SLocEntry *Entry = getSLocEntryForFile(FID))
return Entry->getFile().getContentCache().getBufferDataIfLoaded();
- return None;
+ return std::nullopt;
}
llvm::Optional<StringRef> SourceManager::getBufferDataOrNone(FileID FID) const {
@@ -757,7 +757,7 @@ llvm::Optional<StringRef> SourceManager::getBufferDataOrNone(FileID FID) const {
if (auto B = Entry->getFile().getContentCache().getBufferOrNone(
Diag, getFileManager(), SourceLocation()))
return B->getBuffer();
- return None;
+ return std::nullopt;
}
//===----------------------------------------------------------------------===//
@@ -2230,7 +2230,7 @@ LLVM_DUMP_METHOD void SourceManager::dump() const {
DumpSLocEntry(ID, LoadedSLocEntryTable[Index], NextStart);
NextStart = LoadedSLocEntryTable[Index].getOffset();
} else {
- NextStart = None;
+ NextStart = std::nullopt;
}
}
}
diff --git a/clang/lib/Basic/TargetID.cpp b/clang/lib/Basic/TargetID.cpp
index 6f583cb0c6e72..e50080c5603cb 100644
--- a/clang/lib/Basic/TargetID.cpp
+++ b/clang/lib/Basic/TargetID.cpp
@@ -73,7 +73,7 @@ parseTargetIDWithFormatCheckingOnly(llvm::StringRef TargetID,
auto Split = TargetID.split(':');
Processor = Split.first;
if (Processor.empty())
- return llvm::None;
+ return std::nullopt;
auto Features = Split.second;
if (Features.empty())
@@ -88,12 +88,12 @@ parseTargetIDWithFormatCheckingOnly(llvm::StringRef TargetID,
auto Sign = Splits.first.back();
auto Feature = Splits.first.drop_back();
if (Sign != '+' && Sign != '-')
- return llvm::None;
+ return std::nullopt;
bool IsOn = Sign == '+';
auto Loc = FeatureMap->find(Feature);
// Each feature can only show up at most once in target ID.
if (Loc != FeatureMap->end())
- return llvm::None;
+ return std::nullopt;
(*FeatureMap)[Feature] = IsOn;
Features = Splits.second;
}
@@ -107,11 +107,11 @@ parseTargetID(const llvm::Triple &T, llvm::StringRef TargetID,
parseTargetIDWithFormatCheckingOnly(TargetID, FeatureMap);
if (!OptionalProcessor)
- return llvm::None;
+ return std::nullopt;
llvm::StringRef Processor = getCanonicalProcessorName(T, *OptionalProcessor);
if (Processor.empty())
- return llvm::None;
+ return std::nullopt;
llvm::SmallSet<llvm::StringRef, 4> AllFeatures;
for (auto &&F : getAllPossibleTargetIDFeatures(T, Processor))
@@ -119,7 +119,7 @@ parseTargetID(const llvm::Triple &T, llvm::StringRef TargetID,
for (auto &&F : *FeatureMap)
if (!AllFeatures.count(F.first()))
- return llvm::None;
+ return std::nullopt;
return Processor;
}
@@ -161,7 +161,7 @@ getConflictTargetIDCombination(const std::set<llvm::StringRef> &TargetIDs) {
return std::make_pair(Loc->second.TargetID, ID);
}
}
- return llvm::None;
+ return std::nullopt;
}
bool isCompatibleTargetID(llvm::StringRef Provided, llvm::StringRef Requested) {
diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp
index edc4fdca26378..476bfcf9c41f6 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -506,7 +506,7 @@ AArch64TargetInfo::getVScaleRange(const LangOptions &LangOpts) const {
if (hasFeature("sve"))
return std::pair<unsigned, unsigned>(1, 16);
- return None;
+ return std::nullopt;
}
bool AArch64TargetInfo::hasFeature(StringRef Feature) const {
diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h
index 742bb768ccf0d..e9bda7570f00c 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -119,7 +119,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
ArrayRef<const char *> getGCCRegNames() const override;
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
- return None;
+ return std::nullopt;
}
/// Accepted register names: (n, m is unsigned integer, n < m)
@@ -402,7 +402,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
} else if (AddressSpace == Local) {
return DWARF_Local;
} else {
- return None;
+ return std::nullopt;
}
}
@@ -452,7 +452,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
Optional<std::string> getTargetID() const override {
if (!isAMDGCN(getTriple()))
- return llvm::None;
+ return std::nullopt;
// When -target-cpu is not set, we assume generic code that it is valid
// for all GPU and use an empty string as target ID to represent that.
if (GPUKind == llvm::AMDGPU::GK_NONE)
diff --git a/clang/lib/Basic/Targets/ARC.h b/clang/lib/Basic/Targets/ARC.h
index 5411cd2cd8694..f3640f39b4b47 100644
--- a/clang/lib/Basic/Targets/ARC.h
+++ b/clang/lib/Basic/Targets/ARC.h
@@ -40,7 +40,9 @@ class LLVM_LIBRARY_VISIBILITY ARCTargetInfo : public TargetInfo {
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override;
- ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override {
+ return std::nullopt;
+ }
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::VoidPtrBuiltinVaList;
@@ -58,7 +60,7 @@ class LLVM_LIBRARY_VISIBILITY ARCTargetInfo : public TargetInfo {
}
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
- return None;
+ return std::nullopt;
}
bool validateAsmConstraint(const char *&Name,
diff --git a/clang/lib/Basic/Targets/AVR.h b/clang/lib/Basic/Targets/AVR.h
index 8b42144999751..0b8a05d87aee1 100644
--- a/clang/lib/Basic/Targets/AVR.h
+++ b/clang/lib/Basic/Targets/AVR.h
@@ -61,7 +61,9 @@ class LLVM_LIBRARY_VISIBILITY AVRTargetInfo : public TargetInfo {
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override;
- ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override {
+ return std::nullopt;
+ }
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::VoidPtrBuiltinVaList;
@@ -78,7 +80,7 @@ class LLVM_LIBRARY_VISIBILITY AVRTargetInfo : public TargetInfo {
}
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
- return None;
+ return std::nullopt;
}
ArrayRef<TargetInfo::AddlRegName> getGCCAddlRegNames() const override {
diff --git a/clang/lib/Basic/Targets/BPF.h b/clang/lib/Basic/Targets/BPF.h
index 393a91ff53a51..708bdb4afd837 100644
--- a/clang/lib/Basic/Targets/BPF.h
+++ b/clang/lib/Basic/Targets/BPF.h
@@ -68,7 +68,9 @@ class LLVM_LIBRARY_VISIBILITY BPFTargetInfo : public TargetInfo {
}
bool isValidGCCRegisterName(StringRef Name) const override { return true; }
- ArrayRef<const char *> getGCCRegNames() const override { return None; }
+ ArrayRef<const char *> getGCCRegNames() const override {
+ return std::nullopt;
+ }
bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &Info) const override {
@@ -85,7 +87,7 @@ class LLVM_LIBRARY_VISIBILITY BPFTargetInfo : public TargetInfo {
}
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
- return None;
+ return std::nullopt;
}
bool allowDebugInfoForExternalRef() const override { return true; }
diff --git a/clang/lib/Basic/Targets/DirectX.h b/clang/lib/Basic/Targets/DirectX.h
index 548accf5f349b..06cfa79756f92 100644
--- a/clang/lib/Basic/Targets/DirectX.h
+++ b/clang/lib/Basic/Targets/DirectX.h
@@ -70,11 +70,15 @@ class LLVM_LIBRARY_VISIBILITY DirectXTargetInfo : public TargetInfo {
return Feature == "directx";
}
- ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override {
+ return std::nullopt;
+ }
const char *getClobbers() const override { return ""; }
- ArrayRef<const char *> getGCCRegNames() const override { return None; }
+ ArrayRef<const char *> getGCCRegNames() const override {
+ return std::nullopt;
+ }
bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &info) const override {
@@ -82,7 +86,7 @@ class LLVM_LIBRARY_VISIBILITY DirectXTargetInfo : public TargetInfo {
}
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
- return None;
+ return std::nullopt;
}
BuiltinVaListKind getBuiltinVaListKind() const override {
diff --git a/clang/lib/Basic/Targets/Lanai.h b/clang/lib/Basic/Targets/Lanai.h
index 56c6cced938a7..6ab4aea6ac4ab 100644
--- a/clang/lib/Basic/Targets/Lanai.h
+++ b/clang/lib/Basic/Targets/Lanai.h
@@ -78,7 +78,9 @@ class LLVM_LIBRARY_VISIBILITY LanaiTargetInfo : public TargetInfo {
return TargetInfo::VoidPtrBuiltinVaList;
}
- ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override {
+ return std::nullopt;
+ }
bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &info) const override {
diff --git a/clang/lib/Basic/Targets/Le64.h b/clang/lib/Basic/Targets/Le64.h
index 13a0b04d9f090..6652bcea78dff 100644
--- a/clang/lib/Basic/Targets/Le64.h
+++ b/clang/lib/Basic/Targets/Le64.h
@@ -43,10 +43,12 @@ class LLVM_LIBRARY_VISIBILITY Le64TargetInfo : public TargetInfo {
const char *getClobbers() const override { return ""; }
- ArrayRef<const char *> getGCCRegNames() const override { return None; }
+ ArrayRef<const char *> getGCCRegNames() const override {
+ return std::nullopt;
+ }
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
- return None;
+ return std::nullopt;
}
bool validateAsmConstraint(const char *&Name,
diff --git a/clang/lib/Basic/Targets/M68k.cpp b/clang/lib/Basic/Targets/M68k.cpp
index ada5b97ed66de..48627a8ceff9a 100644
--- a/clang/lib/Basic/Targets/M68k.cpp
+++ b/clang/lib/Basic/Targets/M68k.cpp
@@ -117,7 +117,7 @@ void M68kTargetInfo::getTargetDefines(const LangOptions &Opts,
ArrayRef<Builtin::Info> M68kTargetInfo::getTargetBuiltins() const {
// FIXME: Implement.
- return None;
+ return std::nullopt;
}
bool M68kTargetInfo::hasFeature(StringRef Feature) const {
@@ -136,7 +136,7 @@ ArrayRef<const char *> M68kTargetInfo::getGCCRegNames() const {
ArrayRef<TargetInfo::GCCRegAlias> M68kTargetInfo::getGCCRegAliases() const {
// No aliases.
- return None;
+ return std::nullopt;
}
bool M68kTargetInfo::validateAsmConstraint(
@@ -209,7 +209,7 @@ M68kTargetInfo::handleAsmEscapedChar(char EscChar) const {
C = 'd';
break;
default:
- return llvm::None;
+ return std::nullopt;
}
return std::string(1, C);
diff --git a/clang/lib/Basic/Targets/MSP430.h b/clang/lib/Basic/Targets/MSP430.h
index 9d42e4d4bb183..973e039cd02be 100644
--- a/clang/lib/Basic/Targets/MSP430.h
+++ b/clang/lib/Basic/Targets/MSP430.h
@@ -52,7 +52,7 @@ class LLVM_LIBRARY_VISIBILITY MSP430TargetInfo : public TargetInfo {
ArrayRef<Builtin::Info> getTargetBuiltins() const override {
// FIXME: Implement.
- return None;
+ return std::nullopt;
}
bool allowsLargerPreferedTypeAlignment() const override { return false; }
diff --git a/clang/lib/Basic/Targets/NVPTX.h b/clang/lib/Basic/Targets/NVPTX.h
index 176e2e4e3fa93..79f4cbe5d1690 100644
--- a/clang/lib/Basic/Targets/NVPTX.h
+++ b/clang/lib/Basic/Targets/NVPTX.h
@@ -87,7 +87,7 @@ class LLVM_LIBRARY_VISIBILITY NVPTXTargetInfo : public TargetInfo {
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
// No aliases.
- return None;
+ return std::nullopt;
}
bool validateAsmConstraint(const char *&Name,
@@ -162,7 +162,7 @@ class LLVM_LIBRARY_VISIBILITY NVPTXTargetInfo : public TargetInfo {
getDWARFAddressSpace(unsigned AddressSpace) const override {
if (AddressSpace >= std::size(NVPTXDWARFAddrSpaceMap) ||
NVPTXDWARFAddrSpaceMap[AddressSpace] < 0)
- return llvm::None;
+ return std::nullopt;
return NVPTXDWARFAddrSpaceMap[AddressSpace];
}
diff --git a/clang/lib/Basic/Targets/PNaCl.cpp b/clang/lib/Basic/Targets/PNaCl.cpp
index 60e9467193a81..51b6452b0c203 100644
--- a/clang/lib/Basic/Targets/PNaCl.cpp
+++ b/clang/lib/Basic/Targets/PNaCl.cpp
@@ -16,10 +16,12 @@
using namespace clang;
using namespace clang::targets;
-ArrayRef<const char *> PNaClTargetInfo::getGCCRegNames() const { return None; }
+ArrayRef<const char *> PNaClTargetInfo::getGCCRegNames() const {
+ return std::nullopt;
+}
ArrayRef<TargetInfo::GCCRegAlias> PNaClTargetInfo::getGCCRegAliases() const {
- return None;
+ return std::nullopt;
}
void PNaClTargetInfo::getArchDefines(const LangOptions &Opts,
diff --git a/clang/lib/Basic/Targets/PNaCl.h b/clang/lib/Basic/Targets/PNaCl.h
index b5cf73d73e95f..72c586359ceaf 100644
--- a/clang/lib/Basic/Targets/PNaCl.h
+++ b/clang/lib/Basic/Targets/PNaCl.h
@@ -52,7 +52,9 @@ class LLVM_LIBRARY_VISIBILITY PNaClTargetInfo : public TargetInfo {
return Feature == "pnacl";
}
- ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override {
+ return std::nullopt;
+ }
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::PNaClABIBuiltinVaList;
diff --git a/clang/lib/Basic/Targets/RISCV.cpp b/clang/lib/Basic/Targets/RISCV.cpp
index 2c7e00252e598..b76ef15fa3771 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -264,7 +264,7 @@ RISCVTargetInfo::getVScaleRange(const LangOptions &LangOpts) const {
MaxVLen / llvm::RISCV::RVVBitsPerBlock);
}
- return None;
+ return std::nullopt;
}
/// Return true if has this feature, need to sync with handleTargetFeatures.
@@ -276,7 +276,7 @@ bool RISCVTargetInfo::hasFeature(StringRef Feature) const {
.Case("riscv64", Is64Bit)
.Case("32bit", !Is64Bit)
.Case("64bit", Is64Bit)
- .Default(None);
+ .Default(std::nullopt);
if (Result)
return Result.value();
diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h
index 655e9d60f4a1f..17db3b1ba3a0c 100644
--- a/clang/lib/Basic/Targets/SPIR.h
+++ b/clang/lib/Basic/Targets/SPIR.h
@@ -104,11 +104,15 @@ class LLVM_LIBRARY_VISIBILITY BaseSPIRTargetInfo : public TargetInfo {
// memcpy as per section 3 of the SPIR spec.
bool useFP16ConversionIntrinsics() const override { return false; }
- ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override {
+ return std::nullopt;
+ }
const char *getClobbers() const override { return ""; }
- ArrayRef<const char *> getGCCRegNames() const override { return None; }
+ ArrayRef<const char *> getGCCRegNames() const override {
+ return std::nullopt;
+ }
bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &info) const override {
@@ -116,7 +120,7 @@ class LLVM_LIBRARY_VISIBILITY BaseSPIRTargetInfo : public TargetInfo {
}
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
- return None;
+ return std::nullopt;
}
BuiltinVaListKind getBuiltinVaListKind() const override {
diff --git a/clang/lib/Basic/Targets/Sparc.h b/clang/lib/Basic/Targets/Sparc.h
index 177a117520da8..4860b023d6e65 100644
--- a/clang/lib/Basic/Targets/Sparc.h
+++ b/clang/lib/Basic/Targets/Sparc.h
@@ -50,7 +50,7 @@ class LLVM_LIBRARY_VISIBILITY SparcTargetInfo : public TargetInfo {
ArrayRef<Builtin::Info> getTargetBuiltins() const override {
// FIXME: Implement!
- return None;
+ return std::nullopt;
}
BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::VoidPtrBuiltinVaList;
diff --git a/clang/lib/Basic/Targets/SystemZ.h b/clang/lib/Basic/Targets/SystemZ.h
index 371eb25163786..a59941352468e 100644
--- a/clang/lib/Basic/Targets/SystemZ.h
+++ b/clang/lib/Basic/Targets/SystemZ.h
@@ -71,7 +71,7 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo {
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
// No aliases.
- return None;
+ return std::nullopt;
}
ArrayRef<TargetInfo::AddlRegName> getGCCAddlRegNames() const override;
diff --git a/clang/lib/Basic/Targets/TCE.h b/clang/lib/Basic/Targets/TCE.h
index fbd0c30de3eb5..430ace3ab237c 100644
--- a/clang/lib/Basic/Targets/TCE.h
+++ b/clang/lib/Basic/Targets/TCE.h
@@ -92,7 +92,9 @@ class LLVM_LIBRARY_VISIBILITY TCETargetInfo : public TargetInfo {
bool hasFeature(StringRef Feature) const override { return Feature == "tce"; }
- ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override {
+ return std::nullopt;
+ }
const char *getClobbers() const override { return ""; }
@@ -100,7 +102,9 @@ class LLVM_LIBRARY_VISIBILITY TCETargetInfo : public TargetInfo {
return TargetInfo::VoidPtrBuiltinVaList;
}
- ArrayRef<const char *> getGCCRegNames() const override { return None; }
+ ArrayRef<const char *> getGCCRegNames() const override {
+ return std::nullopt;
+ }
bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &info) const override {
@@ -108,7 +112,7 @@ class LLVM_LIBRARY_VISIBILITY TCETargetInfo : public TargetInfo {
}
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
- return None;
+ return std::nullopt;
}
};
diff --git a/clang/lib/Basic/Targets/WebAssembly.h b/clang/lib/Basic/Targets/WebAssembly.h
index 63418869d10ac..d0b4809ff5874 100644
--- a/clang/lib/Basic/Targets/WebAssembly.h
+++ b/clang/lib/Basic/Targets/WebAssembly.h
@@ -96,10 +96,10 @@ class LLVM_LIBRARY_VISIBILITY WebAssemblyTargetInfo : public TargetInfo {
return VoidPtrBuiltinVaList;
}
- ArrayRef<const char *> getGCCRegNames() const final { return None; }
+ ArrayRef<const char *> getGCCRegNames() const final { return std::nullopt; }
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const final {
- return None;
+ return std::nullopt;
}
bool validateAsmConstraint(const char *&Name,
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 242f9c59f3cfa..6cf105d5208cf 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -1453,7 +1453,7 @@ Optional<unsigned> X86TargetInfo::getCPUCacheLineSize() const {
// The following currently have unknown cache line sizes (but they are probably all 64):
// Core
case CK_None:
- return None;
+ return std::nullopt;
}
llvm_unreachable("Unknown CPU kind");
}
diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index 62e59c06fb2c1..1fda9a53d9caf 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -192,7 +192,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo {
ArrayRef<const char *> getGCCRegNames() const override;
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
- return None;
+ return std::nullopt;
}
ArrayRef<TargetInfo::AddlRegName> getGCCAddlRegNames() const override;
diff --git a/clang/lib/Basic/Targets/XCore.h b/clang/lib/Basic/Targets/XCore.h
index 25f20581839d8..1919f0d7a0824 100644
--- a/clang/lib/Basic/Targets/XCore.h
+++ b/clang/lib/Basic/Targets/XCore.h
@@ -61,7 +61,7 @@ class LLVM_LIBRARY_VISIBILITY XCoreTargetInfo : public TargetInfo {
}
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
- return None;
+ return std::nullopt;
}
bool validateAsmConstraint(const char *&Name,
More information about the cfe-commits
mailing list