From 91682b2631b224a9f6dca9512b5e0951cc4a7762 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sat, 14 Jan 2023 14:06:18 -0800 Subject: [PATCH] Remove redundant initialization of std::optional (NFC) --- clang-tools-extra/clangd/ClangdServer.h | 2 +- flang/include/flang/Lower/ComponentPath.h | 2 +- flang/lib/Lower/Bridge.cpp | 2 +- flang/lib/Lower/CallInterface.cpp | 2 +- lld/MachO/LTO.cpp | 2 +- lldb/include/lldb/Core/DataFileCache.h | 6 +++--- lldb/include/lldb/Host/File.h | 8 ++++---- lldb/include/lldb/Target/TraceDumper.h | 4 ++-- lldb/source/Plugins/Trace/intel-pt/DecodedThread.h | 2 +- .../Plugins/Trace/intel-pt/TraceIntelPTConstants.h | 2 +- .../mlir/Dialect/Linalg/Transforms/Transforms.h | 18 +++++++++--------- mlir/include/mlir/ExecutionEngine/ExecutionEngine.h | 2 +- .../Bufferization/Transforms/OneShotAnalysis.cpp | 2 +- .../Dialect/SparseTensor/IR/SparseTensorDialect.cpp | 2 +- .../Transforms/SparseStorageSpecifierToLLVM.cpp | 2 +- mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp | 2 +- 16 files changed, 30 insertions(+), 30 deletions(-) diff --git a/clang-tools-extra/clangd/ClangdServer.h b/clang-tools-extra/clangd/ClangdServer.h index 360967d..b87ff0b 100644 --- a/clang-tools-extra/clangd/ClangdServer.h +++ b/clang-tools-extra/clangd/ClangdServer.h @@ -142,7 +142,7 @@ public: /// defaults and -resource-dir compiler flag). /// If None, ClangdServer calls CompilerInvocation::GetResourcePath() to /// obtain the standard resource directory. - std::optional ResourceDir = std::nullopt; + std::optional 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 69960bad..daf65db 100644 --- a/flang/include/flang/Lower/ComponentPath.h +++ b/flang/include/flang/Lower/ComponentPath.h @@ -69,7 +69,7 @@ public: /// 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 extendCoorRef = std::nullopt; + std::optional extendCoorRef; private: void setPC(bool isImplicit); diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp index b729b47..71e06ed 100644 --- a/flang/lib/Lower/Bridge.cpp +++ b/flang/lib/Lower/Bridge.cpp @@ -1043,7 +1043,7 @@ private: assert(stmt.typedCall && "Call was not analyzed"); mlir::Value res{}; if (bridge.getLoweringOptions().getLowerToHighLevelFIR()) { - std::optional resultType = std::nullopt; + std::optional 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 2034c7c..bc9967f 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 Fortran::lower::CallerInterface::getPassArgIndex() const { unsigned passArgIdx = 0; - std::optional passArg = std::nullopt; + std::optional 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 565a66d..2f5e9d0 100644 --- a/lld/MachO/LTO.cpp +++ b/lld/MachO/LTO.cpp @@ -278,7 +278,7 @@ std::vector BitcodeCompiler::compile() { // not use the cached MemoryBuffer directly to ensure dsymutil does not // race with the cache pruner. StringRef objBuf; - std::optional cachePath = std::nullopt; + std::optional 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 5b63443..8a233af 100644 --- a/lldb/include/lldb/Core/DataFileCache.h +++ b/lldb/include/lldb/Core/DataFileCache.h @@ -108,13 +108,13 @@ private: /// it is out of date. struct CacheSignature { /// UUID of object file or module. - std::optional m_uuid = std::nullopt; + std::optional m_uuid; /// Modification time of file on disk. - std::optional m_mod_time = std::nullopt; + std::optional 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 m_obj_mod_time = std::nullopt; + std::optional m_obj_mod_time; CacheSignature() = default; diff --git a/lldb/include/lldb/Host/File.h b/lldb/include/lldb/Host/File.h index ba5772d..b2e7ebf 100644 --- a/lldb/include/lldb/Host/File.h +++ b/lldb/include/lldb/Host/File.h @@ -438,10 +438,10 @@ private: class SerialPort : public NativeFile { public: struct Options { - std::optional BaudRate = std::nullopt; - std::optional Parity = std::nullopt; - std::optional ParityCheck = std::nullopt; - std::optional StopBits = std::nullopt; + std::optional BaudRate; + std::optional Parity; + std::optional ParityCheck; + std::optional 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 72dcf64..ca3bf2c 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 id = std::nullopt; + std::optional id; /// Optional number of instructions to skip from the starting position /// of the cursor. - std::optional skip = std::nullopt; + std::optional 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 230baf3..b2a674a 100644 --- a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h +++ b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h @@ -312,7 +312,7 @@ private: // cpu is seen. std::map m_cpus; /// This is the chronologically last CPU ID. - std::optional m_last_cpu = std::nullopt; + std::optional m_last_cpu; // The PSB offsets are stored as a map. It maps `item index -> psb offset`. llvm::DenseMap m_psb_offsets; diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTConstants.h b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTConstants.h index e1a35c6..e80f512 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 kDefaultPsbPeriod = std::nullopt; +const std::optional 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 f85e607..b469277 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> operandsToPromote = std::nullopt; + std::optional> operandsToPromote; LinalgPromotionOptions &setOperandsToPromote(ArrayRef operands) { operandsToPromote = DenseSet(); 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 useFullTileBuffers = std::nullopt; + std::optional useFullTileBuffers; LinalgPromotionOptions &setUseFullTileBuffers(ArrayRef 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 alignment = std::nullopt; + std::optional 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 buffer followed by a view operation is used. - std::optional allocationFn = std::nullopt; - std::optional deallocationFn = std::nullopt; + std::optional allocationFn; + std::optional 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 copyInFn = std::nullopt; - std::optional copyOutFn = std::nullopt; + std::optional copyInFn; + std::optional copyOutFn; LinalgPromotionOptions &setCopyInOutFns(CopyCallbackFn const ©In, CopyCallbackFn const ©Out) { copyInFn = copyIn; @@ -626,7 +626,7 @@ struct LinalgTilingAndFusionOptions { SmallVector tileInterchange; /// When specified, specifies distribution of generated tile loops to /// processors. - std::optional tileDistribution = std::nullopt; + std::optional 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 distribution = std::nullopt; + std::optional distribution; LinalgTilingOptions & setDistributionOptions(LinalgLoopDistributionOptions distributionOptions) { diff --git a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h index 957a4b9..13d3c0f6 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 jitCodeGenOptLevel = std::nullopt; + std::optional 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 11ec604..ef87fa9 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 &usesRead, const DenseSet &usesWrite, const AnalysisState &state) { const BufferizationOptions &options = state.getOptions(); - std::optional commonEnclosingRegion = std::nullopt; + std::optional 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 b15c9c5..5ea4f7c 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 dim) const { - std::optional intDim = std::nullopt; + std::optional 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 d5d9dab..791f7f2 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseStorageSpecifierToLLVM.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseStorageSpecifierToLLVM.cpp @@ -140,7 +140,7 @@ public: } else { auto enc = op.getSpecifier().getType().getEncoding(); StorageLayout layout(enc); - std::optional dim = std::nullopt; + std::optional 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 e022e5f..fc11e81 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 getUniqueNonUnitDim(ArrayRef indices, ArrayRef shape) { // Return false if more than one of the dimensions in this group are not 1. - std::optional dimIndex = std::nullopt; + std::optional dimIndex; if (indices.size() < 2) return std::nullopt; for (int64_t idx : indices) { -- 2.7.4