Skip to content

[lldb][Expression] Remove m_found_function_with_type_info in favour of boolean return #141774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1047,8 +1047,6 @@ void ClangExpressionDeclMap::LookupInModulesDeclVendor(
MaybeRegisterFunctionBody(copied_function);

context.AddNamedDecl(copied_function);

context.m_found_function_with_type_info = true;
} else if (auto copied_var = dyn_cast<clang::VarDecl>(copied_decl)) {
context.AddNamedDecl(copied_var);
context.m_found_variable = true;
Expand Down Expand Up @@ -1217,11 +1215,11 @@ SymbolContextList ClangExpressionDeclMap::SearchFunctionsInSymbolContexts(
return sc_func_list;
}

void ClangExpressionDeclMap::LookupFunction(
bool ClangExpressionDeclMap::LookupFunction(
NameSearchContext &context, lldb::ModuleSP module_sp, ConstString name,
const CompilerDeclContext &namespace_decl) {
if (!m_parser_vars)
return;
return false;

Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();

Expand Down Expand Up @@ -1281,6 +1279,8 @@ void ClangExpressionDeclMap::LookupFunction(
}
}

bool found_function_with_type_info = false;

if (sc_list.GetSize()) {
Symbol *extern_symbol = nullptr;
Symbol *non_extern_symbol = nullptr;
Expand All @@ -1297,7 +1297,7 @@ void ClangExpressionDeclMap::LookupFunction(
continue;

AddOneFunction(context, sym_ctx.function, nullptr);
context.m_found_function_with_type_info = true;
found_function_with_type_info = true;
} else if (sym_ctx.symbol) {
Symbol *symbol = sym_ctx.symbol;
if (target && symbol->GetType() == eSymbolTypeReExported) {
Expand All @@ -1313,27 +1313,29 @@ void ClangExpressionDeclMap::LookupFunction(
}
}

if (!context.m_found_function_with_type_info) {
if (!found_function_with_type_info) {
for (clang::NamedDecl *decl : decls_from_modules) {
if (llvm::isa<clang::FunctionDecl>(decl)) {
clang::NamedDecl *copied_decl =
llvm::cast_or_null<FunctionDecl>(CopyDecl(decl));
if (copied_decl) {
context.AddNamedDecl(copied_decl);
context.m_found_function_with_type_info = true;
found_function_with_type_info = true;
}
}
}
}

if (!context.m_found_function_with_type_info) {
if (!found_function_with_type_info) {
if (extern_symbol) {
AddOneFunction(context, nullptr, extern_symbol);
} else if (non_extern_symbol) {
AddOneFunction(context, nullptr, non_extern_symbol);
}
}
}

return found_function_with_type_info;
}

void ClangExpressionDeclMap::FindExternalVisibleDecls(
Expand Down Expand Up @@ -1432,10 +1434,7 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
}
}

LookupFunction(context, module_sp, name, namespace_decl);

// Try the modules next.
if (!context.m_found_function_with_type_info)
if (!LookupFunction(context, module_sp, name, namespace_decl))
LookupInModulesDeclVendor(context, name);

if (target && !context.m_found_variable && !namespace_decl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,10 @@ class ClangExpressionDeclMap : public ClangASTSource {
///
/// \param[in] namespace_decl
/// If valid and module is non-NULL, the parent namespace.
void LookupFunction(NameSearchContext &context, lldb::ModuleSP module_sp,
///
/// \returns Returns \c true if we successfully found a function
/// and could create a decl with correct type-info for it.
bool LookupFunction(NameSearchContext &context, lldb::ModuleSP module_sp,
ConstString name,
const CompilerDeclContext &namespace_decl);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ struct NameSearchContext {
llvm::SmallSet<CompilerType, 5> m_function_types;

bool m_found_variable = false;
bool m_found_function_with_type_info = false;
bool m_found_local_vars_nsp = false;
bool m_found_type = false;

Expand Down
Loading