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