diff options
author | Kazu Hirata <kazu@google.com> | 2022-12-03 11:54:50 -0800 |
---|---|---|
committer | Kazu Hirata <kazu@google.com> | 2022-12-03 11:54:50 -0800 |
commit | 059a23c0f01fd6e5bcef0e403d8108a761ad66f5 (patch) | |
tree | fa6e0cf4e0e4bcd36fc8bb3e634a4bbaac77bb3a /clang-tools-extra/clang-include-fixer | |
parent | [clang-tidy] Use std::nullopt instead of None (NFC) (diff) | |
download | llvm-project-059a23c0f01fd6e5bcef0e403d8108a761ad66f5.tar.gz llvm-project-059a23c0f01fd6e5bcef0e403d8108a761ad66f5.tar.bz2 llvm-project-059a23c0f01fd6e5bcef0e403d8108a761ad66f5.zip |
[clang-tools-extra] 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
Diffstat (limited to 'clang-tools-extra/clang-include-fixer')
-rw-r--r-- | clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllMacros.cpp | 2 | ||||
-rw-r--r-- | clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp | 9 |
2 files changed, 6 insertions, 5 deletions
diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllMacros.cpp b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllMacros.cpp index 0f6ebbf2e23b..f41d478293b9 100644 --- a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllMacros.cpp +++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllMacros.cpp @@ -26,7 +26,7 @@ FindAllMacros::CreateMacroSymbol(const Token &MacroNameTok, std::string FilePath = getIncludePath(*SM, info->getDefinitionLoc(), Collector); if (FilePath.empty()) - return llvm::None; + return std::nullopt; return SymbolInfo(MacroNameTok.getIdentifierInfo()->getName(), SymbolInfo::SymbolKind::Macro, FilePath, {}); } diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp index e000eae999bd..ccfdb9332c44 100644 --- a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp +++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp @@ -85,7 +85,7 @@ CreateSymbolInfo(const NamedDecl *ND, const SourceManager &SM, Type = SymbolInfo::SymbolKind::EnumDecl; // Ignore anonymous enum declarations. if (ND->getName().empty()) - return llvm::None; + return std::nullopt; } else { assert(llvm::isa<RecordDecl>(ND) && "Matched decl must be one of VarDecl, " @@ -93,7 +93,7 @@ CreateSymbolInfo(const NamedDecl *ND, const SourceManager &SM, "EnumDecl and RecordDecl!"); // C-style record decl can have empty name, e.g "struct { ... } var;". if (ND->getName().empty()) - return llvm::None; + return std::nullopt; Type = SymbolInfo::SymbolKind::Class; } @@ -102,11 +102,12 @@ CreateSymbolInfo(const NamedDecl *ND, const SourceManager &SM, llvm::errs() << "Declaration " << ND->getDeclName() << "(" << ND->getDeclKindName() << ") has invalid declaration location."; - return llvm::None; + return std::nullopt; } std::string FilePath = getIncludePath(SM, Loc, Collector); - if (FilePath.empty()) return llvm::None; + if (FilePath.empty()) + return std::nullopt; return SymbolInfo(ND->getNameAsString(), Type, FilePath, GetContexts(ND)); } |