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

View File

@ -668,7 +668,7 @@ let Class = TemplateSpecializationType in {
node->isTypeAlias() node->isTypeAlias()
? llvm::Optional<QualType>(node->getAliasedType()) ? llvm::Optional<QualType>(node->getAliasedType())
: node->isCanonicalUnqualified() : node->isCanonicalUnqualified()
? llvm::None ? std::nullopt
: llvm::Optional<QualType>(node->getCanonicalTypeInternal()) : llvm::Optional<QualType>(node->getCanonicalTypeInternal())
}]; }];
} }
@ -834,7 +834,7 @@ let Class = DependentNameType in {
def : Property<"underlyingType", Optional<QualType>> { def : Property<"underlyingType", Optional<QualType>> {
let Read = [{ let Read = [{
node->isCanonicalUnqualified() node->isCanonicalUnqualified()
? llvm::None ? std::nullopt
: llvm::Optional<QualType>(node->getCanonicalTypeInternal()) : 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. // Generate routines that check the names of sub-rules.
OS << "Optional<attr::SubjectMatchRule> " OS << "Optional<attr::SubjectMatchRule> "
"defaultIsAttributeSubjectMatchSubRuleFor(StringRef, bool) {\n"; "defaultIsAttributeSubjectMatchSubRuleFor(StringRef, bool) {\n";
OS << " return None;\n"; OS << " return std::nullopt;\n";
OS << "}\n\n"; OS << "}\n\n";
llvm::MapVector<const Record *, std::vector<AttributeSubjectMatchRule>> llvm::MapVector<const Record *, std::vector<AttributeSubjectMatchRule>>
@ -2139,7 +2139,7 @@ void PragmaClangAttributeSupport::generateParsingHelpers(raw_ostream &OS) {
OS << " Case(\"" << Rule.getName() << "\", " << Rule.getEnumValue() OS << " Case(\"" << Rule.getName() << "\", " << Rule.getEnumValue()
<< ").\n"; << ").\n";
} }
OS << " Default(None);\n"; OS << " Default(std::nullopt);\n";
OS << " return " OS << " return "
"llvm::StringSwitch<Optional<attr::SubjectMatchRule>>(Name).\n"; "llvm::StringSwitch<Optional<attr::SubjectMatchRule>>(Name).\n";
for (const auto &Rule : SubMatchRule.second) { for (const auto &Rule : SubMatchRule.second) {
@ -2147,7 +2147,7 @@ void PragmaClangAttributeSupport::generateParsingHelpers(raw_ostream &OS) {
OS << " Case(\"" << Rule.getName() << "\", " << Rule.getEnumValue() OS << " Case(\"" << Rule.getName() << "\", " << Rule.getEnumValue()
<< ").\n"; << ").\n";
} }
OS << " Default(None);\n"; OS << " Default(std::nullopt);\n";
OS << "}\n\n"; OS << "}\n\n";
} }
@ -2171,7 +2171,7 @@ void PragmaClangAttributeSupport::generateParsingHelpers(raw_ostream &OS) {
OS << " Case(\"" << Rule.getName() << "\", std::make_pair(" OS << " Case(\"" << Rule.getName() << "\", std::make_pair("
<< Rule.getEnumValue() << ", " << SubRuleFunction << ")).\n"; << Rule.getEnumValue() << ", " << SubRuleFunction << ")).\n";
} }
OS << " Default(std::make_pair(None, " OS << " Default(std::make_pair(std::nullopt, "
"defaultIsAttributeSubjectMatchSubRuleFor));\n"; "defaultIsAttributeSubjectMatchSubRuleFor));\n";
OS << "}\n\n"; OS << "}\n\n";