diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp index 57b19bd30c1c..f7ffcdbc692b 100644 --- a/clang-tools-extra/clang-tidy/ClangTidy.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp @@ -104,7 +104,7 @@ public: DiagPrinter), SourceMgr(Diags, Files), Context(Context), ApplyFixes(ApplyFixes), TotalFixes(0), AppliedFixes(0), WarningsAsErrors(0) { - DiagOpts->ShowColors = Context.getOptions().UseColor.getValueOr( + DiagOpts->ShowColors = Context.getOptions().UseColor.value_or( llvm::sys::Process::StandardOutHasColors()); DiagPrinter->BeginSourceFile(LangOpts); if (DiagOpts->ShowColors && !llvm::sys::Process::StandardOutIsDisplayed()) { diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp index e315318a655f..dc38b4e190cc 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp @@ -204,13 +204,13 @@ void ClangTidyCheck::OptionsView::diagnoseBadEnumOption( StringRef ClangTidyCheck::OptionsView::get(StringRef LocalName, StringRef Default) const { - return get(LocalName).getValueOr(Default); + return get(LocalName).value_or(Default); } StringRef ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName, StringRef Default) const { - return getLocalOrGlobal(LocalName).getValueOr(Default); + return getLocalOrGlobal(LocalName).value_or(Default); } } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.h b/clang-tools-extra/clang-tidy/ClangTidyCheck.h index 77e41990b1da..abf528d65597 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyCheck.h +++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.h @@ -213,7 +213,7 @@ public: template std::enable_if_t::value, T> get(StringRef LocalName, T Default) const { - return get(LocalName).getValueOr(Default); + return get(LocalName).value_or(Default); } /// Read a named option from the ``Context`` and parse it as an @@ -258,7 +258,7 @@ public: template std::enable_if_t::value, T> getLocalOrGlobal(StringRef LocalName, T Default) const { - return getLocalOrGlobal(LocalName).getValueOr(Default); + return getLocalOrGlobal(LocalName).value_or(Default); } /// Read a named option from the ``Context`` and parse it as an @@ -297,7 +297,7 @@ public: template std::enable_if_t::value, T> get(StringRef LocalName, T Default, bool IgnoreCase = false) const { - return get(LocalName, IgnoreCase).getValueOr(Default); + return get(LocalName, IgnoreCase).value_or(Default); } /// Read a named option from the ``Context`` and parse it as an @@ -339,7 +339,7 @@ public: std::enable_if_t::value, T> getLocalOrGlobal(StringRef LocalName, T Default, bool IgnoreCase = false) const { - return getLocalOrGlobal(LocalName, IgnoreCase).getValueOr(Default); + return getLocalOrGlobal(LocalName, IgnoreCase).value_or(Default); } /// Stores an option with the check-local name \p LocalName with diff --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp index 1e62d1c5f5ed..a12a4d6692c7 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp @@ -207,7 +207,7 @@ std::vector ConfigOptionsProvider::getRawOptions(llvm::StringRef FileName) { std::vector RawOptions = DefaultOptionsProvider::getRawOptions(FileName); - if (ConfigOptions.InheritParentConfig.getValueOr(false)) { + if (ConfigOptions.InheritParentConfig.value_or(false)) { LLVM_DEBUG(llvm::dbgs() << "Getting options for file " << FileName << "...\n"); assert(FS && "FS must be set."); @@ -276,7 +276,7 @@ void FileOptionsBaseProvider::addRawFileOptions( CachedOptions[Path] = *Result; CurOptions.push_back(*Result); - if (!Result->first.InheritParentConfig.getValueOr(false)) + if (!Result->first.InheritParentConfig.value_or(false)) break; } } diff --git a/clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp b/clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp index d482e49e0f6d..eb787154e4e4 100644 --- a/clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp +++ b/clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp @@ -84,7 +84,7 @@ public: // - Negative globs ignored (which would effectively disable the suppression). NoLintToken(NoLintType Type, size_t Pos, const Optional &Checks) : Type(Type), Pos(Pos), ChecksGlob(std::make_unique( - Checks.getValueOr("*"), + Checks.value_or("*"), /*KeepNegativeGlobs=*/false)) { if (Checks) this->Checks = trimWhitespace(*Checks); diff --git a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp index 9a53f2bade77..cced230300db 100644 --- a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp @@ -132,7 +132,7 @@ getFailureInfoImpl(StringRef Name, bool IsInGlobalNamespace, auto InProgressFixup = [&] { return Info .map([](const FailureInfo &Info) { return StringRef(Info.Fixup); }) - .getValueOr(Name); + .value_or(Name); }; if (auto Fixup = getDoubleUnderscoreFixup(InProgressFixup(), LangOpts)) AppendFailure(DoubleUnderscoreTag, std::move(*Fixup)); diff --git a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp index 7992fa0c990a..bd283d0c175b 100644 --- a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp @@ -283,7 +283,7 @@ bool MakeSmartPtrCheck::replaceNew(DiagnosticBuilder &Diag, return false; std::string ArraySizeExpr; - if (const auto* ArraySize = New->getArraySize().getValueOr(nullptr)) { + if (const auto *ArraySize = New->getArraySize().value_or(nullptr)) { ArraySizeExpr = Lexer::getSourceText(CharSourceRange::getTokenRange( ArraySize->getSourceRange()), SM, getLangOpts()) diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp index c102b74114d2..242790f1e529 100644 --- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp @@ -279,7 +279,7 @@ IdentifierNamingCheck::FileStyle IdentifierNamingCheck::getFileStyleFromOptions( !IgnoredRegexpStr.empty() || HPTOpt) Styles[I].emplace(std::move(CaseOptional), std::move(Prefix), std::move(Postfix), IgnoredRegexpStr.str(), - HPTOpt.getValueOr(IdentifierNamingCheck::HPT_Off)); + HPTOpt.value_or(IdentifierNamingCheck::HPT_Off)); } bool IgnoreMainLike = Options.get("IgnoreMainLikeFunctions", false); return {std::move(Styles), std::move(HNOption), IgnoreMainLike}; @@ -1045,7 +1045,7 @@ std::string IdentifierNamingCheck::fixupWithStyle( Name.consume_back(Style.Suffix); std::string Fixed = fixupWithCase( Type, Name, D, Style, HNOption, - Style.Case.getValueOr(IdentifierNamingCheck::CaseType::CT_AnyCase)); + Style.Case.value_or(IdentifierNamingCheck::CaseType::CT_AnyCase)); std::string HungarianPrefix; using HungarianPrefixType = IdentifierNamingCheck::HungarianPrefixType; diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp index 49c882e6c8d4..e481b59a2286 100644 --- a/clang-tools-extra/clangd/ClangdLSPServer.cpp +++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp @@ -362,7 +362,7 @@ private: Context handlerContext() const { return Context::current().derive( kCurrentOffsetEncoding, - Server.Opts.Encoding.getValueOr(OffsetEncoding::UTF16)); + Server.Opts.Encoding.value_or(OffsetEncoding::UTF16)); } // We run cancelable requests in a context that does two things: @@ -786,7 +786,7 @@ void ClangdLSPServer::onWorkspaceSymbol( const WorkspaceSymbolParams &Params, Callback> Reply) { Server->workspaceSymbols( - Params.query, Params.limit.getValueOr(Opts.CodeComplete.Limit), + Params.query, Params.limit.value_or(Opts.CodeComplete.Limit), [Reply = std::move(Reply), this](llvm::Expected> Items) mutable { if (!Items) @@ -1110,7 +1110,7 @@ void ClangdLSPServer::onGoToDefinition(const TextDocumentPositionParams &Params, for (auto &S : *Symbols) { if (Location *Toggle = getToggle(Params, S)) return Reply(std::vector{std::move(*Toggle)}); - Defs.push_back(S.Definition.getValueOr(S.PreferredDeclaration)); + Defs.push_back(S.Definition.value_or(S.PreferredDeclaration)); } Reply(std::move(Defs)); }); diff --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp index 69a0f63972aa..eff596dd65d7 100644 --- a/clang-tools-extra/clangd/ClangdServer.cpp +++ b/clang-tools-extra/clangd/ClangdServer.cpp @@ -538,7 +538,7 @@ void ClangdServer::prepareRename(PathRef File, Position Pos, // prepareRename is latency-sensitive: we don't query the index, as we // only need main-file references auto Results = - clangd::rename({Pos, NewName.getValueOr("__clangd_rename_placeholder"), + clangd::rename({Pos, NewName.value_or("__clangd_rename_placeholder"), InpAST->AST, File, /*FS=*/nullptr, /*Index=*/nullptr, RenameOpts}); if (!Results) { @@ -815,7 +815,7 @@ void ClangdServer::workspaceSymbols( "getWorkspaceSymbols", /*Path=*/"", [Query = Query.str(), Limit, CB = std::move(CB), this]() mutable { CB(clangd::getWorkspaceSymbols(Query, Limit, Index, - WorkspaceRoot.getValueOr(""))); + WorkspaceRoot.value_or(""))); }); } diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp index 09e516919c80..276e7a3704d4 100644 --- a/clang-tools-extra/clangd/CodeComplete.cpp +++ b/clang-tools-extra/clangd/CodeComplete.cpp @@ -192,7 +192,7 @@ struct CompletionCandidate { // 0 indicates it's not part of any overload set. size_t overloadSet(const CodeCompleteOptions &Opts, llvm::StringRef FileName, IncludeInserter *Inserter) const { - if (!Opts.BundleOverloads.getValueOr(false)) + if (!Opts.BundleOverloads.value_or(false)) return 0; // Depending on the index implementation, we can see different header @@ -648,7 +648,7 @@ getQueryScopes(CodeCompletionContext &CCContext, const Sema &CCSema, } const CXXScopeSpec *SemaSpecifier = - CCContext.getCXXScopeSpecifier().getValueOr(nullptr); + CCContext.getCXXScopeSpecifier().value_or(nullptr); // Case 1: unqualified completion. if (!SemaSpecifier) { // Case 2 (exception): sema saw no qualifier, but there appears to be one! diff --git a/clang-tools-extra/clangd/IncludeFixer.cpp b/clang-tools-extra/clangd/IncludeFixer.cpp index 7fcb01e6e957..c419d20f29d2 100644 --- a/clang-tools-extra/clangd/IncludeFixer.cpp +++ b/clang-tools-extra/clangd/IncludeFixer.cpp @@ -240,7 +240,7 @@ std::vector IncludeFixer::fix(DiagnosticsEngine::Level DiagLevel, if (Info.getNumArgs() > 0) if (auto Header = getArgStr(Info, 0)) return only(insertHeader(("<" + *Header + ">").str(), - getArgStr(Info, 1).getValueOr(""))); + getArgStr(Info, 1).value_or(""))); break; } diff --git a/clang-tools-extra/clangd/JSONTransport.cpp b/clang-tools-extra/clangd/JSONTransport.cpp index e04377b1a41d..254e54ad5c23 100644 --- a/clang-tools-extra/clangd/JSONTransport.cpp +++ b/clang-tools-extra/clangd/JSONTransport.cpp @@ -53,7 +53,7 @@ llvm::json::Object encodeError(llvm::Error E) { } llvm::Error decodeError(const llvm::json::Object &O) { - llvm::StringRef Msg = O.getString("message").getValueOr("Unspecified error"); + llvm::StringRef Msg = O.getString("message").value_or("Unspecified error"); if (auto Code = O.getInteger("code")) return llvm::make_error(Msg.str(), ErrorCode(*Code)); return error(Msg.str()); diff --git a/clang-tools-extra/clangd/Quality.cpp b/clang-tools-extra/clangd/Quality.cpp index 0f7c2d3da1c6..42eee14d28f4 100644 --- a/clang-tools-extra/clangd/Quality.cpp +++ b/clang-tools-extra/clangd/Quality.cpp @@ -492,7 +492,7 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, if (S.ContextWords) OS << llvm::formatv( "\tMatching context word: {0}\n", - wordMatching(S.Name, S.ContextWords).getValueOr("")); + wordMatching(S.Name, S.ContextWords).value_or("")); OS << llvm::formatv("\tForbidden: {0}\n", S.Forbidden); OS << llvm::formatv("\tNeedsFixIts: {0}\n", S.NeedsFixIts); OS << llvm::formatv("\tIsInstanceMember: {0}\n", S.IsInstanceMember); diff --git a/clang-tools-extra/clangd/TidyProvider.cpp b/clang-tools-extra/clangd/TidyProvider.cpp index 0f0b152be474..32a4d6a30653 100644 --- a/clang-tools-extra/clangd/TidyProvider.cpp +++ b/clang-tools-extra/clangd/TidyProvider.cpp @@ -125,7 +125,7 @@ public: for (const DotClangTidyCache *Cache : Caches) if (auto Config = Cache->get(FS, FreshTime)) { OptionStack.push_back(std::move(Config)); - if (!OptionStack.back()->InheritParentConfig.getValueOr(false)) + if (!OptionStack.back()->InheritParentConfig.value_or(false)) break; } unsigned Order = 1u; diff --git a/clang-tools-extra/clangd/index/MemIndex.cpp b/clang-tools-extra/clangd/index/MemIndex.cpp index 2ca60c99d2a2..fe0ee873018b 100644 --- a/clang-tools-extra/clangd/index/MemIndex.cpp +++ b/clang-tools-extra/clangd/index/MemIndex.cpp @@ -68,8 +68,7 @@ void MemIndex::lookup(const LookupRequest &Req, bool MemIndex::refs(const RefsRequest &Req, llvm::function_ref Callback) const { trace::Span Tracer("MemIndex refs"); - uint32_t Remaining = - Req.Limit.getValueOr(std::numeric_limits::max()); + uint32_t Remaining = Req.Limit.value_or(std::numeric_limits::max()); for (const auto &ReqID : Req.IDs) { auto SymRefs = Refs.find(ReqID); if (SymRefs == Refs.end()) @@ -89,8 +88,7 @@ bool MemIndex::refs(const RefsRequest &Req, void MemIndex::relations( const RelationsRequest &Req, llvm::function_ref Callback) const { - uint32_t Remaining = - Req.Limit.getValueOr(std::numeric_limits::max()); + uint32_t Remaining = Req.Limit.value_or(std::numeric_limits::max()); for (const SymbolID &Subject : Req.Subjects) { LookupRequest LookupReq; auto It = Relations.find( diff --git a/clang-tools-extra/clangd/index/Merge.cpp b/clang-tools-extra/clangd/index/Merge.cpp index ddb7865d679c..997bbfb6672a 100644 --- a/clang-tools-extra/clangd/index/Merge.cpp +++ b/clang-tools-extra/clangd/index/Merge.cpp @@ -126,8 +126,7 @@ bool MergedIndex::refs(const RefsRequest &Req, llvm::function_ref Callback) const { trace::Span Tracer("MergedIndex refs"); bool More = false; - uint32_t Remaining = - Req.Limit.getValueOr(std::numeric_limits::max()); + uint32_t Remaining = Req.Limit.value_or(std::numeric_limits::max()); // We don't want duplicated refs from the static/dynamic indexes, // and we can't reliably deduplicate them because offsets may differ slightly. // We consider the dynamic index authoritative and report all its refs, @@ -167,8 +166,7 @@ MergedIndex::indexedFiles() const { void MergedIndex::relations( const RelationsRequest &Req, llvm::function_ref Callback) const { - uint32_t Remaining = - Req.Limit.getValueOr(std::numeric_limits::max()); + uint32_t Remaining = Req.Limit.value_or(std::numeric_limits::max()); // Return results from both indexes but avoid duplicates. // We might return stale relations from the static index; // we don't currently have a good way of identifying them. diff --git a/clang-tools-extra/clangd/index/dex/Dex.cpp b/clang-tools-extra/clangd/index/dex/Dex.cpp index 18779077b2c4..2d778c13157f 100644 --- a/clang-tools-extra/clangd/index/dex/Dex.cpp +++ b/clang-tools-extra/clangd/index/dex/Dex.cpp @@ -300,8 +300,7 @@ void Dex::lookup(const LookupRequest &Req, bool Dex::refs(const RefsRequest &Req, llvm::function_ref Callback) const { trace::Span Tracer("Dex refs"); - uint32_t Remaining = - Req.Limit.getValueOr(std::numeric_limits::max()); + uint32_t Remaining = Req.Limit.value_or(std::numeric_limits::max()); for (const auto &ID : Req.IDs) for (const auto &Ref : Refs.lookup(ID)) { if (!static_cast(Req.Filter & Ref.Kind)) @@ -318,8 +317,7 @@ void Dex::relations( const RelationsRequest &Req, llvm::function_ref Callback) const { trace::Span Tracer("Dex relations"); - uint32_t Remaining = - Req.Limit.getValueOr(std::numeric_limits::max()); + uint32_t Remaining = Req.Limit.value_or(std::numeric_limits::max()); for (const SymbolID &Subject : Req.Subjects) { LookupRequest LookupReq; auto It = Relations.find( diff --git a/clang-tools-extra/pseudo/lib/Forest.cpp b/clang-tools-extra/pseudo/lib/Forest.cpp index 073a651947ac..dce3c3a7b70a 100644 --- a/clang-tools-extra/pseudo/lib/Forest.cpp +++ b/clang-tools-extra/pseudo/lib/Forest.cpp @@ -78,7 +78,7 @@ std::string ForestNode::dumpRecursive(const Grammar &G, assert(Children[0]->startTokenIndex() == P->startTokenIndex() && EndOfElement(0) == End); return Dump(Children[0], End, - /*ElidedParent=*/ElidedParent.getValueOr(P->symbol()), + /*ElidedParent=*/ElidedParent.value_or(P->symbol()), LineDec); } }