[PATCH] D138464: Return None instead of Optional<T>() (NFC)
Kazu Hirata via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 21 17:49:57 PST 2022
kazu created this revision.
Herald added subscribers: Moerafaat, zero9178, bzcheeseman, ThomasRaoux, pmatos, asb, sdasgup3, wenzhicui, wrengr, jsetoain, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, antiagainst, shauheen, rriddle, mehdi_amini, Jim, martong, kbarton, hiraditya, jgravelle-google, sbc100, nemanjai, dylanmckay, dschuff.
Herald added a reviewer: shafik.
Herald added a reviewer: aartbik.
Herald added a project: All.
kazu requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, stephenneuendorffer, nicolasvasilache, MaskRay, aheejin.
Herald added a reviewer: nicolasvasilache.
Herald added a reviewer: dcaballe.
Herald added projects: clang, MLIR, LLVM.
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
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D138464
Files:
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138464.477039.patch
Type: text/x-patch
Size: 12722 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221122/c7981b4d/attachment.bin>
More information about the cfe-commits
mailing list