[clang] 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:44 -08:00
parent a38cfc50fc
commit 86d8f2ce97
3 changed files with 9 additions and 9 deletions

View File

@ -41,7 +41,7 @@ class RefPropertyType<string className> : PropertyType<className # "*"> {
let PackOptional =
"value ? *value : nullptr";
let UnpackOptional =
"value ? llvm::Optional<" # CXXName # ">(value) : llvm::None";
"value ? llvm::Optional<" # CXXName # ">(value) : std::nullopt";
}
/// Property types that correspond to a specific subclass of another type.
@ -58,7 +58,7 @@ class DefaultValuePropertyType<string typeName = ""> : PropertyType<typeName> {
let PackOptional =
"value ? *value : " # CXXName # "()";
let UnpackOptional =
"value.isNull() ? llvm::None : llvm::Optional<" # CXXName # ">(value)";
"value.isNull() ? std::nullopt : llvm::Optional<" # CXXName # ">(value)";
}
/// Property types that correspond to integer types and support optional
@ -67,7 +67,7 @@ class CountPropertyType<string typeName = ""> : PropertyType<typeName> {
let PackOptional =
"value ? *value + 1 : 0";
let UnpackOptional =
"value ? llvm::Optional<" # CXXName # ">(value - 1) : llvm::None";
"value ? llvm::Optional<" # CXXName # ">(value - 1) : std::nullopt";
}
def APInt : PropertyType<"llvm::APInt"> { let PassByReference = 1; }

View File

@ -668,7 +668,7 @@ let Class = TemplateSpecializationType in {
node->isTypeAlias()
? llvm::Optional<QualType>(node->getAliasedType())
: node->isCanonicalUnqualified()
? llvm::None
? std::nullopt
: llvm::Optional<QualType>(node->getCanonicalTypeInternal())
}];
}
@ -834,7 +834,7 @@ let Class = DependentNameType in {
def : Property<"underlyingType", Optional<QualType>> {
let Read = [{
node->isCanonicalUnqualified()
? llvm::None
? std::nullopt
: llvm::Optional<QualType>(node->getCanonicalTypeInternal())
}];
}

View File

@ -2116,7 +2116,7 @@ void PragmaClangAttributeSupport::generateParsingHelpers(raw_ostream &OS) {
// Generate routines that check the names of sub-rules.
OS << "Optional<attr::SubjectMatchRule> "
"defaultIsAttributeSubjectMatchSubRuleFor(StringRef, bool) {\n";
OS << " return None;\n";
OS << " return std::nullopt;\n";
OS << "}\n\n";
llvm::MapVector<const Record *, std::vector<AttributeSubjectMatchRule>>
@ -2139,7 +2139,7 @@ void PragmaClangAttributeSupport::generateParsingHelpers(raw_ostream &OS) {
OS << " Case(\"" << Rule.getName() << "\", " << Rule.getEnumValue()
<< ").\n";
}
OS << " Default(None);\n";
OS << " Default(std::nullopt);\n";
OS << " return "
"llvm::StringSwitch<Optional<attr::SubjectMatchRule>>(Name).\n";
for (const auto &Rule : SubMatchRule.second) {
@ -2147,7 +2147,7 @@ void PragmaClangAttributeSupport::generateParsingHelpers(raw_ostream &OS) {
OS << " Case(\"" << Rule.getName() << "\", " << Rule.getEnumValue()
<< ").\n";
}
OS << " Default(None);\n";
OS << " Default(std::nullopt);\n";
OS << "}\n\n";
}
@ -2171,7 +2171,7 @@ void PragmaClangAttributeSupport::generateParsingHelpers(raw_ostream &OS) {
OS << " Case(\"" << Rule.getName() << "\", std::make_pair("
<< Rule.getEnumValue() << ", " << SubRuleFunction << ")).\n";
}
OS << " Default(std::make_pair(None, "
OS << " Default(std::make_pair(std::nullopt, "
"defaultIsAttributeSubjectMatchSubRuleFor));\n";
OS << "}\n\n";