From 5413bf1bac2abb9e06901686cdc959e92940143a Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Mon, 20 Jun 2022 11:33:56 -0700 Subject: [PATCH] Don't use Optional::hasValue (NFC) --- clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp | 4 ++-- .../bugprone/EasilySwappableParametersCheck.cpp | 2 +- .../bugprone/SuspiciousMemoryComparisonCheck.cpp | 2 +- .../clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp | 2 +- .../clang-tidy/readability/IdentifierNamingCheck.cpp | 2 +- clang-tools-extra/clangd/ClangdLSPServer.cpp | 2 +- clang-tools-extra/clangd/ClangdServer.cpp | 4 ++-- clang-tools-extra/clangd/CodeComplete.cpp | 4 ++-- clang-tools-extra/clangd/IncludeFixer.cpp | 2 +- clang-tools-extra/clangd/Protocol.cpp | 8 ++++---- clang-tools-extra/clangd/SemanticSelection.cpp | 2 +- .../clangd/refactor/tweaks/ExtractFunction.cpp | 2 +- clang-tools-extra/clangd/tool/Check.cpp | 2 +- clang-tools-extra/pseudo/lib/DirectiveTree.cpp | 2 +- clang-tools-extra/pseudo/lib/Forest.cpp | 2 +- .../clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h | 2 +- clang/lib/Lex/PPDirectives.cpp | 2 +- clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp | 2 +- clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp | 2 +- flang/include/flang/Lower/IterationSpace.h | 2 +- flang/lib/Lower/Bridge.cpp | 2 +- flang/lib/Lower/ConvertExpr.cpp | 6 +++--- flang/lib/Lower/IO.cpp | 2 +- flang/lib/Optimizer/CodeGen/CodeGen.cpp | 4 ++-- flang/lib/Optimizer/CodeGen/TargetRewrite.cpp | 4 ++-- flang/lib/Optimizer/Support/InternalNames.cpp | 2 +- lld/COFF/Driver.cpp | 2 +- lld/ELF/Driver.cpp | 2 +- lld/ELF/InputFiles.cpp | 2 +- lld/ELF/LinkerScript.cpp | 2 +- lld/wasm/Driver.cpp | 2 +- lld/wasm/InputFiles.cpp | 2 +- lld/wasm/Writer.cpp | 2 +- lldb/source/Breakpoint/BreakpointIDList.cpp | 8 ++++---- lldb/source/Commands/CommandObjectFrame.cpp | 2 +- lldb/source/Core/Debugger.cpp | 2 +- .../ExpressionParser/Clang/ClangUserExpression.cpp | 2 +- .../ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp | 2 +- lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp | 6 +++--- lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp | 2 +- lldb/source/Plugins/Process/minidump/MinidumpParser.cpp | 2 +- .../Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp | 4 ++-- .../source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp | 2 +- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 2 +- lldb/source/Utility/SelectHelper.cpp | 4 ++-- llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h | 2 +- llvm/include/llvm/IR/IRBuilder.h | 4 ++-- llvm/lib/Analysis/IRSimilarityIdentifier.cpp | 2 +- llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp | 2 +- llvm/lib/DWARFLinker/DWARFLinker.cpp | 2 +- llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp | 4 ++-- llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp | 4 ++-- llvm/lib/DebugInfo/PDB/Native/InputFile.cpp | 4 ++-- llvm/lib/IR/Function.cpp | 2 +- llvm/lib/IR/IntrinsicInst.cpp | 2 +- llvm/lib/ObjectYAML/ELFYAML.cpp | 2 +- llvm/lib/Target/Mips/MipsTargetStreamer.h | 2 +- llvm/lib/Transforms/IPO/IROutliner.cpp | 6 +++--- llvm/lib/Transforms/IPO/OpenMPOpt.cpp | 4 ++-- .../lib/Transforms/Instrumentation/PGOInstrumentation.cpp | 2 +- llvm/utils/TableGen/GlobalISelEmitter.cpp | 2 +- mlir/lib/Analysis/Presburger/Simplex.cpp | 4 ++-- mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp | 2 +- mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp | 2 +- mlir/lib/Dialect/Affine/Utils/Utils.cpp | 2 +- .../Transforms/FuncBufferizableOpInterfaceImpl.cpp | 2 +- .../Bufferization/Transforms/OneShotModuleBufferize.cpp | 2 +- mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp | 2 +- mlir/lib/Tools/lsp-server-support/Protocol.cpp | 2 +- mlir/test/lib/IR/TestSymbolUses.cpp | 2 +- .../mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp | 6 +++--- mlir/tools/mlir-tblgen/RewriterGen.cpp | 2 +- 72 files changed, 99 insertions(+), 99 deletions(-) diff --git a/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp b/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp index b107dd7385c6..6c5d86a69821 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp @@ -53,7 +53,7 @@ void ClangTidyProfiling::printAsJSON(llvm::raw_ostream &OS) { } void ClangTidyProfiling::storeProfileData() { - assert(Storage.hasValue() && "We should have a filename."); + assert(Storage && "We should have a filename."); llvm::SmallString<256> OutputDirectory(Storage->StoreFilename); llvm::sys::path::remove_filename(OutputDirectory); @@ -80,7 +80,7 @@ ClangTidyProfiling::ClangTidyProfiling(llvm::Optional Storage) ClangTidyProfiling::~ClangTidyProfiling() { TG.emplace("clang-tidy", "clang-tidy checks profiling", Records); - if (!Storage.hasValue()) + if (!Storage) printUserFriendlyTable(llvm::errs()); else storeProfileData(); diff --git a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp index 89c24ce7dd45..8cc494ac1091 100644 --- a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp @@ -1683,7 +1683,7 @@ public: if (CalledFn->getParamDecl(Idx) == PassedToParam) TargetIdx.emplace(Idx); - assert(TargetIdx.hasValue() && "Matched, but didn't find index?"); + assert(TargetIdx && "Matched, but didn't find index?"); TargetParams[PassedParamOfThisFn].insert( {CalledFn->getCanonicalDecl(), *TargetIdx}); } diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp index 12497122bd88..830abda449b2 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp @@ -67,7 +67,7 @@ void SuspiciousMemoryComparisonCheck::check( if (!PointeeType->isIncompleteType()) { uint64_t PointeeSize = Ctx.getTypeSize(PointeeType); - if (ComparedBits.hasValue() && *ComparedBits >= PointeeSize && + if (ComparedBits && *ComparedBits >= PointeeSize && !Ctx.hasUniqueObjectRepresentations(PointeeQualifiedType)) { diag(CE->getBeginLoc(), "comparing object representation of type %0 which does not have a " diff --git a/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp index ab6b17201432..07fb19ff81ac 100644 --- a/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp @@ -65,7 +65,7 @@ analyzeFunction(const FunctionDecl &FuncDecl, ASTContext &ASTCtx) { // `runDataflowAnalysis` doesn't guarantee that the exit block is visited; // for example, when it is unreachable. // FIXME: Diagnose violations even when the exit block is unreachable. - if (!ExitBlockState.hasValue()) + if (!ExitBlockState) return llvm::None; return std::move(ExitBlockState->Lattice); diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp index 242790f1e529..c0387886d941 100644 --- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp @@ -258,7 +258,7 @@ IdentifierNamingCheck::FileStyle IdentifierNamingCheck::getFileStyleFromOptions( auto HPTOpt = Options.get(StyleString); - if (HPTOpt.hasValue() && !HungarianNotation.checkOptionValid(I)) + if (HPTOpt && !HungarianNotation.checkOptionValid(I)) configurationDiag("invalid identifier naming option '%0'") << StyleString; memcpy(&StyleString[StyleSize], "IgnoredRegexp", 13); diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp index e481b59a2286..3bade14f86b9 100644 --- a/clang-tools-extra/clangd/ClangdLSPServer.cpp +++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp @@ -493,7 +493,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params, Opts.CodeComplete.EnableSnippets = Params.capabilities.CompletionSnippets; Opts.CodeComplete.IncludeFixIts = Params.capabilities.CompletionFixes; - if (!Opts.CodeComplete.BundleOverloads.hasValue()) + if (!Opts.CodeComplete.BundleOverloads) Opts.CodeComplete.BundleOverloads = Params.capabilities.HasSignatureHelp; Opts.CodeComplete.DocumentationFormat = Params.capabilities.CompletionDocumentationFormat; diff --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp index eff596dd65d7..fa6c70b4acbc 100644 --- a/clang-tools-extra/clangd/ClangdServer.cpp +++ b/clang-tools-extra/clangd/ClangdServer.cpp @@ -97,7 +97,7 @@ struct UpdateIndexCallbacks : public ParsingCallbacks { if (FIndex) FIndex->updateMain(Path, AST); - assert(AST.getDiagnostics().hasValue() && + assert(AST.getDiagnostics() && "We issue callback only with fresh preambles"); std::vector Diagnostics = *AST.getDiagnostics(); if (ServerCallbacks) @@ -672,7 +672,7 @@ void ClangdServer::applyTweak(PathRef File, Range Sel, StringRef TweakID, } Effect = T.takeError(); } - assert(Effect.hasValue() && "Expected at least one selection"); + assert(Effect && "Expected at least one selection"); if (*Effect && (*Effect)->FormatEdits) { // Format tweaks that require it centrally here. for (auto &It : (*Effect)->ApplyEdits) { diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp index 276e7a3704d4..eaf570da88da 100644 --- a/clang-tools-extra/clangd/CodeComplete.cpp +++ b/clang-tools-extra/clangd/CodeComplete.cpp @@ -835,7 +835,7 @@ struct CompletionRecorder : public CodeCompleteConsumer { continue; // Skip injected class name when no class scope is not explicitly set. // E.g. show injected A::A in `using A::A^` but not in "A^". - if (Result.Declaration && !Context.getCXXScopeSpecifier().hasValue() && + if (Result.Declaration && !Context.getCXXScopeSpecifier() && isInjectedClass(*Result.Declaration)) continue; // We choose to never append '::' to completion results in clangd. @@ -1439,7 +1439,7 @@ public: HeuristicPrefix = guessCompletionPrefix(SemaCCInput.ParseInput.Contents, SemaCCInput.Offset); populateContextWords(SemaCCInput.ParseInput.Contents); - if (Opts.Index && SpecFuzzyFind && SpecFuzzyFind->CachedReq.hasValue()) { + if (Opts.Index && SpecFuzzyFind && SpecFuzzyFind->CachedReq) { assert(!SpecFuzzyFind->Result.valid()); SpecReq = speculativeFuzzyFindRequestForCompletion( *SpecFuzzyFind->CachedReq, HeuristicPrefix); diff --git a/clang-tools-extra/clangd/IncludeFixer.cpp b/clang-tools-extra/clangd/IncludeFixer.cpp index c419d20f29d2..a057c438d7a9 100644 --- a/clang-tools-extra/clangd/IncludeFixer.cpp +++ b/clang-tools-extra/clangd/IncludeFixer.cpp @@ -544,7 +544,7 @@ IncludeFixer::unresolvedNameRecorder() { } std::vector IncludeFixer::fixUnresolvedName() const { - assert(LastUnresolvedName.hasValue()); + assert(LastUnresolvedName); auto &Unresolved = *LastUnresolvedName; vlog("Trying to fix unresolved name \"{0}\" in scopes: [{1}]", Unresolved.Name, llvm::join(Unresolved.Scopes, ", ")); diff --git a/clang-tools-extra/clangd/Protocol.cpp b/clang-tools-extra/clangd/Protocol.cpp index aed4ac09d486..01127fa9ae9e 100644 --- a/clang-tools-extra/clangd/Protocol.cpp +++ b/clang-tools-extra/clangd/Protocol.cpp @@ -34,7 +34,7 @@ bool mapOptOrNull(const llvm::json::Value &Params, llvm::StringLiteral Prop, assert(O); auto *V = O->get(Prop); // Field is missing or null. - if (!V || V->getAsNull().hasValue()) + if (!V || V->getAsNull()) return true; return fromJSON(*V, Out, P.field(Prop)); } @@ -608,7 +608,7 @@ llvm::json::Value toJSON(const Diagnostic &D) { Diag["codeActions"] = D.codeActions; if (!D.code.empty()) Diag["code"] = D.code; - if (D.codeDescription.hasValue()) + if (D.codeDescription) Diag["codeDescription"] = *D.codeDescription; if (!D.source.empty()) Diag["source"] = D.source; @@ -926,7 +926,7 @@ llvm::json::Value toJSON(const MarkupContent &MC) { llvm::json::Value toJSON(const Hover &H) { llvm::json::Object Result{{"contents", toJSON(H.contents)}}; - if (H.range.hasValue()) + if (H.range) Result["range"] = toJSON(*H.range); return std::move(Result); @@ -1024,7 +1024,7 @@ llvm::json::Value toJSON(const CompletionList &L) { } llvm::json::Value toJSON(const ParameterInformation &PI) { - assert((PI.labelOffsets.hasValue() || !PI.labelString.empty()) && + assert((PI.labelOffsets || !PI.labelString.empty()) && "parameter information label is required"); llvm::json::Object Result; if (PI.labelOffsets) diff --git a/clang-tools-extra/clangd/SemanticSelection.cpp b/clang-tools-extra/clangd/SemanticSelection.cpp index 2bead7af2d86..55f5816ed90b 100644 --- a/clang-tools-extra/clangd/SemanticSelection.cpp +++ b/clang-tools-extra/clangd/SemanticSelection.cpp @@ -121,7 +121,7 @@ llvm::Expected getSemanticRanges(ParsedAST &AST, Position Pos) { } auto SR = toHalfOpenFileRange(SM, LangOpts, Node->ASTNode.getSourceRange()); - if (!SR.hasValue() || SM.getFileID(SR->getBegin()) != SM.getMainFileID()) { + if (!SR || SM.getFileID(SR->getBegin()) != SM.getMainFileID()) { continue; } Range R; diff --git a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp index b9809a2808fa..e35dcf55a445 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp @@ -820,7 +820,7 @@ tooling::Replacement replaceWithFuncCall(const NewFunction &ExtractedFunc, tooling::Replacement createFunctionDefinition(const NewFunction &ExtractedFunc, const SourceManager &SM) { FunctionDeclKind DeclKind = InlineDefinition; - if (ExtractedFunc.ForwardDeclarationPoint.hasValue()) + if (ExtractedFunc.ForwardDeclarationPoint) DeclKind = OutOfLineDefinition; std::string FunctionDef = ExtractedFunc.renderDeclaration( DeclKind, *ExtractedFunc.SemanticDC, *ExtractedFunc.SyntacticDC, SM); diff --git a/clang-tools-extra/clangd/tool/Check.cpp b/clang-tools-extra/clangd/tool/Check.cpp index 492da45aed75..748510f91bcc 100644 --- a/clang-tools-extra/clangd/tool/Check.cpp +++ b/clang-tools-extra/clangd/tool/Check.cpp @@ -130,7 +130,7 @@ public: Inputs.ClangTidyProvider = Opts.ClangTidyProvider; Inputs.Opts.PreambleParseForwardingFunctions = Opts.PreambleParseForwardingFunctions; - if (Contents.hasValue()) { + if (Contents) { Inputs.Contents = *Contents; log("Imaginary source file contents:\n{0}", Inputs.Contents); } else { diff --git a/clang-tools-extra/pseudo/lib/DirectiveTree.cpp b/clang-tools-extra/pseudo/lib/DirectiveTree.cpp index 82843125329b..d5f97455685e 100644 --- a/clang-tools-extra/pseudo/lib/DirectiveTree.cpp +++ b/clang-tools-extra/pseudo/lib/DirectiveTree.cpp @@ -304,7 +304,7 @@ private: MayTakeTrivial = false; } // Is this the best branch so far? (Including if it's #if 1). - if (TookTrivial || !C.Taken.hasValue() || BranchScore > Best) { + if (TookTrivial || !C.Taken || BranchScore > Best) { Best = BranchScore; C.Taken = I; } diff --git a/clang-tools-extra/pseudo/lib/Forest.cpp b/clang-tools-extra/pseudo/lib/Forest.cpp index dce3c3a7b70a..3fd36d781beb 100644 --- a/clang-tools-extra/pseudo/lib/Forest.cpp +++ b/clang-tools-extra/pseudo/lib/Forest.cpp @@ -90,7 +90,7 @@ std::string ForestNode::dumpRecursive(const Grammar &G, Result += llvm::formatv("[{0,3}, {1,3}) ", P->startTokenIndex(), End); Result += LineDec.Prefix; Result += LineDec.First; - if (ElidedParent.hasValue()) { + if (ElidedParent) { Result += G.symbolName(*ElidedParent); Result += "~"; } diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h index 00f66d8e4d3e..a01b32669ce3 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h @@ -216,7 +216,7 @@ public: } bool isForeign() const { - assert(Foreign.hasValue() && "Foreign must be set before querying"); + assert(Foreign && "Foreign must be set before querying"); return *Foreign; } void setForeign(bool B) const { Foreign = B; } diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index ca6cb0830210..1bd2f1b9c770 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -2073,7 +2073,7 @@ Optional Preprocessor::LookupHeaderIncludeOrImport( } // If the file is still not found, just go with the vanilla diagnostic - assert(!File.hasValue() && "expected missing file"); + assert(!File && "expected missing file"); Diag(FilenameTok, diag::err_pp_file_not_found) << OriginalFilename << FilenameRange; if (IsFrameworkFound) { diff --git a/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp b/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp index 7b9b27ec2558..de94cb7c978d 100644 --- a/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp +++ b/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp @@ -120,7 +120,7 @@ AnalyzerOptions::mayInlineCXXMemberFunction( .Case("none", CIMK_None) .Default(None); - assert(K.hasValue() && "Invalid c++ member function inlining mode."); + assert(K && "Invalid c++ member function inlining mode."); return *K >= Param; } diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp index 558bc3b5ecfe..326a3b1fb665 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp @@ -1037,7 +1037,7 @@ bool ExprEngine::shouldInlineCall(const CallEvent &Call, const Decl *D, CallInlinePolicy CIP = mayInlineCallKind(Call, Pred, Opts, CallOpts); if (CIP != CIP_Allowed) { if (CIP == CIP_DisallowedAlways) { - assert(!MayInline.hasValue() || MayInline.getValue()); + assert(!MayInline || *MayInline); Engine.FunctionSummaries->markShouldNotInline(D); } return false; diff --git a/flang/include/flang/Lower/IterationSpace.h b/flang/include/flang/Lower/IterationSpace.h index 4c6f3a1fe1ca..35377579c2a2 100644 --- a/flang/include/flang/Lower/IterationSpace.h +++ b/flang/include/flang/Lower/IterationSpace.h @@ -500,7 +500,7 @@ public: } void attachLoopCleanup(std::function fn) { - if (!loopCleanup.hasValue()) { + if (!loopCleanup) { loopCleanup = fn; return; } diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp index dea8d3d3063f..de36822e81d3 100644 --- a/flang/lib/Lower/Bridge.cpp +++ b/flang/lib/Lower/Bridge.cpp @@ -2064,7 +2064,7 @@ private: return; } - if (lbounds.hasValue()) { + if (lbounds) { // Array of POINTER entities, with elemental assignment. if (!Fortran::lower::isWholePointer(assign.lhs)) fir::emitFatalError(toLocation(), "pointer assignment to non-pointer"); diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp index bc073a1d9527..104859d44881 100644 --- a/flang/lib/Lower/ConvertExpr.cpp +++ b/flang/lib/Lower/ConvertExpr.cpp @@ -2590,7 +2590,7 @@ public: return *allocatedResult; } - if (!resultType.hasValue()) + if (!resultType) return mlir::Value{}; // subroutine call // For now, Fortran return values are implemented with a single MLIR // function return value. @@ -6410,7 +6410,7 @@ private: mem = copyNeeded ? copyNextArrayCtorSection(exv, buffPos, buffSize, mem, eleSz, eleTy, eleRefTy, resTy) : fir::getBase(exv); - if (fir::isa_char(seqTy.getEleTy()) && !charLen.hasValue()) { + if (fir::isa_char(seqTy.getEleTy()) && !charLen) { charLen = builder.createTemporary(loc, builder.getI64Type()); mlir::Value castLen = builder.createConvert(loc, builder.getI64Type(), fir::getLen(exv)); @@ -6492,7 +6492,7 @@ private: mem = copyNeeded ? copyNextArrayCtorSection(exv, buffPos, buffSize, mem, eleSz, eleTy, eleRefTy, resTy) : fir::getBase(exv); - if (fir::isa_char(seqTy.getEleTy()) && !charLen.hasValue()) { + if (fir::isa_char(seqTy.getEleTy()) && !charLen) { charLen = builder.createTemporary(loc, builder.getI64Type()); mlir::Value castLen = builder.createConvert(loc, builder.getI64Type(), fir::getLen(exv)); diff --git a/flang/lib/Lower/IO.cpp b/flang/lib/Lower/IO.cpp index a738f8b87a38..f5a8da0ca93b 100644 --- a/flang/lib/Lower/IO.cpp +++ b/flang/lib/Lower/IO.cpp @@ -1852,7 +1852,7 @@ void genBeginDataTransferCallArgs( if constexpr (hasIOCtrl) { // READ or WRITE if (isInternal) { // descriptor or scalar variable; maybe explicit format; scratch area - if (descRef.hasValue()) { + if (descRef) { mlir::Value desc = builder.createBox(loc, *descRef); ioArgs.push_back( builder.createConvert(loc, ioFuncTy.getInput(ioArgs.size()), desc)); diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp index f1777afd4299..eeda56209494 100644 --- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp +++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp @@ -2493,7 +2493,7 @@ private: return mlir::emitError(loc, "invalid coordinate/check failed"); // check if the i-th coordinate relates to an array - if (dims.hasValue()) { + if (dims) { arrIdx.push_back(nxtOpnd); int dimsLeft = *dims; if (dimsLeft > 1) { @@ -2529,7 +2529,7 @@ private: offs.push_back(nxtOpnd); } - if (dims.hasValue()) + if (dims) offs.append(arrIdx.rbegin(), arrIdx.rend()); mlir::Value base = operands[0]; mlir::Value retval = genGEP(loc, ty, rewriter, base, offs); diff --git a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp index e20792115f42..c88d4317d29a 100644 --- a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp +++ b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp @@ -199,7 +199,7 @@ public: // to call. int dropFront = 0; if constexpr (std::is_same_v, fir::CallOp>) { - if (!callOp.getCallee().hasValue()) { + if (!callOp.getCallee()) { newInTys.push_back(fnTy.getInput(0)); newOpers.push_back(callOp.getOperand(0)); dropFront = 1; @@ -327,7 +327,7 @@ public: newCall = rewriter->create(loc, newResTys, newOpers); } LLVM_DEBUG(llvm::dbgs() << "replacing call with " << newCall << '\n'); - if (wrap.hasValue()) + if (wrap) replaceOp(callOp, (*wrap)(newCall.getOperation())); else replaceOp(callOp, newCall.getResults()); diff --git a/flang/lib/Optimizer/Support/InternalNames.cpp b/flang/lib/Optimizer/Support/InternalNames.cpp index 01bd3acc7228..8e37df2f7df0 100644 --- a/flang/lib/Optimizer/Support/InternalNames.cpp +++ b/flang/lib/Optimizer/Support/InternalNames.cpp @@ -38,7 +38,7 @@ static std::string doModules(llvm::ArrayRef mods) { static std::string doModulesHost(llvm::ArrayRef mods, llvm::Optional host) { std::string result = doModules(mods); - if (host.hasValue()) + if (host) result.append("F").append(host->lower()); return result; } diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp index 2843a9dde09b..63a392e2970d 100644 --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -620,7 +620,7 @@ void LinkerDriver::addWinSysRootLibSearchPaths() { // Parses LIB environment which contains a list of search paths. void LinkerDriver::addLibSearchPaths() { Optional envOpt = Process::GetEnv("LIB"); - if (!envOpt.hasValue()) + if (!envOpt) return; StringRef env = saver().save(*envOpt); while (!env.empty()) { diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 7b5a588fa3e5..0d46c8d73bbd 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -208,7 +208,7 @@ void LinkerDriver::addFile(StringRef path, bool withLOption) { using namespace sys::fs; Optional buffer = readFile(path); - if (!buffer.hasValue()) + if (!buffer) return; MemoryBufferRef mbref = *buffer; diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 1bce8de193bb..9ded809fdefe 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -697,7 +697,7 @@ static void updateARMVFPArgs(const ARMAttributeParser &attributes, const InputFile *f) { Optional attr = attributes.getAttributeValue(ARMBuildAttrs::ABI_VFP_args); - if (!attr.hasValue()) + if (!attr) // If an ABI tag isn't present then it is implicitly given the value of 0 // which maps to ARMBuildAttrs::BaseAAPCS. However many assembler files, // including some in glibc that don't use FP args (and should have value 3) diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 0f4c908efdd2..3be42904b7fe 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -1350,7 +1350,7 @@ SmallVector LinkerScript::createPhdrs() { // Assign headers specified by linker script for (size_t id : getPhdrIndices(sec)) { ret[id]->add(sec); - if (!phdrsCommands[id].flags.hasValue()) + if (!phdrsCommands[id].flags) ret[id]->p_flags |= sec->getPhdrFlags(); } } diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp index 3764c921ff45..32bd1ef3344e 100644 --- a/lld/wasm/Driver.cpp +++ b/lld/wasm/Driver.cpp @@ -234,7 +234,7 @@ std::vector static getArchiveMembers(MemoryBufferRef mb) { void LinkerDriver::addFile(StringRef path) { Optional buffer = readFile(path); - if (!buffer.hasValue()) + if (!buffer) return; MemoryBufferRef mbref = *buffer; diff --git a/lld/wasm/InputFiles.cpp b/lld/wasm/InputFiles.cpp index 04ec342fe542..84389f1a06d7 100644 --- a/lld/wasm/InputFiles.cpp +++ b/lld/wasm/InputFiles.cpp @@ -44,7 +44,7 @@ namespace wasm { void InputFile::checkArch(Triple::ArchType arch) const { bool is64 = arch == Triple::wasm64; - if (is64 && !config->is64.hasValue()) { + if (is64 && !config->is64) { fatal(toString(this) + ": must specify -mwasm64 to process wasm64 object files"); } else if (config->is64.value_or(false) != is64) { diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp index e0d07e5e6228..ecc808aae6ca 100644 --- a/lld/wasm/Writer.cpp +++ b/lld/wasm/Writer.cpp @@ -754,7 +754,7 @@ void Writer::createCommandExportWrappers() { const std::string &funcName = commandExportWrapperNames.back(); auto func = make(*f->getSignature(), funcName); - if (f->function->getExportName().hasValue()) + if (f->function->getExportName()) func->setExportName(f->function->getExportName()->str()); else func->setExportName(f->getName().str()); diff --git a/lldb/source/Breakpoint/BreakpointIDList.cpp b/lldb/source/Breakpoint/BreakpointIDList.cpp index 172674dc2dd2..b43405699364 100644 --- a/lldb/source/Breakpoint/BreakpointIDList.cpp +++ b/lldb/source/Breakpoint/BreakpointIDList.cpp @@ -52,7 +52,7 @@ bool BreakpointIDList::AddBreakpointID(BreakpointID bp_id) { bool BreakpointIDList::AddBreakpointID(const char *bp_id_str) { auto bp_id = BreakpointID::ParseCanonicalReference(bp_id_str); - if (!bp_id.hasValue()) + if (!bp_id) return false; m_breakpoint_ids.push_back(*bp_id); @@ -76,7 +76,7 @@ bool BreakpointIDList::FindBreakpointID(BreakpointID &bp_id, bool BreakpointIDList::FindBreakpointID(const char *bp_id_str, size_t *position) const { auto bp_id = BreakpointID::ParseCanonicalReference(bp_id_str); - if (!bp_id.hasValue()) + if (!bp_id) return false; return FindBreakpointID(*bp_id, position); @@ -89,7 +89,7 @@ void BreakpointIDList::InsertStringArray( for (const char *str : string_array) { auto bp_id = BreakpointID::ParseCanonicalReference(str); - if (bp_id.hasValue()) + if (bp_id) m_breakpoint_ids.push_back(*bp_id); } result.SetStatus(eReturnStatusSuccessFinishNoResult); @@ -163,7 +163,7 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target, BreakpointSP breakpoint_sp; auto bp_id = BreakpointID::ParseCanonicalReference(bp_id_str); - if (bp_id.hasValue()) + if (bp_id) breakpoint_sp = target->GetBreakpointByID(bp_id->GetBreakpointID()); if (!breakpoint_sp) { new_args.Clear(); diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index 5ba28d2c602e..4081e87f2ddb 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -304,7 +304,7 @@ protected: Thread *thread = m_exe_ctx.GetThreadPtr(); uint32_t frame_idx = UINT32_MAX; - if (m_options.relative_frame_offset.hasValue()) { + if (m_options.relative_frame_offset) { // The one and only argument is a signed relative frame index frame_idx = thread->GetSelectedFrameIndex(); if (frame_idx == UINT32_MAX) diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index c6f1cbe581da..aad3cc412baf 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -1313,7 +1313,7 @@ void Debugger::ReportProgress(uint64_t progress_id, const std::string &message, uint64_t completed, uint64_t total, llvm::Optional debugger_id) { // Check if this progress is for a specific debugger. - if (debugger_id.hasValue()) { + if (debugger_id) { // It is debugger specific, grab it and deliver the event if the debugger // still exists. DebuggerSP debugger_sp = FindDebuggerWithID(*debugger_id); diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp index aa10c43a0c68..78b8bf11220a 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp @@ -858,7 +858,7 @@ bool ClangUserExpression::Complete(ExecutionContext &exe_ctx, // The line and column of the user expression inside the transformed source // code. unsigned user_expr_line, user_expr_column; - if (m_user_expression_start_pos.hasValue()) + if (m_user_expression_start_pos) AbsPosToLineColumnPos(*m_user_expression_start_pos, m_transformed_text, user_expr_line, user_expr_column); else diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp index bef88a67573a..fd673535edee 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp @@ -319,7 +319,7 @@ bool AppleObjCRuntime::AppleIsModuleObjCLibrary(const ModuleSP &module_sp) { // we use the version of Foundation to make assumptions about the ObjC runtime // on a target uint32_t AppleObjCRuntime::GetFoundationVersion() { - if (!m_Foundation_major.hasValue()) { + if (!m_Foundation_major) { const ModuleList &modules = m_process->GetTarget().GetImages(); for (uint32_t idx = 0; idx < modules.GetSize(); idx++) { lldb::ModuleSP module_sp = modules.GetModuleAtIndex(idx); diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index 0a28aa0d8bcc..924d5b694ca6 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -6003,7 +6003,7 @@ llvm::VersionTuple ObjectFileMachO::GetMinimumOSVersion() { } llvm::VersionTuple ObjectFileMachO::GetSDKVersion() { - if (!m_sdk_versions.hasValue()) { + if (!m_sdk_versions) { lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic); for (uint32_t i = 0; i < m_header.ncmds; ++i) { const lldb::offset_t load_cmd_offset = offset; @@ -6032,7 +6032,7 @@ llvm::VersionTuple ObjectFileMachO::GetSDKVersion() { offset = load_cmd_offset + lc.cmdsize; } - if (!m_sdk_versions.hasValue()) { + if (!m_sdk_versions) { offset = MachHeaderSizeFromMagic(m_header.magic); for (uint32_t i = 0; i < m_header.ncmds; ++i) { const lldb::offset_t load_cmd_offset = offset; @@ -6069,7 +6069,7 @@ llvm::VersionTuple ObjectFileMachO::GetSDKVersion() { } } - if (!m_sdk_versions.hasValue()) + if (!m_sdk_versions) m_sdk_versions = llvm::VersionTuple(); } diff --git a/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp b/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp index b1f032e0cc02..0fc975b89f22 100644 --- a/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp +++ b/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp @@ -28,7 +28,7 @@ NativeProcessELF::GetAuxValue(enum AuxVector::EntryType type) { } lldb::addr_t NativeProcessELF::GetSharedLibraryInfoAddress() { - if (!m_shared_library_info_addr.hasValue()) { + if (!m_shared_library_info_addr) { if (GetAddressByteSize() == 8) m_shared_library_info_addr = GetELFImageInfoAddress MinidumpParser::GetPid() { } llvm::Optional proc_status = GetLinuxProcStatus(); - if (proc_status.hasValue()) { + if (proc_status) { return proc_status->GetPid(); } diff --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp index 8cacd7bc3fcc..58e581fce728 100644 --- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp +++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp @@ -511,7 +511,7 @@ SymbolFileBreakpad::GetParameterStackSize(Symbol &symbol) { symbol.GetAddress().GetFileAddress())) { auto record = StackWinRecord::parse( *LineIterator(*m_objfile_sp, Record::StackWin, entry->data)); - assert(record.hasValue()); + assert(record); return record->ParameterSize; } return llvm::createStringError(llvm::inconvertibleErrorCode(), @@ -655,7 +655,7 @@ SymbolFileBreakpad::ParseCFIUnwindPlan(const Bookmark &bookmark, LineIterator It(*m_objfile_sp, Record::StackCFI, bookmark), End(*m_objfile_sp); llvm::Optional init_record = StackCFIRecord::parse(*It); - assert(init_record.hasValue() && init_record->Size.hasValue() && + assert(init_record && init_record->Size && "Record already parsed successfully in ParseUnwindData!"); auto plan_sp = std::make_shared(lldb::eRegisterKindLLDB); diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp index 0217186cf87a..4e586d0825d9 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp @@ -1453,7 +1453,7 @@ void PdbAstBuilder::ParseAllNamespacesPlusChildrenOf( CVTagRecord tag = CVTagRecord::create(cvt); - if (!parent.hasValue()) { + if (!parent) { clang::QualType qt = GetOrCreateType(tid); CompleteType(qt); continue; diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index d260b5f537a2..e0f646b15641 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -1540,7 +1540,7 @@ static bool ClassTemplateAllowsToInstantiationArgs( return false; // Ensure that != . - if (pack_parameter.hasValue() != instantiation_values.hasParameterPack()) + if (pack_parameter.has_value() != instantiation_values.hasParameterPack()) return false; // Compare the first pack parameter that was found with the first pack diff --git a/lldb/source/Utility/SelectHelper.cpp b/lldb/source/Utility/SelectHelper.cpp index 059f810e2194..eee6895296be 100644 --- a/lldb/source/Utility/SelectHelper.cpp +++ b/lldb/source/Utility/SelectHelper.cpp @@ -84,7 +84,7 @@ bool SelectHelper::FDIsSetError(lldb::socket_t fd) const { static void updateMaxFd(llvm::Optional &vold, lldb::socket_t vnew) { - if (!vold.hasValue()) + if (!vold) vold = vnew; else vold = std::max(*vold, vnew); @@ -123,7 +123,7 @@ lldb_private::Status SelectHelper::Select() { updateMaxFd(max_fd, fd); } - if (!max_fd.hasValue()) { + if (!max_fd) { error.SetErrorString("no valid file descriptors"); return error; } diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h index 635a71fc94de..fbf2e9c1590d 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h @@ -132,7 +132,7 @@ public: uint32_t getRegister() const { return RegNum; } int32_t getOffset() const { return Offset; } uint32_t getAddressSpace() const { - assert(Kind == RegPlusOffset && AddrSpace.hasValue()); + assert(Kind == RegPlusOffset && AddrSpace); return *AddrSpace; } int32_t getConstant() const { return Offset; } diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h index 2e0c6a40bfdc..2b387db47ed2 100644 --- a/llvm/include/llvm/IR/IRBuilder.h +++ b/llvm/include/llvm/IR/IRBuilder.h @@ -300,7 +300,7 @@ public: void setDefaultConstrainedExcept(fp::ExceptionBehavior NewExcept) { #ifndef NDEBUG Optional ExceptStr = convertExceptionBehaviorToStr(NewExcept); - assert(ExceptStr.hasValue() && "Garbage strict exception behavior!"); + assert(ExceptStr && "Garbage strict exception behavior!"); #endif DefaultConstrainedExcept = NewExcept; } @@ -309,7 +309,7 @@ public: void setDefaultConstrainedRounding(RoundingMode NewRounding) { #ifndef NDEBUG Optional RoundingStr = convertRoundingModeToStr(NewRounding); - assert(RoundingStr.hasValue() && "Garbage strict rounding mode!"); + assert(RoundingStr && "Garbage strict rounding mode!"); #endif DefaultConstrainedRounding = NewRounding; } diff --git a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp index a19eb6114ff8..9d6799b48a2d 100644 --- a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp +++ b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp @@ -193,7 +193,7 @@ StringRef IRInstructionData::getCalleeName() const { assert(isa(Inst) && "Can only get a name from a call instruction"); - assert(CalleeName.hasValue() && "CalleeName has not been set"); + assert(CalleeName && "CalleeName has not been set"); return *CalleeName; } diff --git a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp index 5226816defae..bd100a297504 100644 --- a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp +++ b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp @@ -7587,7 +7587,7 @@ LegalizerHelper::lowerMemcpyInline(MachineInstr &MI) { // See if this is a constant length copy auto LenVRegAndVal = getIConstantVRegValWithLookThrough(Len, MRI); // FIXME: support dynamically sized G_MEMCPY_INLINE - assert(LenVRegAndVal.hasValue() && + assert(LenVRegAndVal && "inline memcpy with dynamic size is not yet supported"); uint64_t KnownLen = LenVRegAndVal->Value.getZExtValue(); if (KnownLen == 0) { diff --git a/llvm/lib/DWARFLinker/DWARFLinker.cpp b/llvm/lib/DWARFLinker/DWARFLinker.cpp index 6cb5006a7dc9..e4fb7b22806a 100644 --- a/llvm/lib/DWARFLinker/DWARFLinker.cpp +++ b/llvm/lib/DWARFLinker/DWARFLinker.cpp @@ -468,7 +468,7 @@ unsigned DWARFLinker::shouldKeepSubprogramDIE( if (!LowPc) return Flags; - assert(LowPc.hasValue() && "low_pc attribute is not an address."); + assert(LowPc && "low_pc attribute is not an address."); if (!RelocMgr.isLiveSubprogram(DIE, MyInfo)) return Flags; diff --git a/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp b/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp index 1554a6eced8a..a3dbb3954d5c 100644 --- a/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp +++ b/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp @@ -49,7 +49,7 @@ ContinuationRecordBuilder::ContinuationRecordBuilder() ContinuationRecordBuilder::~ContinuationRecordBuilder() = default; void ContinuationRecordBuilder::begin(ContinuationRecordKind RecordKind) { - assert(!Kind.hasValue()); + assert(!Kind); Kind = RecordKind; Buffer.clear(); SegmentWriter.setOffset(0); @@ -76,7 +76,7 @@ void ContinuationRecordBuilder::begin(ContinuationRecordKind RecordKind) { template void ContinuationRecordBuilder::writeMemberType(RecordType &Record) { - assert(Kind.hasValue()); + assert(Kind); uint32_t OriginalOffset = SegmentWriter.getOffset(); CVMemberRecord CVMR; diff --git a/llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp b/llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp index 0c4a02388d75..5fb8d497b957 100644 --- a/llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp +++ b/llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp @@ -24,7 +24,7 @@ SymbolSerializer::SymbolSerializer(BumpPtrAllocator &Allocator, Mapping(Writer, Container) {} Error SymbolSerializer::visitSymbolBegin(CVSymbol &Record) { - assert(!CurrentSymbol.hasValue() && "Already in a symbol mapping!"); + assert(!CurrentSymbol && "Already in a symbol mapping!"); Writer.setOffset(0); @@ -39,7 +39,7 @@ Error SymbolSerializer::visitSymbolBegin(CVSymbol &Record) { } Error SymbolSerializer::visitSymbolEnd(CVSymbol &Record) { - assert(CurrentSymbol.hasValue() && "Not in a symbol mapping!"); + assert(CurrentSymbol && "Not in a symbol mapping!"); if (auto EC = Mapping.visitSymbolEnd(Record)) return EC; diff --git a/llvm/lib/DebugInfo/PDB/Native/InputFile.cpp b/llvm/lib/DebugInfo/PDB/Native/InputFile.cpp index ec7c4e1e3353..495b25077737 100644 --- a/llvm/lib/DebugInfo/PDB/Native/InputFile.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/InputFile.cpp @@ -525,7 +525,7 @@ SymbolGroupIterator &SymbolGroupIterator::operator++() { } void SymbolGroupIterator::scanToNextDebugS() { - assert(SectionIter.hasValue()); + assert(SectionIter); auto End = Value.File->obj().section_end(); auto &Iter = *SectionIter; assert(!isEnd()); @@ -551,7 +551,7 @@ bool SymbolGroupIterator::isEnd() const { return Index == Count; } - assert(SectionIter.hasValue()); + assert(SectionIter); return *SectionIter == Value.File->obj().section_end(); } diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index bf0491d2397d..c5534a79eb54 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -1971,7 +1971,7 @@ void Function::setEntryCount(ProfileCount Count, const DenseSet *S) { #if !defined(NDEBUG) auto PrevCount = getEntryCount(); - assert(!PrevCount.hasValue() || PrevCount->getType() == Count.getType()); + assert(!PrevCount || PrevCount->getType() == Count.getType()); #endif auto ImportGUIDs = getImportGUIDs(); diff --git a/llvm/lib/IR/IntrinsicInst.cpp b/llvm/lib/IR/IntrinsicInst.cpp index 7e564c624b4b..5deb3a5a634e 100644 --- a/llvm/lib/IR/IntrinsicInst.cpp +++ b/llvm/lib/IR/IntrinsicInst.cpp @@ -617,7 +617,7 @@ CmpInst::Predicate VPCmpIntrinsic::getPredicate() const { #define END_REGISTER_VP_INTRINSIC(VPID) break; #include "llvm/IR/VPIntrinsics.def" } - assert(CCArgIdx.hasValue() && "Unexpected vector-predicated comparison"); + assert(CCArgIdx && "Unexpected vector-predicated comparison"); return IsFP ? getFPPredicateFromMD(getArgOperand(*CCArgIdx)) : getIntPredicateFromMD(getArgOperand(*CCArgIdx)); } diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp index 6f429540713e..f64ee2a8d044 100644 --- a/llvm/lib/ObjectYAML/ELFYAML.cpp +++ b/llvm/lib/ObjectYAML/ELFYAML.cpp @@ -1335,7 +1335,7 @@ static void sectionMapping(IO &IO, ELFYAML::RawContentSection &Section) { // We also support reading a content as array of bytes using the ContentArray // key. obj2yaml never prints this field. - assert(!IO.outputting() || !Section.ContentBuf.hasValue()); + assert(!IO.outputting() || !Section.ContentBuf); IO.mapOptional("ContentArray", Section.ContentBuf); if (Section.ContentBuf) { if (Section.Content) diff --git a/llvm/lib/Target/Mips/MipsTargetStreamer.h b/llvm/lib/Target/Mips/MipsTargetStreamer.h index 44615b987e3c..2f4b6eb37aa1 100644 --- a/llvm/lib/Target/Mips/MipsTargetStreamer.h +++ b/llvm/lib/Target/Mips/MipsTargetStreamer.h @@ -178,7 +178,7 @@ public: MipsABIFlagsSection &getABIFlagsSection() { return ABIFlagsSection; } const MipsABIInfo &getABI() const { - assert(ABI.hasValue() && "ABI hasn't been set!"); + assert(ABI && "ABI hasn't been set!"); return *ABI; } diff --git a/llvm/lib/Transforms/IPO/IROutliner.cpp b/llvm/lib/Transforms/IPO/IROutliner.cpp index 136aaed0c8df..eb4315490639 100644 --- a/llvm/lib/Transforms/IPO/IROutliner.cpp +++ b/llvm/lib/Transforms/IPO/IROutliner.cpp @@ -182,7 +182,7 @@ static void getSortedConstantKeys(std::vector &SortedKeys, Value *OutlinableRegion::findCorrespondingValueIn(const OutlinableRegion &Other, Value *V) { Optional GVN = Candidate->getGVN(V); - assert(GVN.hasValue() && "No GVN for incoming value"); + assert(GVN && "No GVN for incoming value"); Optional CanonNum = Candidate->getCanonicalNum(*GVN); Optional FirstGVN = Other.Candidate->fromCanonicalNum(*CanonNum); Optional FoundValueOpt = Other.Candidate->fromGVN(*FirstGVN); @@ -1196,7 +1196,7 @@ static Optional getGVNForPHINode(OutlinableRegion &Region, // Collect the canonical numbers of the values in the PHINode. unsigned GVN = OGVN.getValue(); OGVN = Cand.getCanonicalNum(GVN); - assert(OGVN.hasValue() && "No GVN found for incoming value?"); + assert(OGVN && "No GVN found for incoming value?"); PHIGVNs.push_back(*OGVN); // Find the incoming block and use the canonical numbering as well to define @@ -1225,7 +1225,7 @@ static Optional getGVNForPHINode(OutlinableRegion &Region, } GVN = OGVN.getValue(); OGVN = Cand.getCanonicalNum(GVN); - assert(OGVN.hasValue() && "No GVN found for incoming block?"); + assert(OGVN && "No GVN found for incoming block?"); PHIGVNs.push_back(*OGVN); } diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp index e687641395cf..60c9266c669b 100644 --- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp +++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp @@ -4582,7 +4582,7 @@ private: // We have empty reaching kernels, therefore we cannot tell if the // associated call site can be folded. At this moment, SimplifiedValue // must be none. - assert(!SimplifiedValue.hasValue() && "SimplifiedValue should be none"); + assert(!SimplifiedValue && "SimplifiedValue should be none"); } return SimplifiedValue == SimplifiedValueBefore ? ChangeStatus::UNCHANGED @@ -4625,7 +4625,7 @@ private: return indicatePessimisticFixpoint(); if (CallerKernelInfoAA.ReachingKernelEntries.empty()) { - assert(!SimplifiedValue.hasValue() && + assert(!SimplifiedValue && "SimplifiedValue should keep none at this point"); return ChangeStatus::UNCHANGED; } diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp index f762a0adb846..4dac144b4b1e 100644 --- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -1607,7 +1607,7 @@ static void fixFuncEntryCount(PGOUseFunc &Func, LoopInfo &LI, BlockFrequencyInfo NBFI(F, NBPI, LI); #ifndef NDEBUG auto BFIEntryCount = F.getEntryCount(); - assert(BFIEntryCount.hasValue() && (BFIEntryCount->getCount() > 0) && + assert(BFIEntryCount && (BFIEntryCount->getCount() > 0) && "Invalid BFI Entrycount"); #endif auto SumCount = APFloat::getZero(APFloat::IEEEdouble()); diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp index 2c2c3c21c3df..e4ea6daee9de 100644 --- a/llvm/utils/TableGen/GlobalISelEmitter.cpp +++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp @@ -468,7 +468,7 @@ public: int64_t RawValue = std::numeric_limits::min()) : LabelID(LabelID_.value_or(~0u)), EmitStr(EmitStr), NumElements(NumElements), Flags(Flags), RawValue(RawValue) { - assert((!LabelID_.hasValue() || LabelID != ~0u) && + assert((!LabelID_ || LabelID != ~0u) && "This value is reserved for non-labels"); } MatchTableRecord(const MatchTableRecord &Other) = default; diff --git a/mlir/lib/Analysis/Presburger/Simplex.cpp b/mlir/lib/Analysis/Presburger/Simplex.cpp index 92cc4d643d54..36b16f51ae9c 100644 --- a/mlir/lib/Analysis/Presburger/Simplex.cpp +++ b/mlir/lib/Analysis/Presburger/Simplex.cpp @@ -1162,7 +1162,7 @@ void Simplex::undoLastConstraint() { pivot(*maybeRow, column); } else { Optional row = findAnyPivotRow(column); - assert(row.hasValue() && "Pivot should always exist for a constraint!"); + assert(row && "Pivot should always exist for a constraint!"); pivot(*row, column); } } @@ -1181,7 +1181,7 @@ void LexSimplexBase::undoLastConstraint() { // long as we get the unknown to row orientation and remove it. unsigned column = con.back().pos; Optional row = findAnyPivotRow(column); - assert(row.hasValue() && "Pivot should always exist for a constraint!"); + assert(row && "Pivot should always exist for a constraint!"); pivot(*row, column); } removeLastConstraintRowOrientation(); diff --git a/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp b/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp index c8f7daafeda9..8a33ae02f99b 100644 --- a/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp @@ -1272,7 +1272,7 @@ static bool isFusionProfitable(Operation *srcOpInst, Operation *srcStoreOpInst, auto srcMemSizeVal = srcMemSize.getValue(); auto dstMemSizeVal = dstMemSize.getValue(); - assert(sliceMemEstimate.hasValue() && "expected value"); + assert(sliceMemEstimate && "expected value"); auto fusedMem = dstMemSizeVal + sliceMemEstimate.getValue(); LLVM_DEBUG(llvm::dbgs() << " src mem: " << srcMemSizeVal << "\n" diff --git a/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp b/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp index 7220cd6fc3b3..aa20e084f1e8 100644 --- a/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp +++ b/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp @@ -1440,7 +1440,7 @@ static bool checkLoopInterchangeDependences( // This iterates through loops in the desired order. for (unsigned j = 0; j < maxLoopDepth; ++j) { unsigned permIndex = loopPermMapInv[j]; - assert(depComps[permIndex].lb.hasValue()); + assert(depComps[permIndex].lb); int64_t depCompLb = depComps[permIndex].lb.getValue(); if (depCompLb > 0) break; diff --git a/mlir/lib/Dialect/Affine/Utils/Utils.cpp b/mlir/lib/Dialect/Affine/Utils/Utils.cpp index ad6af0f72f20..5f9eee572cbb 100644 --- a/mlir/lib/Dialect/Affine/Utils/Utils.cpp +++ b/mlir/lib/Dialect/Affine/Utils/Utils.cpp @@ -1791,7 +1791,7 @@ MemRefType mlir::normalizeMemRefType(MemRefType memrefType, OpBuilder b, auto ubConst = fac.getConstantBound(IntegerPolyhedron::UB, d); // For a static memref and an affine map with no symbols, this is // always bounded. - assert(ubConst.hasValue() && "should always have an upper bound"); + assert(ubConst && "should always have an upper bound"); if (ubConst.getValue() < 0) // This is due to an invalid map that maps to a negative space. return memrefType; diff --git a/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp b/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp index 754cc85a7c2f..9b4831e80e3c 100644 --- a/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp +++ b/mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp @@ -104,7 +104,7 @@ getFuncAnalysisState(const AnalysisState &state) { Optional maybeState = state.getDialectState( func::FuncDialect::getDialectNamespace()); - assert(maybeState.hasValue() && "FuncAnalysisState does not exist"); + assert(maybeState && "FuncAnalysisState does not exist"); return **maybeState; } diff --git a/mlir/lib/Dialect/Bufferization/Transforms/OneShotModuleBufferize.cpp b/mlir/lib/Dialect/Bufferization/Transforms/OneShotModuleBufferize.cpp index bb6f0532af70..acdb59a15598 100644 --- a/mlir/lib/Dialect/Bufferization/Transforms/OneShotModuleBufferize.cpp +++ b/mlir/lib/Dialect/Bufferization/Transforms/OneShotModuleBufferize.cpp @@ -82,7 +82,7 @@ getFuncAnalysisState(const AnalysisState &state) { Optional maybeState = state.getDialectState( func::FuncDialect::getDialectNamespace()); - assert(maybeState.hasValue() && "FuncAnalysisState does not exist"); + assert(maybeState && "FuncAnalysisState does not exist"); return **maybeState; } diff --git a/mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp b/mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp index 774b1f361716..c017dc9473f8 100644 --- a/mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp +++ b/mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp @@ -306,7 +306,7 @@ bool matcher::operatesOnSuperVectorsOf(Operation &op, auto ratio = shapeRatio(superVectorType, subVectorType); // Sanity check. - assert((ratio.hasValue() || !mustDivide) && + assert((ratio || !mustDivide) && "vector.transfer operation in which super-vector size is not an" " integer multiple of sub-vector size"); diff --git a/mlir/lib/Tools/lsp-server-support/Protocol.cpp b/mlir/lib/Tools/lsp-server-support/Protocol.cpp index 79b30252353e..b8a00b9d271c 100644 --- a/mlir/lib/Tools/lsp-server-support/Protocol.cpp +++ b/mlir/lib/Tools/lsp-server-support/Protocol.cpp @@ -781,7 +781,7 @@ bool mlir::lsp::fromJSON(const llvm::json::Value &value, //===----------------------------------------------------------------------===// llvm::json::Value mlir::lsp::toJSON(const ParameterInformation &value) { - assert((value.labelOffsets.hasValue() || !value.labelString.empty()) && + assert((value.labelOffsets || !value.labelString.empty()) && "parameter information label is required"); llvm::json::Object result; if (value.labelOffsets) diff --git a/mlir/test/lib/IR/TestSymbolUses.cpp b/mlir/test/lib/IR/TestSymbolUses.cpp index a7f4d9038626..9a3621f1f1b3 100644 --- a/mlir/test/lib/IR/TestSymbolUses.cpp +++ b/mlir/test/lib/IR/TestSymbolUses.cpp @@ -52,7 +52,7 @@ struct SymbolUsesPass // Test the functionality of getSymbolUses. symbolUses = SymbolTable::getSymbolUses(symbol, &module.getBodyRegion()); - assert(symbolUses.hasValue() && "expected no unknown operations"); + assert(symbolUses && "expected no unknown operations"); for (SymbolTable::SymbolUse symbolUse : *symbolUses) { // Check that we can resolve back to our symbol. if (SymbolTable::lookupNearestSymbolFrom( diff --git a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp index e6fdc11231a6..99d356381c90 100644 --- a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp +++ b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp @@ -718,7 +718,7 @@ static LogicalResult generateNamedGenericOpOds(LinalgOpConfig &opConfig, static const char stmtFmt[] = "$_state.addAttribute(\"{0}\", {0});"; // Add the type conversion attributes to the op definition and builders. if (isFunctionAttribute(arg.kind)) { - assert(arg.defaultFn.hasValue()); + assert(arg.defaultFn); std::string enumName = convertOperandKindToEnumName(arg.kind); static const char typeFmt[] = "{0}::{1}"; static const char defFmt[] = "DefaultValuedAttr<{0}, \"{1}\">:${2}"; @@ -861,7 +861,7 @@ exprs.push_back(getAffineConstantExpr(cst{1}, context)); for (LinalgOperandDef &arg : opConfig.structuredOp->args) { if (arg.kind != LinalgOperandDefKind::IndexAttr) continue; - assert(arg.indexAttrMap.hasValue()); + assert(arg.indexAttrMap); for (auto &en : llvm::enumerate(arg.indexAttrMap->affineMap().getResults())) { if (auto symbol = en.value().dyn_cast()) { @@ -958,7 +958,7 @@ std::string {0}::getLibraryCallName() {{ for (LinalgOperandDef &arg : opConfig.structuredOp->args) { if (arg.kind != LinalgOperandDefKind::IndexAttr) continue; - assert(arg.indexAttrMap.hasValue()); + assert(arg.indexAttrMap); // Verify index attribute. Paramters: // {0}: Attribute name // {1}: Attribute size diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp index d55e199f25a9..115ff8cfea3a 100644 --- a/mlir/tools/mlir-tblgen/RewriterGen.cpp +++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp @@ -1745,7 +1745,7 @@ StringRef StaticMatcherHelper::getVerifierName(DagLeaf leaf) { if (leaf.isAttrMatcher()) { Optional constraint = staticVerifierEmitter.getAttrConstraintFn(leaf.getAsConstraint()); - assert(constraint.hasValue() && "attribute constraint was not uniqued"); + assert(constraint && "attribute constraint was not uniqued"); return *constraint; } assert(leaf.isOperandMatcher());