From 86d8f2ce97c36a57da55220b1f0eecf999e78a3d Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sun, 4 Dec 2022 13:52:44 -0800 Subject: [PATCH] [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 --- clang/include/clang/AST/PropertiesBase.td | 6 +++--- clang/include/clang/AST/TypeProperties.td | 4 ++-- clang/utils/TableGen/ClangAttrEmitter.cpp | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/clang/include/clang/AST/PropertiesBase.td b/clang/include/clang/AST/PropertiesBase.td index f952b08502db..8a26aace90a1 100644 --- a/clang/include/clang/AST/PropertiesBase.td +++ b/clang/include/clang/AST/PropertiesBase.td @@ -41,7 +41,7 @@ class RefPropertyType : PropertyType { 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 : PropertyType { 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 : PropertyType { 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; } diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 89bbc0fde709..84cf787487b7 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -668,7 +668,7 @@ let Class = TemplateSpecializationType in { node->isTypeAlias() ? llvm::Optional(node->getAliasedType()) : node->isCanonicalUnqualified() - ? llvm::None + ? std::nullopt : llvm::Optional(node->getCanonicalTypeInternal()) }]; } @@ -834,7 +834,7 @@ let Class = DependentNameType in { def : Property<"underlyingType", Optional> { let Read = [{ node->isCanonicalUnqualified() - ? llvm::None + ? std::nullopt : llvm::Optional(node->getCanonicalTypeInternal()) }]; } diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp index b7f7e507dd6c..3ae1813d5d73 100644 --- a/clang/utils/TableGen/ClangAttrEmitter.cpp +++ b/clang/utils/TableGen/ClangAttrEmitter.cpp @@ -2116,7 +2116,7 @@ void PragmaClangAttributeSupport::generateParsingHelpers(raw_ostream &OS) { // Generate routines that check the names of sub-rules. OS << "Optional " "defaultIsAttributeSubjectMatchSubRuleFor(StringRef, bool) {\n"; - OS << " return None;\n"; + OS << " return std::nullopt;\n"; OS << "}\n\n"; llvm::MapVector> @@ -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>(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";