[flang-commits] [flang] 91682b2 - Remove redundant initialization of std::optional (NFC)
Kazu Hirata via flang-commits
flang-commits at lists.llvm.org
Sat Jan 14 14:06:27 PST 2023
Author: Kazu Hirata
Date: 2023-01-14T14:06:18-08:00
New Revision: 91682b2631b224a9f6dca9512b5e0951cc4a7762
URL: https://github.com/llvm/llvm-project/commit/91682b2631b224a9f6dca9512b5e0951cc4a7762
DIFF: https://github.com/llvm/llvm-project/commit/91682b2631b224a9f6dca9512b5e0951cc4a7762.diff
LOG: Remove redundant initialization of std::optional (NFC)
Added:
Modified:
clang-tools-extra/clangd/ClangdServer.h
flang/include/flang/Lower/ComponentPath.h
flang/lib/Lower/Bridge.cpp
flang/lib/Lower/CallInterface.cpp
lld/MachO/LTO.cpp
lldb/include/lldb/Core/DataFileCache.h
lldb/include/lldb/Host/File.h
lldb/include/lldb/Target/TraceDumper.h
lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTConstants.h
mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp
mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
mlir/lib/Dialect/SparseTensor/Transforms/SparseStorageSpecifierToLLVM.cpp
mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/ClangdServer.h b/clang-tools-extra/clangd/ClangdServer.h
index 360967de40ada..b87ff0bf54b70 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -142,7 +142,7 @@ class ClangdServer {
/// defaults and -resource-dir compiler flag).
/// If None, ClangdServer calls CompilerInvocation::GetResourcePath() to
/// obtain the standard resource directory.
- std::optional<std::string> ResourceDir = std::nullopt;
+ std::optional<std::string> ResourceDir;
/// Time to wait after a new file version before computing diagnostics.
DebouncePolicy UpdateDebounce = DebouncePolicy{
diff --git a/flang/include/flang/Lower/ComponentPath.h b/flang/include/flang/Lower/ComponentPath.h
index 69960bad4e056..daf65db79dc7e 100644
--- a/flang/include/flang/Lower/ComponentPath.h
+++ b/flang/include/flang/Lower/ComponentPath.h
@@ -69,7 +69,7 @@ class ComponentPath {
/// This optional continuation allows the generation of those dereferences.
/// These accesses are always on Fortran entities of record types, which are
/// implicitly in-memory objects.
- std::optional<ExtendRefFunc> extendCoorRef = std::nullopt;
+ std::optional<ExtendRefFunc> extendCoorRef;
private:
void setPC(bool isImplicit);
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index b729b47465709..71e06ed347cdc 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -1043,7 +1043,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
assert(stmt.typedCall && "Call was not analyzed");
mlir::Value res{};
if (bridge.getLoweringOptions().getLowerToHighLevelFIR()) {
- std::optional<mlir::Type> resultType = std::nullopt;
+ std::optional<mlir::Type> resultType;
if (stmt.typedCall->hasAlternateReturns())
resultType = builder->getIndexType();
auto hlfirRes = Fortran::lower::convertCallToHLFIR(
diff --git a/flang/lib/Lower/CallInterface.cpp b/flang/lib/Lower/CallInterface.cpp
index 2034c7c6055e1..bc9967f3e64e6 100644
--- a/flang/lib/Lower/CallInterface.cpp
+++ b/flang/lib/Lower/CallInterface.cpp
@@ -108,7 +108,7 @@ bool Fortran::lower::CallerInterface::requireDispatchCall() const {
std::optional<unsigned>
Fortran::lower::CallerInterface::getPassArgIndex() const {
unsigned passArgIdx = 0;
- std::optional<unsigned> passArg = std::nullopt;
+ std::optional<unsigned> passArg;
for (const auto &arg : getCallDescription().arguments()) {
if (arg && arg->isPassedObject()) {
passArg = passArgIdx;
diff --git a/lld/MachO/LTO.cpp b/lld/MachO/LTO.cpp
index 565a66df38b97..2f5e9d06f396f 100644
--- a/lld/MachO/LTO.cpp
+++ b/lld/MachO/LTO.cpp
@@ -278,7 +278,7 @@ std::vector<ObjFile *> BitcodeCompiler::compile() {
// not use the cached MemoryBuffer directly to ensure dsymutil does not
// race with the cache pruner.
StringRef objBuf;
- std::optional<StringRef> cachePath = std::nullopt;
+ std::optional<StringRef> cachePath;
if (files[i]) {
objBuf = files[i]->getBuffer();
cachePath = files[i]->getBufferIdentifier();
diff --git a/lldb/include/lldb/Core/DataFileCache.h b/lldb/include/lldb/Core/DataFileCache.h
index 5b634435ad768..8a233afaff386 100644
--- a/lldb/include/lldb/Core/DataFileCache.h
+++ b/lldb/include/lldb/Core/DataFileCache.h
@@ -108,13 +108,13 @@ class DataFileCache {
/// it is out of date.
struct CacheSignature {
/// UUID of object file or module.
- std::optional<UUID> m_uuid = std::nullopt;
+ std::optional<UUID> m_uuid;
/// Modification time of file on disk.
- std::optional<std::time_t> m_mod_time = std::nullopt;
+ std::optional<std::time_t> m_mod_time;
/// If this describes a .o file with a BSD archive, the BSD archive's
/// modification time will be in m_mod_time, and the .o file's modification
/// time will be in this m_obj_mod_time.
- std::optional<std::time_t> m_obj_mod_time = std::nullopt;
+ std::optional<std::time_t> m_obj_mod_time;
CacheSignature() = default;
diff --git a/lldb/include/lldb/Host/File.h b/lldb/include/lldb/Host/File.h
index ba5772dfe10af..b2e7ebf5bba35 100644
--- a/lldb/include/lldb/Host/File.h
+++ b/lldb/include/lldb/Host/File.h
@@ -438,10 +438,10 @@ class NativeFile : public File {
class SerialPort : public NativeFile {
public:
struct Options {
- std::optional<unsigned int> BaudRate = std::nullopt;
- std::optional<Terminal::Parity> Parity = std::nullopt;
- std::optional<Terminal::ParityCheck> ParityCheck = std::nullopt;
- std::optional<unsigned int> StopBits = std::nullopt;
+ std::optional<unsigned int> BaudRate;
+ std::optional<Terminal::Parity> Parity;
+ std::optional<Terminal::ParityCheck> ParityCheck;
+ std::optional<unsigned int> StopBits;
};
// Obtain Options corresponding to the passed URL query string
diff --git a/lldb/include/lldb/Target/TraceDumper.h b/lldb/include/lldb/Target/TraceDumper.h
index 72dcf64a05ef0..ca3bf2c088088 100644
--- a/lldb/include/lldb/Target/TraceDumper.h
+++ b/lldb/include/lldb/Target/TraceDumper.h
@@ -39,10 +39,10 @@ struct TraceDumperOptions {
/// For each instruction, print the instruction kind.
bool show_control_flow_kind = false;
/// Optional custom id to start traversing from.
- std::optional<uint64_t> id = std::nullopt;
+ std::optional<uint64_t> id;
/// Optional number of instructions to skip from the starting position
/// of the cursor.
- std::optional<size_t> skip = std::nullopt;
+ std::optional<size_t> skip;
};
/// Class used to dump the instructions of a \a TraceCursor using its current
diff --git a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
index 230baf363dc6d..b2a674aca1826 100644
--- a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
+++ b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
@@ -312,7 +312,7 @@ class DecodedThread : public std::enable_shared_from_this<DecodedThread> {
// cpu is seen.
std::map<uint64_t, lldb::cpu_id_t> m_cpus;
/// This is the chronologically last CPU ID.
- std::optional<uint64_t> m_last_cpu = std::nullopt;
+ std::optional<uint64_t> m_last_cpu;
// The PSB offsets are stored as a map. It maps `item index -> psb offset`.
llvm::DenseMap<uint64_t, lldb::addr_t> m_psb_offsets;
diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTConstants.h b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTConstants.h
index e1a35c6f121ac..e80f512457cf2 100644
--- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTConstants.h
+++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTConstants.h
@@ -19,7 +19,7 @@ namespace trace_intel_pt {
const size_t kDefaultIptTraceSize = 4 * 1024; // 4KB
const size_t kDefaultProcessBufferSizeLimit = 5 * 1024 * 1024; // 500MB
const bool kDefaultEnableTscValue = false;
-const std::optional<size_t> kDefaultPsbPeriod = std::nullopt;
+const std::optional<size_t> kDefaultPsbPeriod;
const bool kDefaultPerCpuTracing = false;
const bool kDefaultDisableCgroupFiltering = false;
diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
index f85e607f893fa..b4692776a61bd 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
@@ -266,7 +266,7 @@ using CopyCallbackFn =
struct LinalgPromotionOptions {
/// Indices of subViews to promote. If `std::nullopt`, try to promote all
/// operands.
- std::optional<DenseSet<unsigned>> operandsToPromote = std::nullopt;
+ std::optional<DenseSet<unsigned>> operandsToPromote;
LinalgPromotionOptions &setOperandsToPromote(ArrayRef<int64_t> operands) {
operandsToPromote = DenseSet<unsigned>();
operandsToPromote->insert(operands.begin(), operands.end());
@@ -277,7 +277,7 @@ struct LinalgPromotionOptions {
/// Otherwise the partial view will be used. The decision is defaulted to
/// `useFullTileBuffersDefault` when `useFullTileBuffers` is None and for
/// operands missing from `useFullTileBuffers`.
- std::optional<llvm::SmallBitVector> useFullTileBuffers = std::nullopt;
+ std::optional<llvm::SmallBitVector> useFullTileBuffers;
LinalgPromotionOptions &setUseFullTileBuffers(ArrayRef<bool> useFullTiles) {
unsigned size = useFullTiles.size();
llvm::SmallBitVector tmp(size, false);
@@ -294,7 +294,7 @@ struct LinalgPromotionOptions {
return *this;
}
/// Alignment of promoted buffer. If `std::nullopt` do not specify alignment.
- std::optional<unsigned> alignment = std::nullopt;
+ std::optional<unsigned> alignment;
LinalgPromotionOptions &setAlignment(unsigned align) {
alignment = align;
return *this;
@@ -308,8 +308,8 @@ struct LinalgPromotionOptions {
/// Callback function to do the allocation of the promoted buffer. If
/// std::nullopt, then the default allocation scheme of allocating a
/// memref<?xi8> buffer followed by a view operation is used.
- std::optional<AllocBufferCallbackFn> allocationFn = std::nullopt;
- std::optional<DeallocBufferCallbackFn> deallocationFn = std::nullopt;
+ std::optional<AllocBufferCallbackFn> allocationFn;
+ std::optional<DeallocBufferCallbackFn> deallocationFn;
LinalgPromotionOptions &
setAllocationDeallocationFns(AllocBufferCallbackFn const &allocFn,
DeallocBufferCallbackFn const &deallocFn) {
@@ -319,8 +319,8 @@ struct LinalgPromotionOptions {
}
/// Callback function to do the copy of data to and from the promoted
/// subview. If std::nullopt then a memref.copy is used.
- std::optional<CopyCallbackFn> copyInFn = std::nullopt;
- std::optional<CopyCallbackFn> copyOutFn = std::nullopt;
+ std::optional<CopyCallbackFn> copyInFn;
+ std::optional<CopyCallbackFn> copyOutFn;
LinalgPromotionOptions &setCopyInOutFns(CopyCallbackFn const ©In,
CopyCallbackFn const ©Out) {
copyInFn = copyIn;
@@ -626,7 +626,7 @@ struct LinalgTilingAndFusionOptions {
SmallVector<int64_t> tileInterchange;
/// When specified, specifies distribution of generated tile loops to
/// processors.
- std::optional<LinalgLoopDistributionOptions> tileDistribution = std::nullopt;
+ std::optional<LinalgLoopDistributionOptions> tileDistribution;
LinalgTilingAndFusionOptions &
setDistributionOptions(LinalgLoopDistributionOptions distributionOptions) {
tileDistribution = std::move(distributionOptions);
@@ -679,7 +679,7 @@ struct LinalgTilingOptions {
/// When specified, specifies distribution of generated tile loops to
/// processors.
- std::optional<LinalgLoopDistributionOptions> distribution = std::nullopt;
+ std::optional<LinalgLoopDistributionOptions> distribution;
LinalgTilingOptions &
setDistributionOptions(LinalgLoopDistributionOptions distributionOptions) {
diff --git a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
index 957a4b99899a6..13d3c0f6f7ee0 100644
--- a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
+++ b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
@@ -68,7 +68,7 @@ struct ExecutionEngineOptions {
/// `jitCodeGenOptLevel`, when provided, is used as the optimization level for
/// target code generation.
- std::optional<llvm::CodeGenOpt::Level> jitCodeGenOptLevel = std::nullopt;
+ std::optional<llvm::CodeGenOpt::Level> jitCodeGenOptLevel;
/// If `sharedLibPaths` are provided, the underlying JIT-compilation will
/// open and link the shared libraries for symbol resolution.
diff --git a/mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp b/mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp
index 11ec6047b19e4..ef87fa9011707 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp
@@ -455,7 +455,7 @@ bool canUseOpDominance(const DenseSet<OpOperand *> &usesRead,
const DenseSet<OpOperand *> &usesWrite,
const AnalysisState &state) {
const BufferizationOptions &options = state.getOptions();
- std::optional<Region *> commonEnclosingRegion = std::nullopt;
+ std::optional<Region *> commonEnclosingRegion;
// In case of a write, take the region in which the write takes place.
for (OpOperand *uWrite : usesWrite) {
diff --git a/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp b/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
index b15c9c5386871..5ea4f7ca63eae 100644
--- a/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
+++ b/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
@@ -541,7 +541,7 @@ Type StorageSpecifierType::getFieldType(StorageSpecifierKind kind,
Type StorageSpecifierType::getFieldType(StorageSpecifierKind kind,
std::optional<APInt> dim) const {
- std::optional<unsigned> intDim = std::nullopt;
+ std::optional<unsigned> intDim;
if (dim)
intDim = dim.value().getZExtValue();
return getFieldType(kind, intDim);
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseStorageSpecifierToLLVM.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseStorageSpecifierToLLVM.cpp
index d5d9dab22fb45..791f7f245e5ec 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseStorageSpecifierToLLVM.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseStorageSpecifierToLLVM.cpp
@@ -140,7 +140,7 @@ class SpecifierGetterSetterOpConverter : public OpConversionPattern<SourceOp> {
} else {
auto enc = op.getSpecifier().getType().getEncoding();
StorageLayout layout(enc);
- std::optional<unsigned> dim = std::nullopt;
+ std::optional<unsigned> dim;
if (op.getDim())
dim = op.getDim().value().getZExtValue();
unsigned idx = layout.getMemRefFieldIndex(op.getSpecifierKind(), dim);
diff --git a/mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp b/mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp
index e022e5f47ea22..fc11e814ef6c5 100644
--- a/mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp
+++ b/mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp
@@ -360,7 +360,7 @@ SliceFromCollapseHelper::getInsertSliceParams(MLIRContext *ctx,
static std::optional<int64_t> getUniqueNonUnitDim(ArrayRef<int64_t> indices,
ArrayRef<int64_t> shape) {
// Return false if more than one of the dimensions in this group are not 1.
- std::optional<int64_t> dimIndex = std::nullopt;
+ std::optional<int64_t> dimIndex;
if (indices.size() < 2)
return std::nullopt;
for (int64_t idx : indices) {
More information about the flang-commits
mailing list