mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-10 01:55:08 +00:00
[lldb][NFC] Make NameSearchContext::m_found members bools instead of bitfields
The size of NameSearchContext isn't important as we never store it and rarely allocate more than a few. This way we also don't have to use the memset to initialize these fields to zero.
This commit is contained in:
parent
defd0e24aa
commit
2ad7b6fba0
@ -663,7 +663,7 @@ void ClangASTSource::FindExternalVisibleDecls(
|
||||
}
|
||||
}
|
||||
|
||||
if (context.m_found.type)
|
||||
if (context.m_found_type)
|
||||
return;
|
||||
|
||||
TypeList types;
|
||||
@ -699,17 +699,17 @@ void ClangASTSource::FindExternalVisibleDecls(
|
||||
|
||||
context.AddTypeDecl(copied_clang_type);
|
||||
|
||||
context.m_found.type = true;
|
||||
context.m_found_type = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!context.m_found.type) {
|
||||
if (!context.m_found_type) {
|
||||
// Try the modules next.
|
||||
FindDeclInModules(context, name);
|
||||
}
|
||||
|
||||
if (!context.m_found.type) {
|
||||
if (!context.m_found_type) {
|
||||
FindDeclInObjCRuntime(context, name);
|
||||
}
|
||||
}
|
||||
@ -882,7 +882,7 @@ void ClangASTSource::FindDeclInModules(NameSearchContext &context,
|
||||
|
||||
context.AddNamedDecl(copied_named_decl);
|
||||
|
||||
context.m_found.type = true;
|
||||
context.m_found_type = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1000,7 +1000,7 @@ void ClangExpressionDeclMap::LookupLocalVarNamespace(
|
||||
name_context.AddNamedDecl(namespace_decl);
|
||||
clang::DeclContext *ctxt = clang::Decl::castToDeclContext(namespace_decl);
|
||||
ctxt->setHasExternalVisibleStorage(true);
|
||||
name_context.m_found.local_vars_nsp = true;
|
||||
name_context.m_found_local_vars_nsp = true;
|
||||
}
|
||||
|
||||
void ClangExpressionDeclMap::LookupInModulesDeclVendor(
|
||||
@ -1041,11 +1041,11 @@ void ClangExpressionDeclMap::LookupInModulesDeclVendor(
|
||||
|
||||
context.AddNamedDecl(copied_function);
|
||||
|
||||
context.m_found.function_with_type_info = true;
|
||||
context.m_found.function = true;
|
||||
context.m_found_function_with_type_info = true;
|
||||
context.m_found_function = true;
|
||||
} else if (auto copied_var = dyn_cast<clang::VarDecl>(copied_decl)) {
|
||||
context.AddNamedDecl(copied_var);
|
||||
context.m_found.variable = true;
|
||||
context.m_found_variable = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1087,7 +1087,7 @@ bool ClangExpressionDeclMap::LookupLocalVariable(
|
||||
variable_found = true;
|
||||
ValueObjectSP valobj = ValueObjectVariable::Create(frame, var);
|
||||
AddOneVariable(context, var, valobj);
|
||||
context.m_found.variable = true;
|
||||
context.m_found_variable = true;
|
||||
}
|
||||
}
|
||||
return variable_found;
|
||||
@ -1272,8 +1272,8 @@ void ClangExpressionDeclMap::LookupFunction(
|
||||
continue;
|
||||
|
||||
AddOneFunction(context, sym_ctx.function, nullptr);
|
||||
context.m_found.function_with_type_info = true;
|
||||
context.m_found.function = true;
|
||||
context.m_found_function_with_type_info = true;
|
||||
context.m_found_function = true;
|
||||
} else if (sym_ctx.symbol) {
|
||||
if (sym_ctx.symbol->GetType() == eSymbolTypeReExported && target) {
|
||||
sym_ctx.symbol = sym_ctx.symbol->ResolveReExportedSymbol(*target);
|
||||
@ -1288,26 +1288,26 @@ void ClangExpressionDeclMap::LookupFunction(
|
||||
}
|
||||
}
|
||||
|
||||
if (!context.m_found.function_with_type_info) {
|
||||
if (!context.m_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;
|
||||
context.m_found_function_with_type_info = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!context.m_found.function_with_type_info) {
|
||||
if (!context.m_found_function_with_type_info) {
|
||||
if (extern_symbol) {
|
||||
AddOneFunction(context, nullptr, extern_symbol);
|
||||
context.m_found.function = true;
|
||||
context.m_found_function = true;
|
||||
} else if (non_extern_symbol) {
|
||||
AddOneFunction(context, nullptr, non_extern_symbol);
|
||||
context.m_found.function = true;
|
||||
context.m_found_function = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1404,7 +1404,7 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
|
||||
if (var) {
|
||||
valobj = ValueObjectVariable::Create(target, var);
|
||||
AddOneVariable(context, var, valobj);
|
||||
context.m_found.variable = true;
|
||||
context.m_found_variable = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1412,10 +1412,10 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
|
||||
LookupFunction(context, module_sp, name, namespace_decl);
|
||||
|
||||
// Try the modules next.
|
||||
if (!context.m_found.function_with_type_info)
|
||||
if (!context.m_found_function_with_type_info)
|
||||
LookupInModulesDeclVendor(context, name);
|
||||
|
||||
if (target && !context.m_found.variable && !namespace_decl) {
|
||||
if (target && !context.m_found_variable && !namespace_decl) {
|
||||
// We couldn't find a non-symbol variable for this. Now we'll hunt for a
|
||||
// generic data symbol, and -- if it is found -- treat it as a variable.
|
||||
Status error;
|
||||
@ -1438,7 +1438,7 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
|
||||
clang::DiagnosticsEngine::Level::Warning, "%0");
|
||||
m_ast_context->getDiagnostics().Report(diag_id) << warning.c_str();
|
||||
AddOneGenericVariable(context, *data_symbol);
|
||||
context.m_found.variable = true;
|
||||
context.m_found_variable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,20 +39,18 @@ struct NameSearchContext {
|
||||
/// report conflicts.
|
||||
llvm::SmallSet<CompilerType, 5> m_function_types;
|
||||
|
||||
struct {
|
||||
bool variable : 1;
|
||||
bool function_with_type_info : 1;
|
||||
bool function : 1;
|
||||
bool local_vars_nsp : 1;
|
||||
bool type : 1;
|
||||
} m_found;
|
||||
bool m_found_variable = false;
|
||||
bool m_found_function_with_type_info = false;
|
||||
bool m_found_function = false;
|
||||
bool m_found_local_vars_nsp = false;
|
||||
bool m_found_type = false;
|
||||
|
||||
/// Constructor
|
||||
///
|
||||
/// Initializes class variables.
|
||||
///
|
||||
/// \param[in] astSource
|
||||
/// A reference to the AST source making a request.
|
||||
/// \param[in] clang_ts
|
||||
/// The TypeSystemClang from which the request originates.
|
||||
///
|
||||
/// \param[in] decls
|
||||
/// A reference to a list into which new Decls will be placed. This
|
||||
@ -68,7 +66,6 @@ struct NameSearchContext {
|
||||
clang::DeclarationName &name, const clang::DeclContext *dc)
|
||||
: m_clang_ts(clang_ts), m_decls(decls), m_decl_name(name),
|
||||
m_decl_context(dc) {
|
||||
memset(&m_found, 0, sizeof(m_found));
|
||||
}
|
||||
|
||||
/// Create a VarDecl with the name being searched for and the provided type
|
||||
|
Loading…
Reference in New Issue
Block a user