[llvm] Use std::nullopt instead of None (NFC)

I've verified that every change in this patch affects generated files
and would reduce the number of warnings if None were deprecated.

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-04 13:52:42 -08:00
parent f4c16c4473
commit a38cfc50fc
6 changed files with 10 additions and 10 deletions

View File

@ -496,7 +496,7 @@ void MarkupFilter::printValue(Twine Value) {
#define ASSIGN_OR_RETURN_NONE(TYPE, NAME, EXPR) \ #define ASSIGN_OR_RETURN_NONE(TYPE, NAME, EXPR) \
auto NAME##Opt = (EXPR); \ auto NAME##Opt = (EXPR); \
if (!NAME##Opt) \ if (!NAME##Opt) \
return None; \ return std::nullopt; \
TYPE NAME = std::move(*NAME##Opt) TYPE NAME = std::move(*NAME##Opt)
Optional<MarkupFilter::Module> Optional<MarkupFilter::Module>

View File

@ -31,7 +31,7 @@ using namespace llvm;
TY res = *NAME##View; \ TY res = *NAME##View; \
return res; \ return res; \
} \ } \
return None; \ return std::nullopt; \
} }
MCOPT_EXP(bool, RelaxAll) MCOPT_EXP(bool, RelaxAll)

View File

@ -3947,7 +3947,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
OS << " MII.getDeprecatedInfo(Inst, getSTI(), Info)) {\n"; OS << " MII.getDeprecatedInfo(Inst, getSTI(), Info)) {\n";
OS << " SMLoc Loc = ((" << Target.getName() OS << " SMLoc Loc = ((" << Target.getName()
<< "Operand &)*Operands[0]).getStartLoc();\n"; << "Operand &)*Operands[0]).getStartLoc();\n";
OS << " getParser().Warning(Loc, Info, None);\n"; OS << " getParser().Warning(Loc, Info, std::nullopt);\n";
OS << " }\n"; OS << " }\n";
} }

View File

@ -647,7 +647,7 @@ void GICombinerEmitter::emitNameMatcher(raw_ostream &OS) const {
StringMatcher Matcher("RuleIdentifier", Cases, OS); StringMatcher Matcher("RuleIdentifier", Cases, OS);
Matcher.Emit(); Matcher.Emit();
OS << "#endif // ifndef NDEBUG\n\n" OS << "#endif // ifndef NDEBUG\n\n"
<< " return None;\n" << " return std::nullopt;\n"
<< "}\n"; << "}\n";
} }
@ -960,7 +960,7 @@ void GICombinerEmitter::run(raw_ostream &OS) {
<< " const auto Last = " << " const auto Last = "
"getRuleIdxForIdentifier(RangePair.second);\n" "getRuleIdxForIdentifier(RangePair.second);\n"
<< " if (!First || !Last)\n" << " if (!First || !Last)\n"
<< " return None;\n" << " return std::nullopt;\n"
<< " if (First >= Last)\n" << " if (First >= Last)\n"
<< " report_fatal_error(\"Beginning of range should be before " << " report_fatal_error(\"Beginning of range should be before "
"end of range\");\n" "end of range\");\n"
@ -971,7 +971,7 @@ void GICombinerEmitter::run(raw_ostream &OS) {
<< " }\n" << " }\n"
<< " const auto I = getRuleIdxForIdentifier(RangePair.first);\n" << " const auto I = getRuleIdxForIdentifier(RangePair.first);\n"
<< " if (!I)\n" << " if (!I)\n"
<< " return None;\n" << " return std::nullopt;\n"
<< " return {{*I, *I + 1}};\n" << " return {{*I, *I + 1}};\n"
<< "}\n\n"; << "}\n\n";

View File

@ -1690,7 +1690,7 @@ RegisterInfoEmitter::runTargetDesc(raw_ostream &OS, CodeGenTarget &Target,
OS << " };\n"; OS << " };\n";
OS << " return makeArrayRef(Masks);\n"; OS << " return makeArrayRef(Masks);\n";
} else { } else {
OS << " return None;\n"; OS << " return std::nullopt;\n";
} }
OS << "}\n\n"; OS << "}\n\n";
@ -1756,7 +1756,7 @@ RegisterInfoEmitter::runTargetDesc(raw_ostream &OS, CodeGenTarget &Target,
OS << " };\n"; OS << " };\n";
OS << " return makeArrayRef(Names);\n"; OS << " return makeArrayRef(Names);\n";
} else { } else {
OS << " return None;\n"; OS << " return std::nullopt;\n";
} }
OS << "}\n\n"; OS << "}\n\n";

View File

@ -1862,7 +1862,7 @@ void SubtargetEmitter::run(raw_ostream &OS) {
if (NumFeatures) if (NumFeatures)
OS << Target << "FeatureKV, "; OS << Target << "FeatureKV, ";
else else
OS << "None, "; OS << "std::nullopt, ";
if (NumProcs) if (NumProcs)
OS << Target << "SubTypeKV, "; OS << Target << "SubTypeKV, ";
else else
@ -1955,7 +1955,7 @@ void SubtargetEmitter::run(raw_ostream &OS) {
if (NumFeatures) if (NumFeatures)
OS << "makeArrayRef(" << Target << "FeatureKV, " << NumFeatures << "), "; OS << "makeArrayRef(" << Target << "FeatureKV, " << NumFeatures << "), ";
else else
OS << "None, "; OS << "std::nullopt, ";
if (NumProcs) if (NumProcs)
OS << "makeArrayRef(" << Target << "SubTypeKV, " << NumProcs << "), "; OS << "makeArrayRef(" << Target << "SubTypeKV, " << NumProcs << "), ";
else else