Author: Kazu Hirata Date: 2022-06-20T20:26:05-07:00 New Revision: d66cbc565adbea8b7362349e527ac7aa2c75788f
URL: https://github.com/llvm/llvm-project/commit/d66cbc565adbea8b7362349e527ac7aa2c75788f DIFF: https://github.com/llvm/llvm-project/commit/d66cbc565adbea8b7362349e527ac7aa2c75788f.diff LOG: Don't use Optional::hasValue (NFC) Added: Modified: clang/include/clang/APINotes/Types.h clang/include/clang/Basic/DarwinSDKInfo.h clang/lib/Lex/MacroInfo.cpp lldb/tools/lldb-vscode/FifoFiles.cpp llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h llvm/include/llvm/ProfileData/MemProf.h llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h llvm/lib/ObjectYAML/ELFYAML.cpp llvm/lib/Target/SystemZ/SystemZISelLowering.h llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp llvm/tools/llvm-cov/CodeCoverage.cpp mlir/include/mlir/TableGen/CodeGenHelpers.h mlir/lib/Analysis/Presburger/IntegerRelation.cpp mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp mlir/lib/Dialect/Affine/Analysis/Utils.cpp mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp Removed: ################################################################################ diff --git a/clang/include/clang/APINotes/Types.h b/clang/include/clang/APINotes/Types.h index cd02db3da185c..ed5250f3d5b4e 100644 --- a/clang/include/clang/APINotes/Types.h +++ b/clang/include/clang/APINotes/Types.h @@ -440,8 +440,7 @@ class ParamInfo : public VariableInfo { } void setRetainCountConvention(llvm::Optional<RetainCountConventionKind> Value) { - RawRetainCountConvention = - Value.hasValue() ? static_cast<unsigned>(Value.getValue()) + 1 : 0; + RawRetainCountConvention = Value ? static_cast<unsigned>(*Value) + 1 : 0; assert(getRetainCountConvention() == Value && "bitfield too small"); } @@ -559,8 +558,7 @@ class FunctionInfo : public CommonEntityInfo { } void setRetainCountConvention(llvm::Optional<RetainCountConventionKind> Value) { - RawRetainCountConvention = - Value.hasValue() ? static_cast<unsigned>(Value.getValue()) + 1 : 0; + RawRetainCountConvention = Value ? static_cast<unsigned>(*Value) + 1 : 0; assert(getRetainCountConvention() == Value && "bitfield too small"); } diff --git a/clang/include/clang/Basic/DarwinSDKInfo.h b/clang/include/clang/Basic/DarwinSDKInfo.h index df16827debfc0..728bbc17c3acb 100644 --- a/clang/include/clang/Basic/DarwinSDKInfo.h +++ b/clang/include/clang/Basic/DarwinSDKInfo.h @@ -142,8 +142,7 @@ class DarwinSDKInfo { auto Mapping = VersionMappings.find(Kind.Value); if (Mapping == VersionMappings.end()) return nullptr; - return Mapping->getSecond().hasValue() ? Mapping->getSecond().getPointer() - : nullptr; + return Mapping->getSecond() ? Mapping->getSecond().getPointer() : nullptr; } static Optional<DarwinSDKInfo> diff --git a/clang/lib/Lex/MacroInfo.cpp b/clang/lib/Lex/MacroInfo.cpp index f5702130d1819..4a8127d29a459 100644 --- a/clang/lib/Lex/MacroInfo.cpp +++ b/clang/lib/Lex/MacroInfo.cpp @@ -201,8 +201,7 @@ MacroDirective::DefInfo MacroDirective::getDefinition() { Optional<bool> isPublic; for (; MD; MD = MD->getPrevious()) { if (DefMacroDirective *DefMD = dyn_cast<DefMacroDirective>(MD)) - return DefInfo(DefMD, UndefLoc, - !isPublic.hasValue() || isPublic.getValue()); + return DefInfo(DefMD, UndefLoc, !isPublic || *isPublic); if (UndefMacroDirective *UndefMD = dyn_cast<UndefMacroDirective>(MD)) { UndefLoc = UndefMD->getLocation(); diff --git a/lldb/tools/lldb-vscode/FifoFiles.cpp b/lldb/tools/lldb-vscode/FifoFiles.cpp index e37f2020d8f19..b97455ba953fb 100644 --- a/lldb/tools/lldb-vscode/FifoFiles.cpp +++ b/lldb/tools/lldb-vscode/FifoFiles.cpp @@ -61,8 +61,7 @@ Expected<json::Value> FifoFileIO::ReadJSON(std::chrono::milliseconds timeout) { if (!buffer.empty()) line = buffer; })); - if (future->wait_for(timeout) == std::future_status::timeout || - !line.hasValue()) + if (future->wait_for(timeout) == std::future_status::timeout || !line) return createStringError(inconvertibleErrorCode(), "Timed out trying to get messages from the " + m_other_endpoint_name); diff --git a/llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h b/llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h index ed41d2b5b9d4c..a41b2fe2a6e76 100644 --- a/llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h +++ b/llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h @@ -102,9 +102,7 @@ struct FunctionInfo { /// debug info, we might end up with multiple FunctionInfo objects for the /// same range and we need to be able to tell which one is the better object /// to use. - bool hasRichInfo() const { - return OptLineTable.hasValue() || Inline.hasValue(); - } + bool hasRichInfo() const { return OptLineTable || Inline; } /// Query if a FunctionInfo object is valid. /// diff --git a/llvm/include/llvm/ProfileData/MemProf.h b/llvm/include/llvm/ProfileData/MemProf.h index 0406d4fab711e..bcee3b25bf875 100644 --- a/llvm/include/llvm/ProfileData/MemProf.h +++ b/llvm/include/llvm/ProfileData/MemProf.h @@ -221,8 +221,7 @@ struct Frame { void printYAML(raw_ostream &OS) const { OS << " -\n" << " Function: " << Function << "\n" - << " SymbolName: " - << (SymbolName.hasValue() ? SymbolName.getValue() : "<None>") << "\n" + << " SymbolName: " << SymbolName.value_or("<None>") << "\n" << " LineOffset: " << LineOffset << "\n" << " Column: " << Column << "\n" << " Inline: " << IsInlineFrame << "\n"; diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h index 9e3489ea7b191..a26eb98e67508 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h @@ -689,9 +689,7 @@ struct RegsForValue { const DataLayout &DL, unsigned Reg, Type *Ty, Optional<CallingConv::ID> CC); - bool isABIMangled() const { - return CallConv.hasValue(); - } + bool isABIMangled() const { return CallConv.has_value(); } /// Add the specified values to this one. void append(const RegsForValue &RHS) { diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp index f64ee2a8d0445..bcae5a2c4c9ee 100644 --- a/llvm/lib/ObjectYAML/ELFYAML.cpp +++ b/llvm/lib/ObjectYAML/ELFYAML.cpp @@ -1364,8 +1364,7 @@ static void sectionMapping(IO &IO, ELFYAML::HashSection &Section) { // obj2yaml does not dump these fields. They can be used to override nchain // and nbucket values for creating broken sections. - assert(!IO.outputting() || - (!Section.NBucket.hasValue() && !Section.NChain.hasValue())); + assert(!IO.outputting() || (!Section.NBucket && !Section.NChain)); IO.mapOptional("NChain", Section.NChain); IO.mapOptional("NBucket", Section.NBucket); } diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.h b/llvm/lib/Target/SystemZ/SystemZISelLowering.h index 16a0a95ffd3ff..b9c95274f62b8 100644 --- a/llvm/lib/Target/SystemZ/SystemZISelLowering.h +++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.h @@ -419,8 +419,7 @@ class SystemZTargetLowering : public TargetLowering { getNumRegisters(LLVMContext &Context, EVT VT, Optional<MVT> RegisterVT) const override { // i128 inline assembly operand. - if (VT == MVT::i128 && - RegisterVT.hasValue() && RegisterVT.getValue() == MVT::Untyped) + if (VT == MVT::i128 && RegisterVT && *RegisterVT == MVT::Untyped) return 1; return TargetLowering::getNumRegisters(Context, VT); } diff --git a/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp b/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp index 81368bca9bbff..c2c29d9f0ff79 100644 --- a/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp +++ b/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp @@ -701,8 +701,7 @@ PreservedAnalyses LoopSimplifyCFGPass::run(Loop &L, LoopAnalysisManager &AM, MSSAU = MemorySSAUpdater(AR.MSSA); bool DeleteCurrentLoop = false; if (!simplifyLoopCFG(L, AR.DT, AR.LI, AR.SE, - MSSAU.hasValue() ? MSSAU.getPointer() : nullptr, - DeleteCurrentLoop)) + MSSAU ? MSSAU.getPointer() : nullptr, DeleteCurrentLoop)) return PreservedAnalyses::all(); if (DeleteCurrentLoop) diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp index 273ebe0659e9d..e37d7c0dc1893 100644 --- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp +++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp @@ -3151,8 +3151,7 @@ PreservedAnalyses SimpleLoopUnswitchPass::run(Loop &L, LoopAnalysisManager &AM, AR.MSSA->verifyMemorySSA(); } if (!unswitchLoop(L, AR.DT, AR.LI, AR.AC, AR.AA, AR.TTI, Trivial, NonTrivial, - UnswitchCB, &AR.SE, - MSSAU.hasValue() ? MSSAU.getPointer() : nullptr, + UnswitchCB, &AR.SE, MSSAU ? MSSAU.getPointer() : nullptr, DestroyLoopCB)) return PreservedAnalyses::all(); diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp index b333f7f0f2e68..6932e9b5bd31a 100644 --- a/llvm/tools/llvm-cov/CodeCoverage.cpp +++ b/llvm/tools/llvm-cov/CodeCoverage.cpp @@ -265,8 +265,7 @@ bool CodeCoverageTool::isEquivalentFile(StringRef FilePath1, StringRef FilePath2) { auto Status1 = getFileStatus(FilePath1); auto Status2 = getFileStatus(FilePath2); - return Status1.hasValue() && Status2.hasValue() && - sys::fs::equivalent(Status1.getValue(), Status2.getValue()); + return Status1 && Status2 && sys::fs::equivalent(*Status1, *Status2); } ErrorOr<const MemoryBuffer &> diff --git a/mlir/include/mlir/TableGen/CodeGenHelpers.h b/mlir/include/mlir/TableGen/CodeGenHelpers.h index 69b3a897fc38d..3f55e3b374f45 100644 --- a/mlir/include/mlir/TableGen/CodeGenHelpers.h +++ b/mlir/include/mlir/TableGen/CodeGenHelpers.h @@ -229,8 +229,7 @@ template <> struct stringifier<Twine> { template <typename OptionalT> struct stringifier<Optional<OptionalT>> { static std::string apply(Optional<OptionalT> optional) { - return optional.hasValue() ? stringifier<OptionalT>::apply(*optional) - : std::string(); + return optional ? stringifier<OptionalT>::apply(*optional) : std::string(); } }; } // namespace detail diff --git a/mlir/lib/Analysis/Presburger/IntegerRelation.cpp b/mlir/lib/Analysis/Presburger/IntegerRelation.cpp index 6411a04fb2d08..fc2fbd5b634d9 100644 --- a/mlir/lib/Analysis/Presburger/IntegerRelation.cpp +++ b/mlir/lib/Analysis/Presburger/IntegerRelation.cpp @@ -626,9 +626,7 @@ Matrix IntegerRelation::getBoundedDirections() const { return dirs; } -bool IntegerRelation::isIntegerEmpty() const { - return !findIntegerSample().hasValue(); -} +bool IntegerRelation::isIntegerEmpty() const { return !findIntegerSample(); } /// Let this set be S. If S is bounded then we directly call into the GBR /// sampling algorithm. Otherwise, there are some unbounded directions, i.e., diff --git a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp index 65d3862dd4c46..1a830b9483003 100644 --- a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp +++ b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp @@ -251,8 +251,7 @@ static Optional<Type> convertArrayType(spirv::ArrayType type, unsigned stride = type.getArrayStride(); Type elementType = type.getElementType(); auto sizeInBytes = elementType.cast<spirv::SPIRVType>().getSizeInBytes(); - if (stride != 0 && - !(sizeInBytes.hasValue() && sizeInBytes.getValue() == stride)) + if (stride != 0 && !(sizeInBytes && *sizeInBytes == stride)) return llvm::None; auto llvmElementType = converter.convertType(elementType); diff --git a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp index a0a9fc75fcb16..00331a920c5f0 100644 --- a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp +++ b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp @@ -1134,8 +1134,7 @@ void mlir::getComputationSliceState( // 3. Is being inserted at the innermost insertion point. Optional<bool> isMaximal = sliceState->isMaximal(); if (isLoopParallelAndContainsReduction(getSliceLoop(i)) && - isInnermostInsertion() && srcIsUnitSlice() && isMaximal.hasValue() && - isMaximal.getValue()) + isInnermostInsertion() && srcIsUnitSlice() && isMaximal && *isMaximal) continue; for (unsigned j = i; j < numSliceLoopIVs; ++j) { sliceState->lbs[j] = AffineMap(); diff --git a/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp b/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp index bcd9b5dff8ac9..9d22053f19f94 100644 --- a/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp @@ -1297,9 +1297,7 @@ static bool isFusionProfitable(Operation *srcOpInst, Operation *srcStoreOpInst, msg << " fusion is most profitable at depth " << *dstLoopDepth << " with " << std::setprecision(2) << additionalComputeFraction << "% redundant computation and a "; - msg << (storageReduction.hasValue() - ? std::to_string(storageReduction.getValue()) - : "<unknown>"); + msg << (storageReduction ? std::to_string(*storageReduction) : "<unknown>"); msg << "% storage reduction.\n"; llvm::dbgs() << msg.str(); }); diff --git a/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp b/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp index 7452647a524e8..ea10dbb3f26ec 100644 --- a/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp +++ b/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp @@ -1108,8 +1108,7 @@ LogicalResult mlir::loopUnrollByFactor( // If the trip count is lower than the unroll factor, no unrolled body. // TODO: option to specify cleanup loop unrolling. - if (mayBeConstantTripCount.hasValue() && - mayBeConstantTripCount.getValue() < unrollFactor) + if (mayBeConstantTripCount && *mayBeConstantTripCount < unrollFactor) return failure(); // Generate the cleanup loop if trip count isn't a multiple of unrollFactor. @@ -1216,8 +1215,7 @@ LogicalResult mlir::loopUnrollJamByFactor(AffineForOp forOp, return success(); // If the trip count is lower than the unroll jam factor, no unroll jam. - if (mayBeConstantTripCount.hasValue() && - mayBeConstantTripCount.getValue() < unrollJamFactor) { + if (mayBeConstantTripCount && *mayBeConstantTripCount < unrollJamFactor) { LLVM_DEBUG(llvm::dbgs() << "[failed] trip count < unroll-jam factor\n"); return failure(); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits