Author: Kazu Hirata Date: 2022-06-20T20:17:57-07:00 New Revision: 0916d96d12fda355933a8f66ed2a1ccc855cab9c
URL: https://github.com/llvm/llvm-project/commit/0916d96d12fda355933a8f66ed2a1ccc855cab9c DIFF: https://github.com/llvm/llvm-project/commit/0916d96d12fda355933a8f66ed2a1ccc855cab9c.diff LOG: Don't use Optional::hasValue (NFC) Added: Modified: clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp clang-tools-extra/clangd/CodeComplete.cpp clang-tools-extra/clangd/Quality.cpp clang-tools-extra/clangd/TUScheduler.cpp clang-tools-extra/clangd/tool/Check.cpp clang/include/clang/APINotes/Types.h clang/include/clang/AST/Type.h clang/lib/AST/ExprCXX.cpp clang/lib/ASTMatchers/ASTMatchFinder.cpp clang/lib/Lex/HeaderSearch.cpp clang/lib/Sema/SemaExprCXX.cpp clang/lib/StaticAnalyzer/Core/CallEvent.cpp clang/lib/StaticAnalyzer/Core/RegionStore.cpp clang/lib/Tooling/Syntax/BuildTree.cpp clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp flang/lib/Lower/IO.cpp flang/lib/Optimizer/Dialect/FIROps.cpp lldb/source/Interpreter/CommandInterpreter.cpp lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp lldb/source/Symbol/CompileUnit.cpp llvm/include/llvm/Analysis/InlineAdvisor.h llvm/include/llvm/Analysis/ObjCARCUtil.h llvm/include/llvm/DebugInfo/CodeView/TypeCollection.h llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h llvm/lib/Analysis/ScalarEvolution.cpp llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp llvm/lib/CodeGen/ExpandMemCmp.cpp llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/lib/CodeGen/ShadowStackGCLowering.cpp llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp llvm/lib/IR/ConstantFold.cpp llvm/lib/IR/DebugInfoMetadata.cpp llvm/lib/IR/VectorBuilder.cpp llvm/lib/IR/Verifier.cpp llvm/lib/MC/MCDwarf.cpp llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp llvm/lib/Target/ARM/ARMISelLowering.cpp llvm/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.cpp llvm/lib/Target/RISCV/RISCVISelLowering.cpp llvm/lib/Transforms/IPO/AttributorAttributes.cpp llvm/lib/Transforms/IPO/IROutliner.cpp llvm/lib/Transforms/Scalar/LoopFlatten.cpp llvm/lib/Transforms/Scalar/LoopInstSimplify.cpp llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp mlir/lib/TableGen/AttrOrTypeDef.cpp mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp index 200528b1c061d..1efd88d7cbb95 100644 --- a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp @@ -799,7 +799,7 @@ void NotNullTerminatedResultCheck::check( Optional<bool> AreSafeFunctionsWanted; Preprocessor::macro_iterator It = PP->macro_begin(); - while (It != PP->macro_end() && !AreSafeFunctionsWanted.hasValue()) { + while (It != PP->macro_end() && !AreSafeFunctionsWanted) { if (It->first->getName() == "__STDC_WANT_LIB_EXT1__") { const auto *MI = PP->getMacroInfo(It->first); // PP->getMacroInfo() returns nullptr if macro has no definition. diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp index eaf570da88da8..fbd7488c07d21 100644 --- a/clang-tools-extra/clangd/CodeComplete.cpp +++ b/clang-tools-extra/clangd/CodeComplete.cpp @@ -375,7 +375,7 @@ struct CodeCompletionBuilder { std::move(*Spelled), Includes.shouldInsertInclude(*ResolvedDeclaring, *ResolvedInserted)); }; - bool ShouldInsert = C.headerToInsertIfAllowed(Opts).hasValue(); + bool ShouldInsert = C.headerToInsertIfAllowed(Opts).has_value(); // Calculate include paths and edits for all possible headers. for (const auto &Inc : C.RankedIncludeHeaders) { if (auto ToInclude = Inserted(Inc)) { diff --git a/clang-tools-extra/clangd/Quality.cpp b/clang-tools-extra/clangd/Quality.cpp index 42eee14d28f42..0024e63955334 100644 --- a/clang-tools-extra/clangd/Quality.cpp +++ b/clang-tools-extra/clangd/Quality.cpp @@ -378,7 +378,7 @@ wordMatching(llvm::StringRef Name, const llvm::StringSet<> *ContextWords) { SymbolRelevanceSignals::DerivedSignals SymbolRelevanceSignals::calculateDerivedSignals() const { DerivedSignals Derived; - Derived.NameMatchesContext = wordMatching(Name, ContextWords).hasValue(); + Derived.NameMatchesContext = wordMatching(Name, ContextWords).has_value(); Derived.FileProximityDistance = !FileProximityMatch || SymbolURI.empty() ? FileDistance::Unreachable : FileProximityMatch->distance(SymbolURI); diff --git a/clang-tools-extra/clangd/TUScheduler.cpp b/clang-tools-extra/clangd/TUScheduler.cpp index 4bdcf0f3c80cd..49d850ad96a09 100644 --- a/clang-tools-extra/clangd/TUScheduler.cpp +++ b/clang-tools-extra/clangd/TUScheduler.cpp @@ -452,7 +452,7 @@ class PreambleThread { { std::lock_guard<std::mutex> Lock(Mutex); CurrentReq.reset(); - IsEmpty = !NextReq.hasValue(); + IsEmpty = !NextReq; } if (IsEmpty) { // We don't perform this above, before waiting for a request to make @@ -1146,7 +1146,7 @@ void ASTWorker::generateDiagnostics( } Status.update([&](TUStatus &Status) { Status.Details.ReuseAST = false; - Status.Details.BuildFailed = !NewAST.hasValue(); + Status.Details.BuildFailed = !NewAST; }); AST = NewAST ? std::make_unique<ParsedAST>(std::move(*NewAST)) : nullptr; } else { diff --git a/clang-tools-extra/clangd/tool/Check.cpp b/clang-tools-extra/clangd/tool/Check.cpp index 748510f91bcc9..54c7e91ab9815 100644 --- a/clang-tools-extra/clangd/tool/Check.cpp +++ b/clang-tools-extra/clangd/tool/Check.cpp @@ -253,7 +253,7 @@ class Checker { vlog(" definition: {0}", Definitions); auto Hover = getHover(*AST, Pos, Style, &Index); - vlog(" hover: {0}", Hover.hasValue()); + vlog(" hover: {0}", Hover.has_value()); unsigned DocHighlights = findDocumentHighlights(*AST, Pos).size(); vlog(" documentHighlight: {0}", DocHighlights); diff --git a/clang/include/clang/APINotes/Types.h b/clang/include/clang/APINotes/Types.h index f00e41b7c9558..cd02db3da185c 100644 --- a/clang/include/clang/APINotes/Types.h +++ b/clang/include/clang/APINotes/Types.h @@ -238,7 +238,7 @@ class ObjCContextInfo : public CommonTypeInfo { : llvm::None; } void setSwiftImportAsNonGeneric(llvm::Optional<bool> Value) { - SwiftImportAsNonGenericSpecified = Value.hasValue(); + SwiftImportAsNonGenericSpecified = Value.has_value(); SwiftImportAsNonGeneric = Value.value_or(false); } @@ -247,7 +247,7 @@ class ObjCContextInfo : public CommonTypeInfo { : llvm::None; } void setSwiftObjCMembers(llvm::Optional<bool> Value) { - SwiftObjCMembersSpecified = Value.hasValue(); + SwiftObjCMembersSpecified = Value.has_value(); SwiftObjCMembers = Value.value_or(false); } @@ -365,7 +365,7 @@ class ObjCPropertyInfo : public VariableInfo { : llvm::None; } void setSwiftImportAsAccessors(llvm::Optional<bool> Value) { - SwiftImportAsAccessorsSpecified = Value.hasValue(); + SwiftImportAsAccessorsSpecified = Value.has_value(); SwiftImportAsAccessors = Value.value_or(false); } @@ -429,7 +429,7 @@ class ParamInfo : public VariableInfo { return NoEscape; } void setNoEscape(llvm::Optional<bool> Value) { - NoEscapeSpecified = Value.hasValue(); + NoEscapeSpecified = Value.has_value(); NoEscape = Value.value_or(false); } @@ -666,7 +666,7 @@ class TagInfo : public CommonTypeInfo { return llvm::None; } void setFlagEnum(llvm::Optional<bool> Value) { - HasFlagEnum = Value.hasValue(); + HasFlagEnum = Value.has_value(); IsFlagEnum = Value.value_or(false); } diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 1f8086301f66e..61c153b1f6758 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -5805,7 +5805,7 @@ class PackExpansionType : public Type, public llvm::FoldingSetNode { static void Profile(llvm::FoldingSetNodeID &ID, QualType Pattern, Optional<unsigned> NumExpansions) { ID.AddPointer(Pattern.getAsOpaquePtr()); - ID.AddBoolean(NumExpansions.hasValue()); + ID.AddBoolean(NumExpansions.has_value()); if (NumExpansions) ID.AddInteger(*NumExpansions); } diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp index 55f3c3541b7f5..8911056929808 100644 --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -196,7 +196,7 @@ CXXNewExpr::CXXNewExpr(bool IsGlobalNew, FunctionDecl *OperatorNew, "Only NoInit can have no initializer!"); CXXNewExprBits.IsGlobalNew = IsGlobalNew; - CXXNewExprBits.IsArray = ArraySize.hasValue(); + CXXNewExprBits.IsArray = ArraySize.has_value(); CXXNewExprBits.ShouldPassAlignment = ShouldPassAlignment; CXXNewExprBits.UsualArrayDeleteWantsSize = UsualArrayDeleteWantsSize; CXXNewExprBits.StoredInitializationStyle = @@ -248,7 +248,7 @@ CXXNewExpr::Create(const ASTContext &Ctx, bool IsGlobalNew, InitializationStyle InitializationStyle, Expr *Initializer, QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range, SourceRange DirectInitRange) { - bool IsArray = ArraySize.hasValue(); + bool IsArray = ArraySize.has_value(); bool HasInit = Initializer != nullptr; unsigned NumPlacementArgs = PlacementArgs.size(); bool IsParenTypeId = TypeIdParens.isValid(); diff --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp b/clang/lib/ASTMatchers/ASTMatchFinder.cpp index 5d245d3fc9b76..ac8e4eccad8eb 100644 --- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp +++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp @@ -429,7 +429,7 @@ class MatchASTVisitor : public RecursiveASTVisitor<MatchASTVisitor>, } void onStartOfTranslationUnit() { - const bool EnableCheckProfiling = Options.CheckProfiling.hasValue(); + const bool EnableCheckProfiling = Options.CheckProfiling.has_value(); TimeBucketRegion Timer; for (MatchCallback *MC : Matchers->AllCallbacks) { if (EnableCheckProfiling) @@ -439,7 +439,7 @@ class MatchASTVisitor : public RecursiveASTVisitor<MatchASTVisitor>, } void onEndOfTranslationUnit() { - const bool EnableCheckProfiling = Options.CheckProfiling.hasValue(); + const bool EnableCheckProfiling = Options.CheckProfiling.has_value(); TimeBucketRegion Timer; for (MatchCallback *MC : Matchers->AllCallbacks) { if (EnableCheckProfiling) @@ -1010,7 +1010,7 @@ class MatchASTVisitor : public RecursiveASTVisitor<MatchASTVisitor>, /// Used by \c matchDispatch() below. template <typename T, typename MC> void matchWithoutFilter(const T &Node, const MC &Matchers) { - const bool EnableCheckProfiling = Options.CheckProfiling.hasValue(); + const bool EnableCheckProfiling = Options.CheckProfiling.has_value(); TimeBucketRegion Timer; for (const auto &MP : Matchers) { if (EnableCheckProfiling) @@ -1033,7 +1033,7 @@ class MatchASTVisitor : public RecursiveASTVisitor<MatchASTVisitor>, if (Filter.empty()) return; - const bool EnableCheckProfiling = Options.CheckProfiling.hasValue(); + const bool EnableCheckProfiling = Options.CheckProfiling.has_value(); TimeBucketRegion Timer; auto &Matchers = this->Matchers->DeclOrStmt; for (unsigned short I : Filter) { diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp index 85804bc83eb74..60fd42bc1127a 100644 --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/lib/Lex/HeaderSearch.cpp @@ -626,7 +626,7 @@ Optional<FileEntryRef> DirectoryLookup::DoFrameworkLookup( // Set out flags. InUserSpecifiedSystemFramework = CacheEntry.IsUserSpecifiedSystemFramework; - IsFrameworkFound = CacheEntry.Directory.hasValue(); + IsFrameworkFound = CacheEntry.Directory.has_value(); if (RelativePath) { RelativePath->clear(); diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 572cc6605551d..591278b60ce94 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -1926,7 +1926,7 @@ Sema::isUnavailableAlignedAllocationFunction(const FunctionDecl &FD) const { return false; Optional<unsigned> AlignmentParam; if (FD.isReplaceableGlobalAllocationFunction(&AlignmentParam) && - AlignmentParam.hasValue()) + AlignmentParam) return true; return false; } @@ -2231,7 +2231,7 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, !Expr::hasAnyTypeDependentArguments(PlacementArgs) && FindAllocationFunctions( StartLoc, SourceRange(PlacementLParen, PlacementRParen), Scope, Scope, - AllocType, ArraySize.hasValue(), PassAlignment, PlacementArgs, + AllocType, ArraySize.has_value(), PassAlignment, PlacementArgs, OperatorNew, OperatorDelete)) return ExprError(); @@ -2314,7 +2314,7 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, // Adjust placement args by prepending conjured size and alignment exprs. llvm::SmallVector<Expr *, 8> CallArgs; CallArgs.reserve(NumImplicitArgs + PlacementArgs.size()); - CallArgs.emplace_back(AllocationSize.hasValue() + CallArgs.emplace_back(AllocationSize ? static_cast<Expr *>(&AllocationSizeLiteral) : &OpaqueAllocationSize); if (PassAlignment) diff --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp index acde10b353799..5f244f7b8b6c5 100644 --- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp +++ b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp @@ -1406,7 +1406,7 @@ CallEventManager::getCaller(const StackFrameContext *CalleeCtx, Trigger = Dtor->getBody(); return getCXXDestructorCall(Dtor, Trigger, ThisVal.getAsRegion(), - E.getAs<CFGBaseDtor>().hasValue(), State, + E.getAs<CFGBaseDtor>().has_value(), State, CallerCtx); } diff --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp index 826ebc5438a7e..7a77593a32081 100644 --- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp +++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -2481,7 +2481,7 @@ RegionStoreManager::bindArray(RegionBindingsConstRef B, RegionBindingsRef NewB(B); - for (; Size.hasValue() ? i < Size.getValue() : true ; ++i, ++VI) { + for (; Size ? i < *Size : true; ++i, ++VI) { // The init list might be shorter than the array length. if (VI == VE) break; diff --git a/clang/lib/Tooling/Syntax/BuildTree.cpp b/clang/lib/Tooling/Syntax/BuildTree.cpp index fcac2250dd969..484cf61664fe8 100644 --- a/clang/lib/Tooling/Syntax/BuildTree.cpp +++ b/clang/lib/Tooling/Syntax/BuildTree.cpp @@ -572,7 +572,7 @@ class syntax::TreeBuilder { for (const auto &T : A.getTokenBuffer().expandedTokens().drop_back()) { auto *L = new (A.getAllocator()) syntax::Leaf(&T); L->Original = true; - L->CanModify = A.getTokenBuffer().spelledForExpanded(T).hasValue(); + L->CanModify = A.getTokenBuffer().spelledForExpanded(T).has_value(); Trees.insert(Trees.end(), {&T, L}); } } @@ -646,7 +646,7 @@ class syntax::TreeBuilder { // Mark that this node came from the AST and is backed by the source code. Node->Original = true; Node->CanModify = - A.getTokenBuffer().spelledForExpanded(Tokens).hasValue(); + A.getTokenBuffer().spelledForExpanded(Tokens).has_value(); Trees.erase(BeginChildren, EndChildren); Trees.insert({FirstToken, Node}); diff --git a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp index 50fe2257bc1d5..77370ed8342df 100644 --- a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp +++ b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp @@ -1318,7 +1318,7 @@ static Error UnbundleArchive() { if (!NextTripleOrErr) return NextTripleOrErr.takeError(); - CodeObject = ((*NextTripleOrErr).hasValue()) ? **NextTripleOrErr : ""; + CodeObject = NextTripleOrErr->value_or(""); } // End of processing of all bundle entries of this child of input archive. } // End of while over children of input archive. diff --git a/flang/lib/Lower/IO.cpp b/flang/lib/Lower/IO.cpp index f5a8da0ca93bc..3ca3effdac379 100644 --- a/flang/lib/Lower/IO.cpp +++ b/flang/lib/Lower/IO.cpp @@ -1229,7 +1229,7 @@ genConditionHandlerCall(Fortran::lower::AbstractConverter &converter, boolValue(csi.hasErr), boolValue(csi.hasEnd), boolValue(csi.hasEor), - boolValue(csi.ioMsg.hasValue())}; + boolValue(csi.ioMsg.has_value())}; builder.create<fir::CallOp>(loc, enableHandlers, ioArgs); } @@ -1902,7 +1902,7 @@ genDataTransferStmt(Fortran::lower::AbstractConverter &converter, llvm::Optional<fir::ExtendedValue> descRef = isInternal ? maybeGetInternalIODescriptor(converter, stmt, stmtCtx) : llvm::None; - const bool isInternalWithDesc = descRef.hasValue(); + const bool isInternalWithDesc = descRef.has_value(); const bool isAsync = isDataTransferAsynchronous(loc, stmt); const bool isNml = isDataTransferNamelist(stmt); diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp index fc5d85886246a..05478ac5dd9a2 100644 --- a/flang/lib/Optimizer/Dialect/FIROps.cpp +++ b/flang/lib/Optimizer/Dialect/FIROps.cpp @@ -3079,7 +3079,7 @@ void fir::StringLitOp::build(mlir::OpBuilder &builder, fir::CharacterType inType, llvm::StringRef val, llvm::Optional<int64_t> len) { auto valAttr = builder.getNamedAttr(value(), builder.getStringAttr(val)); - int64_t length = len.hasValue() ? len.getValue() : inType.getLen(); + int64_t length = len ? *len : inType.getLen(); auto lenAttr = mkNamedIntegerAttr(builder, size(), length); result.addAttributes({valAttr, lenAttr}); result.addTypes(inType); @@ -3102,7 +3102,7 @@ void fir::StringLitOp::build(mlir::OpBuilder &builder, llvm::Optional<std::int64_t> len) { auto valAttr = builder.getNamedAttr(xlist(), convertToArrayAttr(builder, vlist)); - std::int64_t length = len.hasValue() ? len.getValue() : inType.getLen(); + std::int64_t length = len ? *len : inType.getLen(); auto lenAttr = mkNamedIntegerAttr(builder, size(), length); result.addAttributes({valAttr, lenAttr}); result.addTypes(inType); @@ -3115,7 +3115,7 @@ void fir::StringLitOp::build(mlir::OpBuilder &builder, llvm::Optional<std::int64_t> len) { auto valAttr = builder.getNamedAttr(xlist(), convertToArrayAttr(builder, vlist)); - std::int64_t length = len.hasValue() ? len.getValue() : inType.getLen(); + std::int64_t length = len ? *len : inType.getLen(); auto lenAttr = mkNamedIntegerAttr(builder, size(), length); result.addAttributes({valAttr, lenAttr}); result.addTypes(inType); @@ -3128,7 +3128,7 @@ void fir::StringLitOp::build(mlir::OpBuilder &builder, llvm::Optional<std::int64_t> len) { auto valAttr = builder.getNamedAttr(xlist(), convertToArrayAttr(builder, vlist)); - std::int64_t length = len.hasValue() ? len.getValue() : inType.getLen(); + std::int64_t length = len ? *len : inType.getLen(); auto lenAttr = mkNamedIntegerAttr(builder, size(), length); result.addAttributes({valAttr, lenAttr}); result.addTypes(inType); diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index e3d2aa8ebd37f..6ef209b20fc67 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -212,7 +212,7 @@ bool CommandInterpreter::SetQuitExitCode(int exit_code) { } int CommandInterpreter::GetQuitExitCode(bool &exited) const { - exited = m_quit_exit_code.hasValue(); + exited = m_quit_exit_code.has_value(); if (exited) return *m_quit_exit_code; return 0; diff --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp index 16d84fb01f610..11175a410aa92 100644 --- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp +++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp @@ -489,7 +489,7 @@ void SymbolFileBreakpad::AddSymbols(Symtab &symtab) { /*is_trampoline*/ false, /*is_artificial*/ false, AddressRange(section_sp, address - section_sp->GetFileAddress(), size.value_or(0)), - size.hasValue(), /*contains_linker_annotations*/ false, /*flags*/ 0); + size.has_value(), /*contains_linker_annotations*/ false, /*flags*/ 0); }; for (llvm::StringRef line : lines(Record::Public)) { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 350e65406b251..c0bf13e0281d3 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -1373,7 +1373,7 @@ user_id_t SymbolFileDWARF::GetUID(DIERef ref) { lldbassert(GetDwoNum().value_or(0) <= 0x3fffffff); return user_id_t(GetDwoNum().value_or(0)) << 32 | ref.die_offset() | - lldb::user_id_t(GetDwoNum().hasValue()) << 62 | + lldb::user_id_t(GetDwoNum().has_value()) << 62 | lldb::user_id_t(ref.section() == DIERef::Section::DebugTypes) << 63; } diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp index f426d3d123962..c0308196c7609 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp @@ -66,7 +66,7 @@ clang::QualType UdtRecordCompleter::AddBaseClassForTypeIndex( std::unique_ptr<clang::CXXBaseSpecifier> base_spec = m_ast_builder.clang().CreateBaseClassSpecifier( qt.getAsOpaquePtr(), TranslateMemberAccess(access), - vtable_idx.hasValue(), udt_cvt.kind() == LF_CLASS); + vtable_idx.has_value(), udt_cvt.kind() == LF_CLASS); if (!base_spec) return {}; diff --git a/lldb/source/Symbol/CompileUnit.cpp b/lldb/source/Symbol/CompileUnit.cpp index 422f8a555e160..cacb78de24260 100644 --- a/lldb/source/Symbol/CompileUnit.cpp +++ b/lldb/source/Symbol/CompileUnit.cpp @@ -323,7 +323,7 @@ void CompileUnit::ResolveSymbolContext( const bool inlines = false; const bool exact = true; const llvm::Optional<uint16_t> column = - src_location_spec.GetColumn().hasValue() + src_location_spec.GetColumn() ? llvm::Optional<uint16_t>(line_entry.column) : llvm::None; diff --git a/llvm/include/llvm/Analysis/InlineAdvisor.h b/llvm/include/llvm/Analysis/InlineAdvisor.h index f5fbb69513f90..e56a7127dcdf5 100644 --- a/llvm/include/llvm/Analysis/InlineAdvisor.h +++ b/llvm/include/llvm/Analysis/InlineAdvisor.h @@ -145,7 +145,7 @@ class DefaultInlineAdvice : public InlineAdvice { DefaultInlineAdvice(InlineAdvisor *Advisor, CallBase &CB, Optional<InlineCost> OIC, OptimizationRemarkEmitter &ORE, bool EmitRemarks = true) - : InlineAdvice(Advisor, CB, ORE, OIC.hasValue()), OriginalCB(&CB), + : InlineAdvice(Advisor, CB, ORE, OIC.has_value()), OriginalCB(&CB), OIC(OIC), EmitRemarks(EmitRemarks) {} private: diff --git a/llvm/include/llvm/Analysis/ObjCARCUtil.h b/llvm/include/llvm/Analysis/ObjCARCUtil.h index 80844ac8cd325..56faa20c4c6e9 100644 --- a/llvm/include/llvm/Analysis/ObjCARCUtil.h +++ b/llvm/include/llvm/Analysis/ObjCARCUtil.h @@ -35,7 +35,7 @@ inline bool hasAttachedCallOpBundle(const CallBase *CB) { // functions. return !CB->getFunctionType()->getReturnType()->isVoidTy() && CB->getOperandBundle(LLVMContext::OB_clang_arc_attachedcall) - .hasValue(); + .has_value(); } /// This function returns operand bundle clang_arc_attachedcall's argument, diff --git a/llvm/include/llvm/DebugInfo/CodeView/TypeCollection.h b/llvm/include/llvm/DebugInfo/CodeView/TypeCollection.h index bde5a8b3ab2fa..f643bc4d7451a 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/TypeCollection.h +++ b/llvm/include/llvm/DebugInfo/CodeView/TypeCollection.h @@ -34,7 +34,7 @@ class TypeCollection { template <typename TFunc> void ForEachRecord(TFunc Func) { Optional<TypeIndex> Next = getFirst(); - while (Next.hasValue()) { + while (Next) { TypeIndex N = *Next; Func(N, getType(N)); Next = getNext(N); diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h index cc7cbb4544151..3887656ceef6e 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h @@ -34,7 +34,7 @@ class DWARFAbbreviationDeclaration { AttributeSpec(dwarf::Attribute A, dwarf::Form F, Optional<uint8_t> ByteSize) : Attr(A), Form(F) { assert(!isImplicitConst()); - this->ByteSize.HasByteSize = ByteSize.hasValue(); + this->ByteSize.HasByteSize = ByteSize.has_value(); if (this->ByteSize.HasByteSize) this->ByteSize.ByteSize = *ByteSize; } diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 0c8cd72b3caa4..a12c4aea86852 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -8858,7 +8858,7 @@ ScalarEvolution::ExitLimit ScalarEvolution::computeShiftCompareExitLimit( // and the kind of shift should be match the kind of shift we peeled // off, if any. - (!PostShiftOpCode.hasValue() || *PostShiftOpCode == OpCodeOut); + (!PostShiftOpCode || *PostShiftOpCode == OpCodeOut); }; PHINode *PN; diff --git a/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp b/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp index 4e73f4214483e..1d16211c65bfd 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp @@ -736,7 +736,7 @@ Error BitcodeAnalyzer::parseBlock(unsigned BlockID, unsigned IndentLevel, BlockStats.NumInstances++; // BLOCKINFO is a special part of the stream. - bool DumpRecords = O.hasValue(); + bool DumpRecords = O.has_value(); if (BlockID == bitc::BLOCKINFO_BLOCK_ID) { if (O && !O->DumpBlockinfo) O->OS << Indent << "<BLOCKINFO_BLOCK/>\n"; @@ -898,7 +898,7 @@ Error BitcodeAnalyzer::parseBlock(unsigned BlockID, unsigned IndentLevel, // If we found a module hash, let's verify that it matches! if (BlockID == bitc::MODULE_BLOCK_ID && Code == bitc::MODULE_CODE_HASH && - CheckHash.hasValue()) { + CheckHash) { if (Record.size() != 5) O->OS << " (invalid)"; else { diff --git a/llvm/lib/CodeGen/ExpandMemCmp.cpp b/llvm/lib/CodeGen/ExpandMemCmp.cpp index 17bf6b061cace..b2639636dda79 100644 --- a/llvm/lib/CodeGen/ExpandMemCmp.cpp +++ b/llvm/lib/CodeGen/ExpandMemCmp.cpp @@ -885,7 +885,7 @@ ExpandMemCmpPass::runImpl(Function &F, const TargetLibraryInfo *TLI, bool MadeChanges = false; for (auto BBIt = F.begin(); BBIt != F.end();) { if (runOnBlock(*BBIt, TLI, TTI, TL, DL, PSI, BFI, - DTU.hasValue() ? DTU.getPointer() : nullptr)) { + DTU ? DTU.getPointer() : nullptr)) { MadeChanges = true; // If changes were made, restart the function from the beginning, since // the structure of the function was changed. diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 9d2c147fac7c5..674a654c6651a 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -323,7 +323,7 @@ static SDValue getCopyFromPartsVector(SelectionDAG &DAG, const SDLoc &DL, Optional<CallingConv::ID> CallConv) { assert(ValueVT.isVector() && "Not a vector value"); assert(NumParts > 0 && "No parts to assemble!"); - const bool IsABIRegCopy = CallConv.hasValue(); + const bool IsABIRegCopy = CallConv.has_value(); const TargetLowering &TLI = DAG.getTargetLoweringInfo(); SDValue Val = Parts[0]; @@ -647,7 +647,7 @@ static void getCopyToPartsVector(SelectionDAG &DAG, const SDLoc &DL, EVT ValueVT = Val.getValueType(); assert(ValueVT.isVector() && "Not a vector"); const TargetLowering &TLI = DAG.getTargetLoweringInfo(); - const bool IsABIRegCopy = CallConv.hasValue(); + const bool IsABIRegCopy = CallConv.has_value(); if (NumParts == 1) { EVT PartEVT = PartVT; diff --git a/llvm/lib/CodeGen/ShadowStackGCLowering.cpp b/llvm/lib/CodeGen/ShadowStackGCLowering.cpp index a33527d78aa31..5f9ade18f15cf 100644 --- a/llvm/lib/CodeGen/ShadowStackGCLowering.cpp +++ b/llvm/lib/CodeGen/ShadowStackGCLowering.cpp @@ -361,7 +361,7 @@ bool ShadowStackGCLowering::runOnFunction(Function &F) { // For each instruction that escapes... EscapeEnumerator EE(F, "gc_cleanup", /*HandleExceptions=*/true, - DTU.hasValue() ? DTU.getPointer() : nullptr); + DTU ? DTU.getPointer() : nullptr); while (IRBuilder<> *AtExit = EE.Next()) { // Pop the entry from the shadow stack. Don't reuse CurrentHead from // AtEntry, since that would make the value live for the entire function. diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp index dc070424adc12..641043a8e186e 100644 --- a/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp @@ -355,7 +355,7 @@ Error PDBFileBuilder::commit(StringRef Filename, codeview::GUID *Guid) { H->Age = Info->getAge(); H->Guid = Info->getGuid(); Optional<uint32_t> Sig = Info->getSignature(); - H->Signature = Sig.hasValue() ? *Sig : time(nullptr); + H->Signature = Sig ? *Sig : time(nullptr); } return Buffer.commit(); diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index b032a3fea98f2..8f7dad37773c3 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -379,7 +379,7 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V, opc != Instruction::AddrSpaceCast && // Do not fold bitcast (gep) with inrange index, as this loses // information. - !cast<GEPOperator>(CE)->getInRangeIndex().hasValue() && + !cast<GEPOperator>(CE)->getInRangeIndex() && // Do not fold if the gep type is a vector, as bitcasting // operand 0 of a vector gep will result in a bitcast between // diff erent sizes. diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp index 115a577405466..50799327c78a0 100644 --- a/llvm/lib/IR/DebugInfoMetadata.cpp +++ b/llvm/lib/IR/DebugInfoMetadata.cpp @@ -1582,7 +1582,7 @@ DIExpression *DIExpression::appendToStack(const DIExpression *Expr, // // Match .* DW_OP_stack_value (DW_OP_LLVM_fragment A B)?. Optional<FragmentInfo> FI = Expr->getFragmentInfo(); - unsigned DropUntilStackValue = FI.hasValue() ? 3 : 0; + unsigned DropUntilStackValue = FI ? 3 : 0; ArrayRef<uint64_t> ExprOpsBeforeFragment = Expr->getElements().drop_back(DropUntilStackValue); bool NeedsDeref = (Expr->getNumElements() > DropUntilStackValue) && diff --git a/llvm/lib/IR/VectorBuilder.cpp b/llvm/lib/IR/VectorBuilder.cpp index f6c59de66a588..82995ce3d05c4 100644 --- a/llvm/lib/IR/VectorBuilder.cpp +++ b/llvm/lib/IR/VectorBuilder.cpp @@ -64,7 +64,7 @@ Value *VectorBuilder::createVectorInstruction(unsigned Opcode, Type *ReturnTy, auto VLenPosOpt = VPIntrinsic::getVectorLengthParamPos(VPID); size_t NumInstParams = InstOpArray.size(); size_t NumVPParams = - NumInstParams + MaskPosOpt.hasValue() + VLenPosOpt.hasValue(); + NumInstParams + MaskPosOpt.has_value() + VLenPosOpt.has_value(); SmallVector<Value *, 6> IntrinParams; diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 0df0c327a3377..8f857933ada60 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -4887,7 +4887,7 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) { Optional<RoundingMode> RoundMode = convertStrToRoundingMode(cast<MDString>(MD)->getString()); - Check(RoundMode.hasValue() && RoundMode.getValue() != RoundingMode::Dynamic, + Check(RoundMode && *RoundMode != RoundingMode::Dynamic, "unsupported rounding mode argument", Call); break; } @@ -6067,7 +6067,7 @@ void Verifier::verifyAttachedCallBundle(const CallBase &Call, } void Verifier::verifySourceDebugInfo(const DICompileUnit &U, const DIFile &F) { - bool HasSource = F.getSource().hasValue(); + bool HasSource = F.getSource().has_value(); if (!HasSourceDebugInfo.count(&U)) HasSourceDebugInfo[&U] = HasSource; CheckDI(HasSource == HasSourceDebugInfo[&U], diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp index db38c2810d76a..4cbb9981fde2d 100644 --- a/llvm/lib/MC/MCDwarf.cpp +++ b/llvm/lib/MC/MCDwarf.cpp @@ -587,7 +587,7 @@ MCDwarfLineTableHeader::tryGetFile(StringRef &Directory, // Keep track of whether any or all files have an MD5 checksum. // If any files have embedded source, they all must. if (MCDwarfFiles.empty()) { - trackMD5Usage(Checksum.hasValue()); + trackMD5Usage(Checksum.has_value()); HasSource = (Source != None); } if (DwarfVersion >= 5 && isRootFile(RootFile, Directory, FileName, Checksum)) @@ -650,7 +650,7 @@ MCDwarfLineTableHeader::tryGetFile(StringRef &Directory, File.Name = std::string(FileName); File.DirIndex = DirIndex; File.Checksum = Checksum; - trackMD5Usage(Checksum.hasValue()); + trackMD5Usage(Checksum.has_value()); File.Source = Source; if (Source) HasSource = true; diff --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp index c8e51b7135503..fbeebe2595a33 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp @@ -5831,7 +5831,7 @@ bool AArch64InstructionSelector::selectIntrinsic(MachineInstr &I, uint64_t Key = I.getOperand(3).getImm(); Register DiscReg = I.getOperand(4).getReg(); auto DiscVal = getIConstantVRegVal(DiscReg, MRI); - bool IsDiscZero = DiscVal.hasValue() && DiscVal->isNullValue(); + bool IsDiscZero = DiscVal && DiscVal->isNullValue(); if (Key > 3) return false; diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp index c67ac3e217792..85e32c08c74cf 100644 --- a/llvm/lib/Target/ARM/ARMISelLowering.cpp +++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp @@ -4386,7 +4386,7 @@ void ARMTargetLowering::VarArgStyleRegisters(CCState &CCInfo, SelectionDAG &DAG, bool ARMTargetLowering::splitValueIntoRegisterParts( SelectionDAG &DAG, const SDLoc &DL, SDValue Val, SDValue *Parts, unsigned NumParts, MVT PartVT, Optional<CallingConv::ID> CC) const { - bool IsABIRegCopy = CC.hasValue(); + bool IsABIRegCopy = CC.has_value(); EVT ValueVT = Val.getValueType(); if (IsABIRegCopy && (ValueVT == MVT::f16 || ValueVT == MVT::bf16) && PartVT == MVT::f32) { @@ -4404,7 +4404,7 @@ bool ARMTargetLowering::splitValueIntoRegisterParts( SDValue ARMTargetLowering::joinRegisterPartsIntoValue( SelectionDAG &DAG, const SDLoc &DL, const SDValue *Parts, unsigned NumParts, MVT PartVT, EVT ValueVT, Optional<CallingConv::ID> CC) const { - bool IsABIRegCopy = CC.hasValue(); + bool IsABIRegCopy = CC.has_value(); if (IsABIRegCopy && (ValueVT == MVT::f16 || ValueVT == MVT::bf16) && PartVT == MVT::f32) { unsigned ValueBits = ValueVT.getSizeInBits(); diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.cpp index d82731e153fe1..c8805296017dd 100644 --- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.cpp +++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.cpp @@ -295,7 +295,7 @@ void HexagonShuffler::restrictBranchOrder(HexagonPacketSummary const &Summary) { Summary.branchInsts[0]->Core.setUnits(jumpSlot.first); Summary.branchInsts[1]->Core.setUnits(jumpSlot.second); - const bool HasShuffledPacket = tryAuction(Summary).hasValue(); + const bool HasShuffledPacket = tryAuction(Summary).has_value(); if (HasShuffledPacket) return; @@ -599,7 +599,7 @@ void HexagonShuffler::restrictPreferSlot3(HexagonPacketSummary const &Summary, // and then pin it to slot #3 const unsigned saveUnits = PrefSlot3Inst->Core.getUnits(); PrefSlot3Inst->Core.setUnits(saveUnits & Slot3Mask); - const bool HasShuffledPacket = tryAuction(Summary).hasValue(); + const bool HasShuffledPacket = tryAuction(Summary).has_value(); if (HasShuffledPacket) return; diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp index 60e490fa2ce93..664c379f8c03c 100644 --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -11941,7 +11941,7 @@ bool RISCVTargetLowering::allowsMisalignedMemoryAccesses( bool RISCVTargetLowering::splitValueIntoRegisterParts( SelectionDAG &DAG, const SDLoc &DL, SDValue Val, SDValue *Parts, unsigned NumParts, MVT PartVT, Optional<CallingConv::ID> CC) const { - bool IsABIRegCopy = CC.hasValue(); + bool IsABIRegCopy = CC.has_value(); EVT ValueVT = Val.getValueType(); if (IsABIRegCopy && ValueVT == MVT::f16 && PartVT == MVT::f32) { // Cast the f16 to i16, extend to i32, pad with ones to make a float nan, @@ -11995,7 +11995,7 @@ bool RISCVTargetLowering::splitValueIntoRegisterParts( SDValue RISCVTargetLowering::joinRegisterPartsIntoValue( SelectionDAG &DAG, const SDLoc &DL, const SDValue *Parts, unsigned NumParts, MVT PartVT, EVT ValueVT, Optional<CallingConv::ID> CC) const { - bool IsABIRegCopy = CC.hasValue(); + bool IsABIRegCopy = CC.has_value(); if (IsABIRegCopy && ValueVT == MVT::f16 && PartVT == MVT::f32) { SDValue Val = Parts[0]; diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp index 9a4dce398fb87..9e9d262a44229 100644 --- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp +++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp @@ -339,7 +339,7 @@ static bool genericValueTraversal( if (auto *SI = dyn_cast<SelectInst>(V)) { Optional<Constant *> C = A.getAssumedConstant( *SI->getCondition(), QueryingAA, UsedAssumedInformation); - bool NoValueYet = !C.hasValue(); + bool NoValueYet = !C; if (NoValueYet || isa_and_nonnull<UndefValue>(*C)) continue; if (auto *CI = dyn_cast_or_null<ConstantInt>(*C)) { @@ -9576,7 +9576,7 @@ struct AANoUndefImpl : AANoUndef { // considered to be dead. We don't manifest noundef in such positions for // the same reason above. if (!A.getAssumedSimplified(getIRPosition(), *this, UsedAssumedInformation) - .hasValue()) + .has_value()) return ChangeStatus::UNCHANGED; return AANoUndef::manifest(A); } diff --git a/llvm/lib/Transforms/IPO/IROutliner.cpp b/llvm/lib/Transforms/IPO/IROutliner.cpp index eb43154906394..82484f638796b 100644 --- a/llvm/lib/Transforms/IPO/IROutliner.cpp +++ b/llvm/lib/Transforms/IPO/IROutliner.cpp @@ -964,7 +964,7 @@ findExtractedInputToOverallInputMapping(OutlinableRegion &Region, // argument in the overall function. if (Input->isSwiftError()) { assert( - !Group.SwiftErrorArgument.hasValue() && + !Group.SwiftErrorArgument && "Argument already marked with swifterr for this OutlinableGroup!"); Group.SwiftErrorArgument = TypeIndex; } @@ -1871,7 +1871,7 @@ replaceArgumentUses(OutlinableRegion &Region, // If this is storing a PHINode, we must make sure it is included in the // overall function. if (!isa<PHINode>(ValueOperand) || - Region.Candidate->getGVN(ValueOperand).hasValue()) { + Region.Candidate->getGVN(ValueOperand).has_value()) { if (FirstFunction) continue; Value *CorrVal = diff --git a/llvm/lib/Transforms/Scalar/LoopFlatten.cpp b/llvm/lib/Transforms/Scalar/LoopFlatten.cpp index eb12defc515f3..f36193fc468e0 100644 --- a/llvm/lib/Transforms/Scalar/LoopFlatten.cpp +++ b/llvm/lib/Transforms/Scalar/LoopFlatten.cpp @@ -923,7 +923,7 @@ PreservedAnalyses LoopFlattenPass::run(LoopNest &LN, LoopAnalysisManager &LAM, // this pass will simplify all loops that contain inner loops, // regardless of whether anything ends up being flattened. Changed |= Flatten(LN, &AR.DT, &AR.LI, &AR.SE, &AR.AC, &AR.TTI, &U, - MSSAU.hasValue() ? MSSAU.getPointer() : nullptr); + MSSAU ? MSSAU.getPointer() : nullptr); if (!Changed) return PreservedAnalyses::all(); @@ -989,7 +989,7 @@ bool LoopFlattenLegacyPass::runOnFunction(Function &F) { for (Loop *L : *LI) { auto LN = LoopNest::getLoopNest(*L, *SE); Changed |= Flatten(*LN, DT, LI, SE, AC, TTI, nullptr, - MSSAU.hasValue() ? MSSAU.getPointer() : nullptr); + MSSAU ? MSSAU.getPointer() : nullptr); } return Changed; } diff --git a/llvm/lib/Transforms/Scalar/LoopInstSimplify.cpp b/llvm/lib/Transforms/Scalar/LoopInstSimplify.cpp index 61f6dac6fa943..4249512ea0f82 100644 --- a/llvm/lib/Transforms/Scalar/LoopInstSimplify.cpp +++ b/llvm/lib/Transforms/Scalar/LoopInstSimplify.cpp @@ -221,7 +221,7 @@ PreservedAnalyses LoopInstSimplifyPass::run(Loop &L, LoopAnalysisManager &AM, AR.MSSA->verifyMemorySSA(); } if (!simplifyLoopInst(L, AR.DT, AR.LI, AR.AC, AR.TLI, - MSSAU.hasValue() ? MSSAU.getPointer() : nullptr)) + MSSAU ? MSSAU.getPointer() : nullptr)) return PreservedAnalyses::all(); auto PA = getLoopPassPreservedAnalyses(); diff --git a/llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp b/llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp index ae102277b9209..689a2a286cb9f 100644 --- a/llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp +++ b/llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp @@ -140,7 +140,7 @@ static bool runPartiallyInlineLibCalls(Function &F, TargetLibraryInfo *TLI, case LibFunc_sqrt: if (TTI->haveFastSqrt(Call->getType()) && optimizeSQRT(Call, CalledFunc, *CurrBB, BB, TTI, - DTU.hasValue() ? DTU.getPointer() : nullptr)) + DTU ? DTU.getPointer() : nullptr)) break; continue; default: diff --git a/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp b/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp index 38a69ad2f1825..e2976ace3a4af 100644 --- a/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp +++ b/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp @@ -873,7 +873,7 @@ static bool runImpl(Function &F, const TargetTransformInfo &TTI, for (BasicBlock &BB : llvm::make_early_inc_range(F)) { bool ModifiedDTOnIteration = false; MadeChange |= optimizeBlock(BB, ModifiedDTOnIteration, TTI, DL, - DTU.hasValue() ? DTU.getPointer() : nullptr); + DTU ? DTU.getPointer() : nullptr); // Restart BB iteration if the dominator tree of the Function was changed if (ModifiedDTOnIteration) diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td index 8dd64d5f112a8..5d9206329333a 100644 --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td @@ -86,7 +86,7 @@ def SPIRV_Dialect : Dialect { // enum class with `name`. class SPV_IsKnownEnumCaseFor<string name> : CPred<"::mlir::spirv::symbolize" # name # "(" - "$_self.cast<IntegerAttr>().getValue().getZExtValue()).hasValue()">; + "$_self.cast<IntegerAttr>().getValue().getZExtValue()).has_value()">; // Wrapper over base BitEnumAttr to set common fields. class SPV_BitEnumAttr<string name, string description, diff --git a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp index 674287ad75b2c..a212a49f2e596 100644 --- a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp +++ b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp @@ -163,7 +163,7 @@ static Value generateInBoundsCheck( Value cond; // Condition to be built... // Condition check 1: Access in-bounds? - bool isBroadcast = !dim.hasValue(); // No in-bounds check for broadcasts. + bool isBroadcast = !dim; // No in-bounds check for broadcasts. Location loc = xferOp.getLoc(); ImplicitLocOpBuilder lb(xferOp.getLoc(), b); if (!xferOp.isDimInBounds(0) && !isBroadcast) { diff --git a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp index a12228f75659d..bba097b0d3ce3 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp @@ -151,7 +151,7 @@ LinalgTilingOptions &mlir::linalg::LinalgTilingOptions::scalarizeDynamicDims() { // If the shape size is dynamic, tile by 1. Otherwise, do not tile (tile // size 0). for (Value shapeSize : shapeSizes) - tileSizes.push_back(getConstantIntValue(shapeSize).hasValue() + tileSizes.push_back(getConstantIntValue(shapeSize) ? b.create<arith::ConstantIndexOp>(loc, 0) : b.create<arith::ConstantIndexOp>(loc, 1)); return tileSizes; diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp index 6b0daa3dfedce..e147ecd2b1693 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp @@ -657,7 +657,7 @@ class SparseTensorConvertConverter : public OpConversionPattern<ConvertOp> { Value zero = constantIndex(rewriter, loc, 0); Value one = constantIndex(rewriter, loc, 1); auto indicesValues = genSplitSparseConstant(rewriter, loc, src); - bool isCOOConstant = indicesValues.hasValue(); + bool isCOOConstant = indicesValues.has_value(); Value indices; Value values; if (isCOOConstant) { diff --git a/mlir/lib/TableGen/AttrOrTypeDef.cpp b/mlir/lib/TableGen/AttrOrTypeDef.cpp index 7d335abaeba97..4479a64940bc0 100644 --- a/mlir/lib/TableGen/AttrOrTypeDef.cpp +++ b/mlir/lib/TableGen/AttrOrTypeDef.cpp @@ -65,7 +65,7 @@ AttrOrTypeDef::AttrOrTypeDef(const llvm::Record *def) : def(def) { // Verify the use of the mnemonic field. bool hasCppFormat = hasCustomAssemblyFormat(); - bool hasDeclarativeFormat = getAssemblyFormat().hasValue(); + bool hasDeclarativeFormat = getAssemblyFormat().has_value(); if (getMnemonic()) { if (hasCppFormat && hasDeclarativeFormat) { PrintFatalError(getLoc(), "cannot specify both 'assemblyFormat' " @@ -269,7 +269,7 @@ StringRef AttrOrTypeParameter::getSyntax() const { bool AttrOrTypeParameter::isOptional() const { // Parameters with default values are automatically optional. return getDefValue<llvm::BitInit>("isOptional").value_or(false) || - getDefaultValue().hasValue(); + getDefaultValue(); } Optional<StringRef> AttrOrTypeParameter::getDefaultValue() const { diff --git a/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp index 8d620e324f4a0..bdc891b93baa4 100644 --- a/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp @@ -315,7 +315,7 @@ convertOperationImpl(Operation &opInst, llvm::IRBuilderBase &builder, } auto ft = LLVM::LLVMFunctionType::get(resultType, operandTypes); llvm::InlineAsm *inlineAsmInst = - inlineAsmOp.getAsmDialect().hasValue() + inlineAsmOp.getAsmDialect() ? llvm::InlineAsm::get( static_cast<llvm::FunctionType *>( moduleTranslation.convertType(ft)), diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp index 9126ca3848311..4583ad2240d83 100644 --- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp @@ -816,7 +816,7 @@ convertOmpWsLoop(Operation &opInst, llvm::IRBuilderBase &builder, allocaIP = findAllocaInsertPoint(builder, moduleTranslation); // TODO: Handle doacross loops when the ordered clause has a parameter. - bool isOrdered = loop.ordered_val().hasValue(); + bool isOrdered = loop.ordered_val().has_value(); Optional<omp::ScheduleModifier> scheduleModifier = loop.schedule_modifier(); bool isSimd = loop.simd_modifier(); diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp index 3b267537f1bf0..759143dc606b0 100644 --- a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp +++ b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp @@ -251,7 +251,7 @@ void DefGen::emitParserPrinter() { mnemonic->body().indent() << strfmt("return {\"{0}\"};", *def.getMnemonic()); // Declare the parser and printer, if needed. - bool hasAssemblyFormat = def.getAssemblyFormat().hasValue(); + bool hasAssemblyFormat = def.getAssemblyFormat().has_value(); if (!def.hasCustomAssemblyFormat() && !hasAssemblyFormat) return; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits