Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit e17078f

Browse files
committed
Remove append parameter to FindGlobalVariables
Summary: As discussed in https://bugs.llvm.org/show_bug.cgi?id=37317, FindGlobalVariables does not properly handle the case where append=false. As this doesn't seem to be used in the tree, this patch removes the parameter entirely. Subscribers: kubamracek, JDevlieghere Differential Revision: https://reviews.llvm.org/D46885
1 parent b8f6754 commit e17078f

File tree

24 files changed

+70
-123
lines changed

24 files changed

+70
-123
lines changed

include/lldb/Core/Module.h

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -431,25 +431,19 @@ class Module : public std::enable_shared_from_this<Module>,
431431
/// @param[in] parent_decl_ctx
432432
/// If valid, a decl context that results must exist within
433433
///
434-
/// @param[in] append
435-
/// If \b true, any matches will be appended to \a
436-
/// variable_list, else matches replace the contents of
437-
/// \a variable_list.
438-
///
439434
/// @param[in] max_matches
440435
/// Allow the number of matches to be limited to \a
441436
/// max_matches. Specify UINT32_MAX to get all possible matches.
442437
///
443438
/// @param[in] variable_list
444-
/// A list of variables that gets the matches appended to (if
445-
/// \a append it \b true), or replace (if \a append is \b false).
439+
/// A list of variables that gets the matches appended to.
446440
///
447441
/// @return
448442
/// The number of matches added to \a variable_list.
449443
//------------------------------------------------------------------
450444
size_t FindGlobalVariables(const ConstString &name,
451445
const CompilerDeclContext *parent_decl_ctx,
452-
bool append, size_t max_matches,
446+
size_t max_matches,
453447
VariableList &variable_list);
454448

455449
//------------------------------------------------------------------
@@ -458,23 +452,17 @@ class Module : public std::enable_shared_from_this<Module>,
458452
/// @param[in] regex
459453
/// A regular expression to use when matching the name.
460454
///
461-
/// @param[in] append
462-
/// If \b true, any matches will be appended to \a
463-
/// variable_list, else matches replace the contents of
464-
/// \a variable_list.
465-
///
466455
/// @param[in] max_matches
467456
/// Allow the number of matches to be limited to \a
468457
/// max_matches. Specify UINT32_MAX to get all possible matches.
469458
///
470459
/// @param[in] variable_list
471-
/// A list of variables that gets the matches appended to (if
472-
/// \a append it \b true), or replace (if \a append is \b false).
460+
/// A list of variables that gets the matches appended to.
473461
///
474462
/// @return
475463
/// The number of matches added to \a variable_list.
476464
//------------------------------------------------------------------
477-
size_t FindGlobalVariables(const RegularExpression &regex, bool append,
465+
size_t FindGlobalVariables(const RegularExpression &regex,
478466
size_t max_matches, VariableList &variable_list);
479467

480468
//------------------------------------------------------------------

include/lldb/Core/ModuleList.h

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -324,23 +324,17 @@ class ModuleList {
324324
/// The name of the global or static variable we are looking
325325
/// for.
326326
///
327-
/// @param[in] append
328-
/// If \b true, any matches will be appended to \a
329-
/// variable_list, else matches replace the contents of
330-
/// \a variable_list.
331-
///
332327
/// @param[in] max_matches
333328
/// Allow the number of matches to be limited to \a
334329
/// max_matches. Specify UINT32_MAX to get all possible matches.
335330
///
336331
/// @param[in] variable_list
337-
/// A list of variables that gets the matches appended to (if
338-
/// \a append it \b true), or replace (if \a append is \b false).
332+
/// A list of variables that gets the matches appended to.
339333
///
340334
/// @return
341335
/// The number of matches added to \a variable_list.
342336
//------------------------------------------------------------------
343-
size_t FindGlobalVariables(const ConstString &name, bool append,
337+
size_t FindGlobalVariables(const ConstString &name,
344338
size_t max_matches,
345339
VariableList &variable_list) const;
346340

@@ -350,23 +344,17 @@ class ModuleList {
350344
/// @param[in] regex
351345
/// A regular expression to use when matching the name.
352346
///
353-
/// @param[in] append
354-
/// If \b true, any matches will be appended to \a
355-
/// variable_list, else matches replace the contents of
356-
/// \a variable_list.
357-
///
358347
/// @param[in] max_matches
359348
/// Allow the number of matches to be limited to \a
360349
/// max_matches. Specify UINT32_MAX to get all possible matches.
361350
///
362351
/// @param[in] variable_list
363-
/// A list of variables that gets the matches appended to (if
364-
/// \a append it \b true), or replace (if \a append is \b false).
352+
/// A list of variables that gets the matches appended to.
365353
///
366354
/// @return
367355
/// The number of matches added to \a variable_list.
368356
//------------------------------------------------------------------
369-
size_t FindGlobalVariables(const RegularExpression &regex, bool append,
357+
size_t FindGlobalVariables(const RegularExpression &regex,
370358
size_t max_matches,
371359
VariableList &variable_list) const;
372360

include/lldb/Symbol/SymbolFile.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ class SymbolFile : public PluginInterface {
148148
SymbolContextList &sc_list);
149149
virtual uint32_t
150150
FindGlobalVariables(const ConstString &name,
151-
const CompilerDeclContext *parent_decl_ctx, bool append,
151+
const CompilerDeclContext *parent_decl_ctx,
152152
uint32_t max_matches, VariableList &variables);
153153
virtual uint32_t FindGlobalVariables(const RegularExpression &regex,
154-
bool append, uint32_t max_matches,
154+
uint32_t max_matches,
155155
VariableList &variables);
156156
virtual uint32_t FindFunctions(const ConstString &name,
157157
const CompilerDeclContext *parent_decl_ctx,

include/lldb/Symbol/SymbolVendor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ class SymbolVendor : public ModuleChild, public PluginInterface {
8181

8282
virtual size_t FindGlobalVariables(const ConstString &name,
8383
const CompilerDeclContext *parent_decl_ctx,
84-
bool append, size_t max_matches,
84+
size_t max_matches,
8585
VariableList &variables);
8686

8787
virtual size_t FindGlobalVariables(const RegularExpression &regex,
88-
bool append, size_t max_matches,
88+
size_t max_matches,
8989
VariableList &variables);
9090

9191
virtual size_t FindFunctions(const ConstString &name,

source/API/SBModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ SBValueList SBModule::FindGlobalVariables(SBTarget &target, const char *name,
367367
if (name && module_sp) {
368368
VariableList variable_list;
369369
const uint32_t match_count = module_sp->FindGlobalVariables(
370-
ConstString(name), NULL, false, max_matches, variable_list);
370+
ConstString(name), NULL, max_matches, variable_list);
371371

372372
if (match_count > 0) {
373373
for (uint32_t i = 0; i < match_count; ++i) {

source/API/SBTarget.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,9 +1804,8 @@ SBValueList SBTarget::FindGlobalVariables(const char *name,
18041804
TargetSP target_sp(GetSP());
18051805
if (name && target_sp) {
18061806
VariableList variable_list;
1807-
const bool append = true;
18081807
const uint32_t match_count = target_sp->GetImages().FindGlobalVariables(
1809-
ConstString(name), append, max_matches, variable_list);
1808+
ConstString(name), max_matches, variable_list);
18101809

18111810
if (match_count > 0) {
18121811
ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
@@ -1833,23 +1832,22 @@ SBValueList SBTarget::FindGlobalVariables(const char *name,
18331832
if (name && target_sp) {
18341833
llvm::StringRef name_ref(name);
18351834
VariableList variable_list;
1836-
const bool append = true;
18371835

18381836
std::string regexstr;
18391837
uint32_t match_count;
18401838
switch (matchtype) {
18411839
case eMatchTypeNormal:
18421840
match_count = target_sp->GetImages().FindGlobalVariables(
1843-
ConstString(name), append, max_matches, variable_list);
1841+
ConstString(name), max_matches, variable_list);
18441842
break;
18451843
case eMatchTypeRegex:
18461844
match_count = target_sp->GetImages().FindGlobalVariables(
1847-
RegularExpression(name_ref), append, max_matches, variable_list);
1845+
RegularExpression(name_ref), max_matches, variable_list);
18481846
break;
18491847
case eMatchTypeStartsWith:
18501848
regexstr = llvm::Regex::escape(name) + ".*";
18511849
match_count = target_sp->GetImages().FindGlobalVariables(
1852-
RegularExpression(regexstr), append, max_matches, variable_list);
1850+
RegularExpression(regexstr), max_matches, variable_list);
18531851
break;
18541852
}
18551853

source/Commands/CommandObjectTarget.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ class CommandObjectTargetVariable : public CommandObjectParsed {
752752
VariableList &variable_list) {
753753
Target *target = static_cast<Target *>(baton);
754754
if (target) {
755-
return target->GetImages().FindGlobalVariables(ConstString(name), true,
755+
return target->GetImages().FindGlobalVariables(ConstString(name),
756756
UINT32_MAX, variable_list);
757757
}
758758
return 0;
@@ -819,7 +819,7 @@ class CommandObjectTargetVariable : public CommandObjectParsed {
819819
}
820820
use_var_name = true;
821821
matches = target->GetImages().FindGlobalVariables(
822-
regex, true, UINT32_MAX, variable_list);
822+
regex, UINT32_MAX, variable_list);
823823
} else {
824824
Status error(Variable::GetValuesForVariableExpressionPath(
825825
arg, m_exe_ctx.GetBestExecutionContextScope(),
@@ -947,7 +947,7 @@ class CommandObjectTargetVariable : public CommandObjectParsed {
947947
llvm::StringRef(
948948
".")); // Any global with at least one character
949949
VariableList variable_list;
950-
sc.module_sp->FindGlobalVariables(all_globals_regex, append,
950+
sc.module_sp->FindGlobalVariables(all_globals_regex,
951951
UINT32_MAX, variable_list);
952952
DumpGlobalVariableList(m_exe_ctx, sc, variable_list, s);
953953
}

source/Commands/CommandObjectWatchpoint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ corresponding to the byte size of the data type.");
838838
VariableList &variable_list) {
839839
Target *target = static_cast<Target *>(baton);
840840
if (target) {
841-
return target->GetImages().FindGlobalVariables(ConstString(name), true,
841+
return target->GetImages().FindGlobalVariables(ConstString(name),
842842
UINT32_MAX, variable_list);
843843
}
844844
return 0;

source/Core/Module.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -600,21 +600,21 @@ uint32_t Module::ResolveSymbolContextsForFileSpec(const FileSpec &file_spec,
600600

601601
size_t Module::FindGlobalVariables(const ConstString &name,
602602
const CompilerDeclContext *parent_decl_ctx,
603-
bool append, size_t max_matches,
603+
size_t max_matches,
604604
VariableList &variables) {
605605
SymbolVendor *symbols = GetSymbolVendor();
606606
if (symbols)
607-
return symbols->FindGlobalVariables(name, parent_decl_ctx, append,
607+
return symbols->FindGlobalVariables(name, parent_decl_ctx,
608608
max_matches, variables);
609609
return 0;
610610
}
611611

612-
size_t Module::FindGlobalVariables(const RegularExpression &regex, bool append,
612+
size_t Module::FindGlobalVariables(const RegularExpression &regex,
613613
size_t max_matches,
614614
VariableList &variables) {
615615
SymbolVendor *symbols = GetSymbolVendor();
616616
if (symbols)
617-
return symbols->FindGlobalVariables(regex, append, max_matches, variables);
617+
return symbols->FindGlobalVariables(regex, max_matches, variables);
618618
return 0;
619619
}
620620

source/Core/ModuleList.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,27 +432,27 @@ size_t ModuleList::FindCompileUnits(const FileSpec &path, bool append,
432432
return sc_list.GetSize();
433433
}
434434

435-
size_t ModuleList::FindGlobalVariables(const ConstString &name, bool append,
435+
size_t ModuleList::FindGlobalVariables(const ConstString &name,
436436
size_t max_matches,
437437
VariableList &variable_list) const {
438438
size_t initial_size = variable_list.GetSize();
439439
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
440440
collection::const_iterator pos, end = m_modules.end();
441441
for (pos = m_modules.begin(); pos != end; ++pos) {
442-
(*pos)->FindGlobalVariables(name, nullptr, append, max_matches,
442+
(*pos)->FindGlobalVariables(name, nullptr, max_matches,
443443
variable_list);
444444
}
445445
return variable_list.GetSize() - initial_size;
446446
}
447447

448448
size_t ModuleList::FindGlobalVariables(const RegularExpression &regex,
449-
bool append, size_t max_matches,
449+
size_t max_matches,
450450
VariableList &variable_list) const {
451451
size_t initial_size = variable_list.GetSize();
452452
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
453453
collection::const_iterator pos, end = m_modules.end();
454454
for (pos = m_modules.begin(); pos != end; ++pos) {
455-
(*pos)->FindGlobalVariables(regex, append, max_matches, variable_list);
455+
(*pos)->FindGlobalVariables(regex, max_matches, variable_list);
456456
}
457457
return variable_list.GetSize() - initial_size;
458458
}

source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,9 @@ lldb::VariableSP ClangExpressionDeclMap::FindGlobalVariable(
720720
VariableList vars;
721721

722722
if (module && namespace_decl)
723-
module->FindGlobalVariables(name, namespace_decl, true, -1, vars);
723+
module->FindGlobalVariables(name, namespace_decl, -1, vars);
724724
else
725-
target.GetImages().FindGlobalVariables(name, true, -1, vars);
725+
target.GetImages().FindGlobalVariables(name, -1, vars);
726726

727727
if (vars.GetSize()) {
728728
if (type) {

source/Plugins/ExpressionParser/Go/GoUserExpression.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,11 @@ class GoUserExpression::GoInterpreter {
171171
VariableSP FindGlobalVariable(TargetSP target, llvm::Twine name) {
172172
ConstString fullname(name.str());
173173
VariableList variable_list;
174-
const bool append = true;
175174
if (!target) {
176175
return nullptr;
177176
}
178177
const uint32_t match_count = target->GetImages().FindGlobalVariables(
179-
fullname, append, 1, variable_list);
178+
fullname, 1, variable_list);
180179
if (match_count == 1) {
181180
return variable_list.GetVariableAtIndex(0);
182181
}

source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ static void GetSymbolDeclarationFromAddress(ProcessSP process_sp, addr_t addr,
573573
return;
574574

575575
VariableList var_list;
576-
module->FindGlobalVariables(sym_name, nullptr, true, 1U, var_list);
576+
module->FindGlobalVariables(sym_name, nullptr, 1U, var_list);
577577
if (var_list.GetSize() < 1)
578578
return;
579579

source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2328,7 +2328,7 @@ void RenderScriptRuntime::FindStructTypeName(Element &elem,
23282328
VariableList var_list;
23292329
for (auto module_sp : m_rsmodules)
23302330
module_sp->m_module->FindGlobalVariables(
2331-
RegularExpression(llvm::StringRef(".")), true, UINT32_MAX, var_list);
2331+
RegularExpression(llvm::StringRef(".")), UINT32_MAX, var_list);
23322332

23332333
// Iterate over all the global variables looking for one with a matching type
23342334
// to the Element. We make the assumption a match exists since there needs to
@@ -4065,7 +4065,7 @@ void RSModuleDescriptor::Dump(Stream &strm) const {
40654065
void RSGlobalDescriptor::Dump(Stream &strm) const {
40664066
strm.Indent(m_name.AsCString());
40674067
VariableList var_list;
4068-
m_module->m_module->FindGlobalVariables(m_name, nullptr, true, 1U, var_list);
4068+
m_module->m_module->FindGlobalVariables(m_name, nullptr, 1U, var_list);
40694069
if (var_list.GetSize() == 1) {
40704070
auto var = var_list.GetVariableAtIndex(0);
40714071
auto type = var->GetType();

source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,6 @@ lldb::ThreadSP OperatingSystemGo::CreateThread(lldb::tid_t tid,
402402

403403
ValueObjectSP OperatingSystemGo::FindGlobal(TargetSP target, const char *name) {
404404
VariableList variable_list;
405-
const bool append = true;
406405

407406
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OS));
408407

@@ -414,7 +413,7 @@ ValueObjectSP OperatingSystemGo::FindGlobal(TargetSP target, const char *name) {
414413
}
415414

416415
uint32_t match_count = target->GetImages().FindGlobalVariables(
417-
ConstString(name), append, 1, variable_list);
416+
ConstString(name), 1, variable_list);
418417
if (match_count > 0) {
419418
ExecutionContextScope *exe_scope = target->GetProcessSP().get();
420419
if (exe_scope == NULL)

0 commit comments

Comments
 (0)