[all-commits] [llvm/llvm-project] 6ba4b6: Return None instead of Optional<T>() (NFC)

kazutakahirata via All-commits all-commits at lists.llvm.org
Mon Nov 21 19:06:56 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6ba4b62af8df00edb7e1cc0c473f6770fb1cfe3b
      https://github.com/llvm/llvm-project/commit/6ba4b62af8df00edb7e1cc0c473f6770fb1cfe3b
  Author: Kazu Hirata <kazu at google.com>
  Date:   2022-11-21 (Mon, 21 Nov 2022)

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

  Log Message:
  -----------
  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




More information about the All-commits mailing list