[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
This commit is contained in:
Kazu Hirata 2022-12-03 11:34:27 -08:00
parent 34e0d0579a
commit eeee3fee37
32 changed files with 119 additions and 88 deletions

View File

@ -272,7 +272,7 @@ public:
OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr & OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr &
operator=(std::nullopt_t) { operator=(std::nullopt_t) {
Optional<DirectoryEntryRef>::operator=(None); Optional<DirectoryEntryRef>::operator=(std::nullopt);
return *this; return *this;
} }
OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr &operator=(DirectoryEntryRef Ref) { OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr &operator=(DirectoryEntryRef Ref) {

View File

@ -315,7 +315,7 @@ public:
: Optional<FileEntryRef>(MaybeRef) {} : Optional<FileEntryRef>(MaybeRef) {}
OptionalFileEntryRefDegradesToFileEntryPtr &operator=(std::nullopt_t) { OptionalFileEntryRefDegradesToFileEntryPtr &operator=(std::nullopt_t) {
Optional<FileEntryRef>::operator=(None); Optional<FileEntryRef>::operator=(std::nullopt);
return *this; return *this;
} }
OptionalFileEntryRefDegradesToFileEntryPtr &operator=(FileEntryRef Ref) { OptionalFileEntryRefDegradesToFileEntryPtr &operator=(FileEntryRef Ref) {

View File

@ -179,8 +179,9 @@ public:
mutable unsigned IsBufferInvalid : 1; mutable unsigned IsBufferInvalid : 1;
ContentCache() ContentCache()
: OrigEntry(None), ContentsEntry(nullptr), BufferOverridden(false), : OrigEntry(std::nullopt), ContentsEntry(nullptr),
IsFileVolatile(false), IsTransient(false), IsBufferInvalid(false) {} BufferOverridden(false), IsFileVolatile(false), IsTransient(false),
IsBufferInvalid(false) {}
ContentCache(FileEntryRef Ent) : ContentCache(Ent, Ent) {} ContentCache(FileEntryRef Ent) : ContentCache(Ent, Ent) {}
@ -236,7 +237,7 @@ public:
llvm::Optional<llvm::MemoryBufferRef> getBufferIfLoaded() const { llvm::Optional<llvm::MemoryBufferRef> getBufferIfLoaded() const {
if (Buffer) if (Buffer)
return Buffer->getMemBufferRef(); return Buffer->getMemBufferRef();
return None; return std::nullopt;
} }
/// Return a StringRef to the source buffer data, only if it has already /// Return a StringRef to the source buffer data, only if it has already
@ -244,7 +245,7 @@ public:
llvm::Optional<StringRef> getBufferDataIfLoaded() const { llvm::Optional<StringRef> getBufferDataIfLoaded() const {
if (Buffer) if (Buffer)
return Buffer->getBuffer(); return Buffer->getBuffer();
return None; return std::nullopt;
} }
/// Set the buffer. /// Set the buffer.
@ -1025,7 +1026,7 @@ public:
if (auto *Entry = getSLocEntryForFile(FID)) if (auto *Entry = getSLocEntryForFile(FID))
return Entry->getFile().getContentCache().getBufferOrNone( return Entry->getFile().getContentCache().getBufferOrNone(
Diag, getFileManager(), Loc); Diag, getFileManager(), Loc);
return None; return std::nullopt;
} }
/// Return the buffer for the specified FileID. /// Return the buffer for the specified FileID.
@ -1050,7 +1051,7 @@ public:
Optional<FileEntryRef> getFileEntryRefForID(FileID FID) const { Optional<FileEntryRef> getFileEntryRefForID(FileID FID) const {
if (auto *Entry = getSLocEntryForFile(FID)) if (auto *Entry = getSLocEntryForFile(FID))
return Entry->getFile().getContentCache().OrigEntry; return Entry->getFile().getContentCache().OrigEntry;
return None; return std::nullopt;
} }
/// Returns the filename for the provided FileID, unless it's a built-in /// Returns the filename for the provided FileID, unless it's a built-in

View File

@ -956,7 +956,7 @@ public:
/// Returns target-specific min and max values VScale_Range. /// Returns target-specific min and max values VScale_Range.
virtual Optional<std::pair<unsigned, unsigned>> virtual Optional<std::pair<unsigned, unsigned>>
getVScaleRange(const LangOptions &LangOpts) const { getVScaleRange(const LangOptions &LangOpts) const {
return None; return std::nullopt;
} }
/// The __builtin_clz* and __builtin_ctz* built-in /// The __builtin_clz* and __builtin_ctz* built-in
/// functions are specified to have undefined results for zero inputs, but /// functions are specified to have undefined results for zero inputs, but
@ -1181,7 +1181,7 @@ public:
/// Replace some escaped characters with another string based on /// Replace some escaped characters with another string based on
/// target-specific rules /// target-specific rules
virtual llvm::Optional<std::string> handleAsmEscapedChar(char C) const { 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. /// Returns a string of target-specific clobbers, in LLVM format.
@ -1199,7 +1199,9 @@ public:
} }
/// Returns the target ID if supported. /// 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 { const char *getDataLayoutString() const {
assert(!DataLayoutString.empty() && "Uninitialized DataLayout!"); assert(!DataLayoutString.empty() && "Uninitialized DataLayout!");
@ -1434,7 +1436,9 @@ public:
// Get the cache line size of a given cpu. This method switches over // 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. // 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. // Returns maximal number of args passed in registers.
unsigned getRegParmMax() const { unsigned getRegParmMax() const {
@ -1651,7 +1655,7 @@ public:
/// \returns Otherwise return None and no conversion will be emitted in the /// \returns Otherwise return None and no conversion will be emitted in the
/// DWARF. /// DWARF.
virtual Optional<unsigned> getDWARFAddressSpace(unsigned AddressSpace) const { 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 /// \returns The version of the SDK which was used during the compilation if
@ -1704,7 +1708,7 @@ protected:
virtual ArrayRef<const char *> getGCCRegNames() const = 0; virtual ArrayRef<const char *> getGCCRegNames() const = 0;
virtual ArrayRef<GCCRegAlias> getGCCRegAliases() const = 0; virtual ArrayRef<GCCRegAlias> getGCCRegAliases() const = 0;
virtual ArrayRef<AddlRegName> getGCCAddlRegNames() const { virtual ArrayRef<AddlRegName> getGCCAddlRegNames() const {
return None; return std::nullopt;
} }
private: private:

View File

@ -30,7 +30,7 @@ Optional<VersionTuple> DarwinSDKInfo::RelatedTargetVersionMapping::map(
if (Key.getMinor()) if (Key.getMinor())
return map(VersionTuple(Key.getMajor()), MinimumValue, MaximumValue); return map(VersionTuple(Key.getMajor()), MinimumValue, MaximumValue);
// If this a major only key, return None for a missing entry. // If this a major only key, return None for a missing entry.
return None; return std::nullopt;
} }
Optional<DarwinSDKInfo::RelatedTargetVersionMapping> Optional<DarwinSDKInfo::RelatedTargetVersionMapping>
@ -45,7 +45,7 @@ DarwinSDKInfo::RelatedTargetVersionMapping::parseJSON(
llvm::VersionTuple KeyVersion; llvm::VersionTuple KeyVersion;
llvm::VersionTuple ValueVersion; llvm::VersionTuple ValueVersion;
if (KeyVersion.tryParse(KV.getFirst()) || ValueVersion.tryParse(*Val)) if (KeyVersion.tryParse(KV.getFirst()) || ValueVersion.tryParse(*Val))
return None; return std::nullopt;
Mapping[KeyVersion.normalize()] = ValueVersion; Mapping[KeyVersion.normalize()] = ValueVersion;
if (KeyVersion < Min) if (KeyVersion < Min)
Min = KeyVersion; Min = KeyVersion;
@ -56,7 +56,7 @@ DarwinSDKInfo::RelatedTargetVersionMapping::parseJSON(
} }
} }
if (Mapping.empty()) if (Mapping.empty())
return None; return std::nullopt;
return RelatedTargetVersionMapping( return RelatedTargetVersionMapping(
Min, Max, MinValue, MaximumDeploymentTarget, std::move(Mapping)); Min, Max, MinValue, MaximumDeploymentTarget, std::move(Mapping));
} }
@ -65,10 +65,10 @@ static Optional<VersionTuple> getVersionKey(const llvm::json::Object &Obj,
StringRef Key) { StringRef Key) {
auto Value = Obj.getString(Key); auto Value = Obj.getString(Key);
if (!Value) if (!Value)
return None; return std::nullopt;
VersionTuple Version; VersionTuple Version;
if (Version.tryParse(*Value)) if (Version.tryParse(*Value))
return None; return std::nullopt;
return Version; return Version;
} }
@ -76,11 +76,11 @@ Optional<DarwinSDKInfo>
DarwinSDKInfo::parseDarwinSDKSettingsJSON(const llvm::json::Object *Obj) { DarwinSDKInfo::parseDarwinSDKSettingsJSON(const llvm::json::Object *Obj) {
auto Version = getVersionKey(*Obj, "Version"); auto Version = getVersionKey(*Obj, "Version");
if (!Version) if (!Version)
return None; return std::nullopt;
auto MaximumDeploymentVersion = auto MaximumDeploymentVersion =
getVersionKey(*Obj, "MaximumDeploymentTarget"); getVersionKey(*Obj, "MaximumDeploymentTarget");
if (!MaximumDeploymentVersion) if (!MaximumDeploymentVersion)
return None; return std::nullopt;
llvm::DenseMap<OSEnvPair::StorageType, Optional<RelatedTargetVersionMapping>> llvm::DenseMap<OSEnvPair::StorageType, Optional<RelatedTargetVersionMapping>>
VersionMappings; VersionMappings;
if (const auto *VM = Obj->getObject("VersionMap")) { if (const auto *VM = Obj->getObject("VersionMap")) {
@ -107,7 +107,7 @@ DarwinSDKInfo::parseDarwinSDKSettingsJSON(const llvm::json::Object *Obj) {
auto VersionMap = RelatedTargetVersionMapping::parseJSON( auto VersionMap = RelatedTargetVersionMapping::parseJSON(
*Mapping, *MaximumDeploymentVersion); *Mapping, *MaximumDeploymentVersion);
if (!VersionMap) if (!VersionMap)
return None; return std::nullopt;
VersionMappings[OSEnvPair::macOStoMacCatalystPair().Value] = VersionMappings[OSEnvPair::macOStoMacCatalystPair().Value] =
std::move(VersionMap); std::move(VersionMap);
} }
@ -115,7 +115,7 @@ DarwinSDKInfo::parseDarwinSDKSettingsJSON(const llvm::json::Object *Obj) {
auto VersionMap = RelatedTargetVersionMapping::parseJSON( auto VersionMap = RelatedTargetVersionMapping::parseJSON(
*Mapping, *MaximumDeploymentVersion); *Mapping, *MaximumDeploymentVersion);
if (!VersionMap) if (!VersionMap)
return None; return std::nullopt;
VersionMappings[OSEnvPair::macCatalystToMacOSPair().Value] = VersionMappings[OSEnvPair::macCatalystToMacOSPair().Value] =
std::move(VersionMap); std::move(VersionMap);
} }
@ -134,7 +134,7 @@ clang::parseDarwinSDKInfo(llvm::vfs::FileSystem &VFS, StringRef SDKRootPath) {
VFS.getBufferForFile(Filepath); VFS.getBufferForFile(Filepath);
if (!File) { if (!File) {
// If the file couldn't be read, assume it just doesn't exist. // If the file couldn't be read, assume it just doesn't exist.
return None; return std::nullopt;
} }
Expected<llvm::json::Value> Result = Expected<llvm::json::Value> Result =
llvm::json::parse(File.get()->getBuffer()); llvm::json::parse(File.get()->getBuffer());

View File

@ -639,14 +639,14 @@ DiagnosticIDs::getGroupForWarningOption(StringRef Name) {
const auto *Found = llvm::partition_point( const auto *Found = llvm::partition_point(
OptionTable, [=](const WarningOption &O) { return O.getName() < Name; }); OptionTable, [=](const WarningOption &O) { return O.getName() < Name; });
if (Found == std::end(OptionTable) || Found->getName() != Name) if (Found == std::end(OptionTable) || Found->getName() != Name)
return llvm::None; return std::nullopt;
return static_cast<diag::Group>(Found - OptionTable); return static_cast<diag::Group>(Found - OptionTable);
} }
llvm::Optional<diag::Group> DiagnosticIDs::getGroupForDiag(unsigned DiagID) { llvm::Optional<diag::Group> DiagnosticIDs::getGroupForDiag(unsigned DiagID) {
if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID)) if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID))
return static_cast<diag::Group>(Info->getOptionGroupIndex()); return static_cast<diag::Group>(Info->getOptionGroupIndex());
return llvm::None; return std::nullopt;
} }
/// getWarningOptionForDiag - Return the lowest-level warning option that /// getWarningOptionForDiag - Return the lowest-level warning option that

View File

@ -474,7 +474,7 @@ llvm::Optional<FileEntryRef> FileManager::getBypassFile(FileEntryRef VF) {
// Stat of the file and return nullptr if it doesn't exist. // Stat of the file and return nullptr if it doesn't exist.
llvm::vfs::Status Status; llvm::vfs::Status Status;
if (getStatValue(VF.getName(), Status, /*isFile=*/true, /*F=*/nullptr)) if (getStatValue(VF.getName(), Status, /*isFile=*/true, /*F=*/nullptr))
return None; return std::nullopt;
if (!SeenBypassFileEntries) if (!SeenBypassFileEntries)
SeenBypassFileEntries = std::make_unique< SeenBypassFileEntries = std::make_unique<

View File

@ -111,7 +111,7 @@ ProfileList::inSection(StringRef Section, StringRef Prefix,
return Forbid; return Forbid;
if (SCL->inSection(Section, Prefix, Query)) if (SCL->inSection(Section, Prefix, Query))
return Allow; return Allow;
return None; return std::nullopt;
} }
llvm::Optional<ProfileList::ExclusionType> llvm::Optional<ProfileList::ExclusionType>
@ -125,7 +125,7 @@ ProfileList::isFunctionExcluded(StringRef FunctionName,
return Forbid; return Forbid;
if (SCL->inSection(Section, "fun", FunctionName)) if (SCL->inSection(Section, "fun", FunctionName))
return Allow; return Allow;
return None; return std::nullopt;
} }
llvm::Optional<ProfileList::ExclusionType> llvm::Optional<ProfileList::ExclusionType>
@ -145,5 +145,5 @@ ProfileList::isFileExcluded(StringRef FileName,
return Forbid; return Forbid;
if (SCL->inSection(Section, "src", FileName)) if (SCL->inSection(Section, "src", FileName))
return Allow; return Allow;
return None; return std::nullopt;
} }

View File

@ -105,11 +105,11 @@ ContentCache::getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM,
// Lazily create the Buffer for ContentCaches that wrap files. If we already // Lazily create the Buffer for ContentCaches that wrap files. If we already
// computed it, just return what we have. // computed it, just return what we have.
if (IsBufferInvalid) if (IsBufferInvalid)
return None; return std::nullopt;
if (Buffer) if (Buffer)
return Buffer->getMemBufferRef(); return Buffer->getMemBufferRef();
if (!ContentsEntry) if (!ContentsEntry)
return None; return std::nullopt;
// Start with the assumption that the buffer is invalid to simplify early // Start with the assumption that the buffer is invalid to simplify early
// return paths. // return paths.
@ -131,7 +131,7 @@ ContentCache::getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM,
Diag.Report(Loc, diag::err_cannot_open_file) Diag.Report(Loc, diag::err_cannot_open_file)
<< ContentsEntry->getName() << BufferOrError.getError().message(); << ContentsEntry->getName() << BufferOrError.getError().message();
return None; return std::nullopt;
} }
Buffer = std::move(*BufferOrError); Buffer = std::move(*BufferOrError);
@ -153,7 +153,7 @@ ContentCache::getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM,
Diag.Report(Loc, diag::err_file_too_large) Diag.Report(Loc, diag::err_file_too_large)
<< ContentsEntry->getName(); << ContentsEntry->getName();
return None; return std::nullopt;
} }
// Unless this is a named pipe (in which case we can handle a mismatch), // 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) Diag.Report(Loc, diag::err_file_modified)
<< ContentsEntry->getName(); << ContentsEntry->getName();
return None; return std::nullopt;
} }
// If the buffer is valid, check to see if it has a UTF Byte Order Mark // 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) { if (InvalidBOM) {
Diag.Report(Loc, diag::err_unsupported_bom) Diag.Report(Loc, diag::err_unsupported_bom)
<< InvalidBOM << ContentsEntry->getName(); << InvalidBOM << ContentsEntry->getName();
return None; return std::nullopt;
} }
// Buffer has been validated. // 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 the file can't be found in the FS, give up.
if (!BypassFile) if (!BypassFile)
return None; return std::nullopt;
(void)getOrCreateContentCache(*BypassFile); (void)getOrCreateContentCache(*BypassFile);
return BypassFile; return BypassFile;
@ -735,7 +735,7 @@ SourceManager::getNonBuiltinFilenameForID(FileID FID) const {
if (const SrcMgr::SLocEntry *Entry = getSLocEntryForFile(FID)) if (const SrcMgr::SLocEntry *Entry = getSLocEntryForFile(FID))
if (Entry->getFile().getContentCache().OrigEntry) if (Entry->getFile().getContentCache().OrigEntry)
return Entry->getFile().getName(); return Entry->getFile().getName();
return None; return std::nullopt;
} }
StringRef SourceManager::getBufferData(FileID FID, bool *Invalid) const { StringRef SourceManager::getBufferData(FileID FID, bool *Invalid) const {
@ -749,7 +749,7 @@ llvm::Optional<StringRef>
SourceManager::getBufferDataIfLoaded(FileID FID) const { SourceManager::getBufferDataIfLoaded(FileID FID) const {
if (const SrcMgr::SLocEntry *Entry = getSLocEntryForFile(FID)) if (const SrcMgr::SLocEntry *Entry = getSLocEntryForFile(FID))
return Entry->getFile().getContentCache().getBufferDataIfLoaded(); return Entry->getFile().getContentCache().getBufferDataIfLoaded();
return None; return std::nullopt;
} }
llvm::Optional<StringRef> SourceManager::getBufferDataOrNone(FileID FID) const { 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( if (auto B = Entry->getFile().getContentCache().getBufferOrNone(
Diag, getFileManager(), SourceLocation())) Diag, getFileManager(), SourceLocation()))
return B->getBuffer(); return B->getBuffer();
return None; return std::nullopt;
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -2230,7 +2230,7 @@ LLVM_DUMP_METHOD void SourceManager::dump() const {
DumpSLocEntry(ID, LoadedSLocEntryTable[Index], NextStart); DumpSLocEntry(ID, LoadedSLocEntryTable[Index], NextStart);
NextStart = LoadedSLocEntryTable[Index].getOffset(); NextStart = LoadedSLocEntryTable[Index].getOffset();
} else { } else {
NextStart = None; NextStart = std::nullopt;
} }
} }
} }

View File

@ -73,7 +73,7 @@ parseTargetIDWithFormatCheckingOnly(llvm::StringRef TargetID,
auto Split = TargetID.split(':'); auto Split = TargetID.split(':');
Processor = Split.first; Processor = Split.first;
if (Processor.empty()) if (Processor.empty())
return llvm::None; return std::nullopt;
auto Features = Split.second; auto Features = Split.second;
if (Features.empty()) if (Features.empty())
@ -88,12 +88,12 @@ parseTargetIDWithFormatCheckingOnly(llvm::StringRef TargetID,
auto Sign = Splits.first.back(); auto Sign = Splits.first.back();
auto Feature = Splits.first.drop_back(); auto Feature = Splits.first.drop_back();
if (Sign != '+' && Sign != '-') if (Sign != '+' && Sign != '-')
return llvm::None; return std::nullopt;
bool IsOn = Sign == '+'; bool IsOn = Sign == '+';
auto Loc = FeatureMap->find(Feature); auto Loc = FeatureMap->find(Feature);
// Each feature can only show up at most once in target ID. // Each feature can only show up at most once in target ID.
if (Loc != FeatureMap->end()) if (Loc != FeatureMap->end())
return llvm::None; return std::nullopt;
(*FeatureMap)[Feature] = IsOn; (*FeatureMap)[Feature] = IsOn;
Features = Splits.second; Features = Splits.second;
} }
@ -107,11 +107,11 @@ parseTargetID(const llvm::Triple &T, llvm::StringRef TargetID,
parseTargetIDWithFormatCheckingOnly(TargetID, FeatureMap); parseTargetIDWithFormatCheckingOnly(TargetID, FeatureMap);
if (!OptionalProcessor) if (!OptionalProcessor)
return llvm::None; return std::nullopt;
llvm::StringRef Processor = getCanonicalProcessorName(T, *OptionalProcessor); llvm::StringRef Processor = getCanonicalProcessorName(T, *OptionalProcessor);
if (Processor.empty()) if (Processor.empty())
return llvm::None; return std::nullopt;
llvm::SmallSet<llvm::StringRef, 4> AllFeatures; llvm::SmallSet<llvm::StringRef, 4> AllFeatures;
for (auto &&F : getAllPossibleTargetIDFeatures(T, Processor)) for (auto &&F : getAllPossibleTargetIDFeatures(T, Processor))
@ -119,7 +119,7 @@ parseTargetID(const llvm::Triple &T, llvm::StringRef TargetID,
for (auto &&F : *FeatureMap) for (auto &&F : *FeatureMap)
if (!AllFeatures.count(F.first())) if (!AllFeatures.count(F.first()))
return llvm::None; return std::nullopt;
return Processor; return Processor;
} }
@ -161,7 +161,7 @@ getConflictTargetIDCombination(const std::set<llvm::StringRef> &TargetIDs) {
return std::make_pair(Loc->second.TargetID, ID); return std::make_pair(Loc->second.TargetID, ID);
} }
} }
return llvm::None; return std::nullopt;
} }
bool isCompatibleTargetID(llvm::StringRef Provided, llvm::StringRef Requested) { bool isCompatibleTargetID(llvm::StringRef Provided, llvm::StringRef Requested) {

View File

@ -506,7 +506,7 @@ AArch64TargetInfo::getVScaleRange(const LangOptions &LangOpts) const {
if (hasFeature("sve")) if (hasFeature("sve"))
return std::pair<unsigned, unsigned>(1, 16); return std::pair<unsigned, unsigned>(1, 16);
return None; return std::nullopt;
} }
bool AArch64TargetInfo::hasFeature(StringRef Feature) const { bool AArch64TargetInfo::hasFeature(StringRef Feature) const {

View File

@ -119,7 +119,7 @@ public:
ArrayRef<const char *> getGCCRegNames() const override; ArrayRef<const char *> getGCCRegNames() const override;
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
return None; return std::nullopt;
} }
/// Accepted register names: (n, m is unsigned integer, n < m) /// Accepted register names: (n, m is unsigned integer, n < m)
@ -402,7 +402,7 @@ public:
} else if (AddressSpace == Local) { } else if (AddressSpace == Local) {
return DWARF_Local; return DWARF_Local;
} else { } else {
return None; return std::nullopt;
} }
} }
@ -452,7 +452,7 @@ public:
Optional<std::string> getTargetID() const override { Optional<std::string> getTargetID() const override {
if (!isAMDGCN(getTriple())) if (!isAMDGCN(getTriple()))
return llvm::None; return std::nullopt;
// When -target-cpu is not set, we assume generic code that it is valid // 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. // for all GPU and use an empty string as target ID to represent that.
if (GPUKind == llvm::AMDGPU::GK_NONE) if (GPUKind == llvm::AMDGPU::GK_NONE)

View File

@ -40,7 +40,9 @@ public:
void getTargetDefines(const LangOptions &Opts, void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override; 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 { BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::VoidPtrBuiltinVaList; return TargetInfo::VoidPtrBuiltinVaList;
@ -58,7 +60,7 @@ public:
} }
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
return None; return std::nullopt;
} }
bool validateAsmConstraint(const char *&Name, bool validateAsmConstraint(const char *&Name,

View File

@ -61,7 +61,9 @@ public:
void getTargetDefines(const LangOptions &Opts, void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override; 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 { BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::VoidPtrBuiltinVaList; return TargetInfo::VoidPtrBuiltinVaList;
@ -78,7 +80,7 @@ public:
} }
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
return None; return std::nullopt;
} }
ArrayRef<TargetInfo::AddlRegName> getGCCAddlRegNames() const override { ArrayRef<TargetInfo::AddlRegName> getGCCAddlRegNames() const override {

View File

@ -68,7 +68,9 @@ public:
} }
bool isValidGCCRegisterName(StringRef Name) const override { return true; } 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, bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &Info) const override { TargetInfo::ConstraintInfo &Info) const override {
@ -85,7 +87,7 @@ public:
} }
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
return None; return std::nullopt;
} }
bool allowDebugInfoForExternalRef() const override { return true; } bool allowDebugInfoForExternalRef() const override { return true; }

View File

@ -70,11 +70,15 @@ public:
return Feature == "directx"; 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 ""; } 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, bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &info) const override { TargetInfo::ConstraintInfo &info) const override {
@ -82,7 +86,7 @@ public:
} }
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
return None; return std::nullopt;
} }
BuiltinVaListKind getBuiltinVaListKind() const override { BuiltinVaListKind getBuiltinVaListKind() const override {

View File

@ -78,7 +78,9 @@ public:
return TargetInfo::VoidPtrBuiltinVaList; 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, bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &info) const override { TargetInfo::ConstraintInfo &info) const override {

View File

@ -43,10 +43,12 @@ public:
const char *getClobbers() const override { return ""; } 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 { ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
return None; return std::nullopt;
} }
bool validateAsmConstraint(const char *&Name, bool validateAsmConstraint(const char *&Name,

View File

@ -117,7 +117,7 @@ void M68kTargetInfo::getTargetDefines(const LangOptions &Opts,
ArrayRef<Builtin::Info> M68kTargetInfo::getTargetBuiltins() const { ArrayRef<Builtin::Info> M68kTargetInfo::getTargetBuiltins() const {
// FIXME: Implement. // FIXME: Implement.
return None; return std::nullopt;
} }
bool M68kTargetInfo::hasFeature(StringRef Feature) const { bool M68kTargetInfo::hasFeature(StringRef Feature) const {
@ -136,7 +136,7 @@ ArrayRef<const char *> M68kTargetInfo::getGCCRegNames() const {
ArrayRef<TargetInfo::GCCRegAlias> M68kTargetInfo::getGCCRegAliases() const { ArrayRef<TargetInfo::GCCRegAlias> M68kTargetInfo::getGCCRegAliases() const {
// No aliases. // No aliases.
return None; return std::nullopt;
} }
bool M68kTargetInfo::validateAsmConstraint( bool M68kTargetInfo::validateAsmConstraint(
@ -209,7 +209,7 @@ M68kTargetInfo::handleAsmEscapedChar(char EscChar) const {
C = 'd'; C = 'd';
break; break;
default: default:
return llvm::None; return std::nullopt;
} }
return std::string(1, C); return std::string(1, C);

View File

@ -52,7 +52,7 @@ public:
ArrayRef<Builtin::Info> getTargetBuiltins() const override { ArrayRef<Builtin::Info> getTargetBuiltins() const override {
// FIXME: Implement. // FIXME: Implement.
return None; return std::nullopt;
} }
bool allowsLargerPreferedTypeAlignment() const override { return false; } bool allowsLargerPreferedTypeAlignment() const override { return false; }

View File

@ -87,7 +87,7 @@ public:
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
// No aliases. // No aliases.
return None; return std::nullopt;
} }
bool validateAsmConstraint(const char *&Name, bool validateAsmConstraint(const char *&Name,
@ -162,7 +162,7 @@ public:
getDWARFAddressSpace(unsigned AddressSpace) const override { getDWARFAddressSpace(unsigned AddressSpace) const override {
if (AddressSpace >= std::size(NVPTXDWARFAddrSpaceMap) || if (AddressSpace >= std::size(NVPTXDWARFAddrSpaceMap) ||
NVPTXDWARFAddrSpaceMap[AddressSpace] < 0) NVPTXDWARFAddrSpaceMap[AddressSpace] < 0)
return llvm::None; return std::nullopt;
return NVPTXDWARFAddrSpaceMap[AddressSpace]; return NVPTXDWARFAddrSpaceMap[AddressSpace];
} }

View File

@ -16,10 +16,12 @@
using namespace clang; using namespace clang;
using namespace clang::targets; 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 { ArrayRef<TargetInfo::GCCRegAlias> PNaClTargetInfo::getGCCRegAliases() const {
return None; return std::nullopt;
} }
void PNaClTargetInfo::getArchDefines(const LangOptions &Opts, void PNaClTargetInfo::getArchDefines(const LangOptions &Opts,

View File

@ -52,7 +52,9 @@ public:
return Feature == "pnacl"; return Feature == "pnacl";
} }
ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; } ArrayRef<Builtin::Info> getTargetBuiltins() const override {
return std::nullopt;
}
BuiltinVaListKind getBuiltinVaListKind() const override { BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::PNaClABIBuiltinVaList; return TargetInfo::PNaClABIBuiltinVaList;

View File

@ -264,7 +264,7 @@ RISCVTargetInfo::getVScaleRange(const LangOptions &LangOpts) const {
MaxVLen / llvm::RISCV::RVVBitsPerBlock); MaxVLen / llvm::RISCV::RVVBitsPerBlock);
} }
return None; return std::nullopt;
} }
/// Return true if has this feature, need to sync with handleTargetFeatures. /// 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("riscv64", Is64Bit)
.Case("32bit", !Is64Bit) .Case("32bit", !Is64Bit)
.Case("64bit", Is64Bit) .Case("64bit", Is64Bit)
.Default(None); .Default(std::nullopt);
if (Result) if (Result)
return Result.value(); return Result.value();

View File

@ -104,11 +104,15 @@ public:
// memcpy as per section 3 of the SPIR spec. // memcpy as per section 3 of the SPIR spec.
bool useFP16ConversionIntrinsics() const override { return false; } 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 ""; } 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, bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &info) const override { TargetInfo::ConstraintInfo &info) const override {
@ -116,7 +120,7 @@ public:
} }
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
return None; return std::nullopt;
} }
BuiltinVaListKind getBuiltinVaListKind() const override { BuiltinVaListKind getBuiltinVaListKind() const override {

View File

@ -50,7 +50,7 @@ public:
ArrayRef<Builtin::Info> getTargetBuiltins() const override { ArrayRef<Builtin::Info> getTargetBuiltins() const override {
// FIXME: Implement! // FIXME: Implement!
return None; return std::nullopt;
} }
BuiltinVaListKind getBuiltinVaListKind() const override { BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::VoidPtrBuiltinVaList; return TargetInfo::VoidPtrBuiltinVaList;

View File

@ -71,7 +71,7 @@ public:
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
// No aliases. // No aliases.
return None; return std::nullopt;
} }
ArrayRef<TargetInfo::AddlRegName> getGCCAddlRegNames() const override; ArrayRef<TargetInfo::AddlRegName> getGCCAddlRegNames() const override;

View File

@ -92,7 +92,9 @@ public:
bool hasFeature(StringRef Feature) const override { return Feature == "tce"; } 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 ""; } const char *getClobbers() const override { return ""; }
@ -100,7 +102,9 @@ public:
return TargetInfo::VoidPtrBuiltinVaList; 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, bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &info) const override { TargetInfo::ConstraintInfo &info) const override {
@ -108,7 +112,7 @@ public:
} }
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
return None; return std::nullopt;
} }
}; };

View File

@ -96,10 +96,10 @@ private:
return VoidPtrBuiltinVaList; 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 { ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const final {
return None; return std::nullopt;
} }
bool validateAsmConstraint(const char *&Name, bool validateAsmConstraint(const char *&Name,

View File

@ -1453,7 +1453,7 @@ Optional<unsigned> X86TargetInfo::getCPUCacheLineSize() const {
// The following currently have unknown cache line sizes (but they are probably all 64): // The following currently have unknown cache line sizes (but they are probably all 64):
// Core // Core
case CK_None: case CK_None:
return None; return std::nullopt;
} }
llvm_unreachable("Unknown CPU kind"); llvm_unreachable("Unknown CPU kind");
} }

View File

@ -192,7 +192,7 @@ public:
ArrayRef<const char *> getGCCRegNames() const override; ArrayRef<const char *> getGCCRegNames() const override;
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
return None; return std::nullopt;
} }
ArrayRef<TargetInfo::AddlRegName> getGCCAddlRegNames() const override; ArrayRef<TargetInfo::AddlRegName> getGCCAddlRegNames() const override;

View File

@ -61,7 +61,7 @@ public:
} }
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
return None; return std::nullopt;
} }
bool validateAsmConstraint(const char *&Name, bool validateAsmConstraint(const char *&Name,