Return None instead of Optional<T>() (NFC)
authorKazu Hirata <kazu@google.com>
Tue, 22 Nov 2022 03:06:42 +0000 (19:06 -0800)
committerKazu Hirata <kazu@google.com>
Tue, 22 Nov 2022 03:06:42 +0000 (19:06 -0800)
commit6ba4b62af8df00edb7e1cc0c473f6770fb1cfe3b
tree8f6741f9b0cdd8b892c83c78614e861d9ec325ad
parent1f914944b6c9a5e4229ceb9f06140fdf178c5ea0
Return None instead of Optional<T>() (NFC)

This patch replaces:

  return Optional<T>();

with:

  return None;

to make the migration from llvm::Optional to std::optional easier.
Specifically, I can deprecate None (in my source tree, that is) to
identify all the instances of None that should be replaced with
std::nullopt.

Note that "return None" far outnumbers "return Optional<T>();".  There
are more than 2000 instances of "return None" in our source tree.

All of the instances in this patch come from functions that return
Optional<T> except Archive::findSym and ASTNodeImporter::import, where
we return Expected<Optional<T>>.  Note that we can construct
Expected<Optional<T>> from any parameter convertible to Optional<T>,
which None certainly is.

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

Differential Revision: https://reviews.llvm.org/D138464
22 files changed:
clang/include/clang/AST/ASTImporterSharedState.h
clang/lib/AST/ASTImporter.cpp
clang/lib/ASTMatchers/Dynamic/Parser.cpp
clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
clang/lib/CodeGen/CodeGenAction.cpp
clang/lib/Driver/ToolChains/AVR.cpp
clang/lib/Driver/ToolChains/Arch/CSKY.cpp
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
llvm/lib/CodeGen/SelectOptimize.cpp
llvm/lib/DebugInfo/PDB/DIA/DIADataStream.cpp
llvm/lib/IR/BasicBlock.cpp
llvm/lib/LineEditor/LineEditor.cpp
llvm/lib/MC/MCSubtargetInfo.cpp
llvm/lib/Object/Archive.cpp
llvm/lib/Support/Z3Solver.cpp
llvm/lib/TableGen/Record.cpp
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
llvm/lib/Target/PowerPC/PPCFastISel.cpp
llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.cpp
mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp
mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp