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

Commit e035466

Browse files
labathtromey
authored andcommitted
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. Reviewers: clayborg, jingham, labath Reviewed By: clayborg Subscribers: aprantl, lldb-commits, kubamracek, JDevlieghere Differential Revision: https://reviews.llvm.org/D46885 Patch by Tom Tromey <[email protected]>. git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@333639 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent e296e88 commit e035466

File tree

23 files changed

+85
-137
lines changed

23 files changed

+85
-137
lines changed

include/lldb/Core/Module.h

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -438,51 +438,38 @@ class Module : public std::enable_shared_from_this<Module>,
438438
/// @param[in] parent_decl_ctx
439439
/// If valid, a decl context that results must exist within
440440
///
441-
/// @param[in] append
442-
/// If \b true, any matches will be appended to \a
443-
/// variable_list, else matches replace the contents of
444-
/// \a variable_list.
445-
///
446441
/// @param[in] max_matches
447442
/// Allow the number of matches to be limited to \a
448443
/// max_matches. Specify UINT32_MAX to get all possible matches.
449444
///
450445
/// @param[in] variable_list
451-
/// A list of variables that gets the matches appended to (if
452-
/// \a append it \b true), or replace (if \a append is \b false).
446+
/// A list of variables that gets the matches appended to.
453447
///
454448
/// @return
455449
/// The number of matches added to \a variable_list.
456450
//------------------------------------------------------------------
457451
size_t FindGlobalVariables(const ConstString &name,
458452
const CompilerDeclContext *parent_decl_ctx,
459-
bool append, size_t max_matches,
460-
VariableList &variable_list);
453+
size_t max_matches, VariableList &variable_list);
461454

462455
//------------------------------------------------------------------
463456
/// Find global and static variables by regular expression.
464457
///
465458
/// @param[in] regex
466459
/// A regular expression to use when matching the name.
467460
///
468-
/// @param[in] append
469-
/// If \b true, any matches will be appended to \a
470-
/// variable_list, else matches replace the contents of
471-
/// \a variable_list.
472-
///
473461
/// @param[in] max_matches
474462
/// Allow the number of matches to be limited to \a
475463
/// max_matches. Specify UINT32_MAX to get all possible matches.
476464
///
477465
/// @param[in] variable_list
478-
/// A list of variables that gets the matches appended to (if
479-
/// \a append it \b true), or replace (if \a append is \b false).
466+
/// A list of variables that gets the matches appended to.
480467
///
481468
/// @return
482469
/// The number of matches added to \a variable_list.
483470
//------------------------------------------------------------------
484-
size_t FindGlobalVariables(const RegularExpression &regex, bool append,
485-
size_t max_matches, VariableList &variable_list);
471+
size_t FindGlobalVariables(const RegularExpression &regex, size_t max_matches,
472+
VariableList &variable_list);
486473

487474
//------------------------------------------------------------------
488475
/// Find types by name.

include/lldb/Core/ModuleList.h

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -315,24 +315,17 @@ class ModuleList {
315315
/// The name of the global or static variable we are looking
316316
/// for.
317317
///
318-
/// @param[in] append
319-
/// If \b true, any matches will be appended to \a
320-
/// variable_list, else matches replace the contents of
321-
/// \a variable_list.
322-
///
323318
/// @param[in] max_matches
324319
/// Allow the number of matches to be limited to \a
325320
/// max_matches. Specify UINT32_MAX to get all possible matches.
326321
///
327322
/// @param[in] variable_list
328-
/// A list of variables that gets the matches appended to (if
329-
/// \a append it \b true), or replace (if \a append is \b false).
323+
/// A list of variables that gets the matches appended to.
330324
///
331325
/// @return
332326
/// The number of matches added to \a variable_list.
333327
//------------------------------------------------------------------
334-
size_t FindGlobalVariables(const ConstString &name, bool append,
335-
size_t max_matches,
328+
size_t FindGlobalVariables(const ConstString &name, size_t max_matches,
336329
VariableList &variable_list) const;
337330

338331
//------------------------------------------------------------------
@@ -341,24 +334,17 @@ class ModuleList {
341334
/// @param[in] regex
342335
/// A regular expression to use when matching the name.
343336
///
344-
/// @param[in] append
345-
/// If \b true, any matches will be appended to \a
346-
/// variable_list, else matches replace the contents of
347-
/// \a variable_list.
348-
///
349337
/// @param[in] max_matches
350338
/// Allow the number of matches to be limited to \a
351339
/// max_matches. Specify UINT32_MAX to get all possible matches.
352340
///
353341
/// @param[in] variable_list
354-
/// A list of variables that gets the matches appended to (if
355-
/// \a append it \b true), or replace (if \a append is \b false).
342+
/// A list of variables that gets the matches appended to.
356343
///
357344
/// @return
358345
/// The number of matches added to \a variable_list.
359346
//------------------------------------------------------------------
360-
size_t FindGlobalVariables(const RegularExpression &regex, bool append,
361-
size_t max_matches,
347+
size_t FindGlobalVariables(const RegularExpression &regex, size_t max_matches,
362348
VariableList &variable_list) const;
363349

364350
//------------------------------------------------------------------

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
@@ -82,11 +82,11 @@ class SymbolVendor : public ModuleChild, public PluginInterface {
8282

8383
virtual size_t FindGlobalVariables(const ConstString &name,
8484
const CompilerDeclContext *parent_decl_ctx,
85-
bool append, size_t max_matches,
85+
size_t max_matches,
8686
VariableList &variables);
8787

8888
virtual size_t FindGlobalVariables(const RegularExpression &regex,
89-
bool append, size_t max_matches,
89+
size_t max_matches,
9090
VariableList &variables);
9191

9292
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
@@ -368,7 +368,7 @@ SBValueList SBModule::FindGlobalVariables(SBTarget &target, const char *name,
368368
if (name && module_sp) {
369369
VariableList variable_list;
370370
const uint32_t match_count = module_sp->FindGlobalVariables(
371-
ConstString(name), NULL, false, max_matches, variable_list);
371+
ConstString(name), NULL, max_matches, variable_list);
372372

373373
if (match_count > 0) {
374374
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
@@ -1782,9 +1782,8 @@ SBValueList SBTarget::FindGlobalVariables(const char *name,
17821782
TargetSP target_sp(GetSP());
17831783
if (name && target_sp) {
17841784
VariableList variable_list;
1785-
const bool append = true;
17861785
const uint32_t match_count = target_sp->GetImages().FindGlobalVariables(
1787-
ConstString(name), append, max_matches, variable_list);
1786+
ConstString(name), max_matches, variable_list);
17881787

17891788
if (match_count > 0) {
17901789
ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
@@ -1811,23 +1810,22 @@ SBValueList SBTarget::FindGlobalVariables(const char *name,
18111810
if (name && target_sp) {
18121811
llvm::StringRef name_ref(name);
18131812
VariableList variable_list;
1814-
const bool append = true;
18151813

18161814
std::string regexstr;
18171815
uint32_t match_count;
18181816
switch (matchtype) {
18191817
case eMatchTypeNormal:
18201818
match_count = target_sp->GetImages().FindGlobalVariables(
1821-
ConstString(name), append, max_matches, variable_list);
1819+
ConstString(name), max_matches, variable_list);
18221820
break;
18231821
case eMatchTypeRegex:
18241822
match_count = target_sp->GetImages().FindGlobalVariables(
1825-
RegularExpression(name_ref), append, max_matches, variable_list);
1823+
RegularExpression(name_ref), max_matches, variable_list);
18261824
break;
18271825
case eMatchTypeStartsWith:
18281826
regexstr = llvm::Regex::escape(name) + ".*";
18291827
match_count = target_sp->GetImages().FindGlobalVariables(
1830-
RegularExpression(regexstr), append, max_matches, variable_list);
1828+
RegularExpression(regexstr), max_matches, variable_list);
18311829
break;
18321830
}
18331831

source/Commands/CommandObjectTarget.cpp

Lines changed: 5 additions & 5 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;
@@ -818,8 +818,8 @@ class CommandObjectTargetVariable : public CommandObjectParsed {
818818
return false;
819819
}
820820
use_var_name = true;
821-
matches = target->GetImages().FindGlobalVariables(
822-
regex, true, UINT32_MAX, variable_list);
821+
matches = target->GetImages().FindGlobalVariables(regex, UINT32_MAX,
822+
variable_list);
823823
} else {
824824
Status error(Variable::GetValuesForVariableExpressionPath(
825825
arg, m_exe_ctx.GetBestExecutionContextScope(),
@@ -947,8 +947,8 @@ 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,
951-
UINT32_MAX, variable_list);
950+
sc.module_sp->FindGlobalVariables(all_globals_regex, UINT32_MAX,
951+
variable_list);
952952
DumpGlobalVariableList(m_exe_ctx, sc, variable_list, s);
953953
}
954954
}

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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -599,21 +599,21 @@ uint32_t Module::ResolveSymbolContextsForFileSpec(const FileSpec &file_spec,
599599

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

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

source/Core/ModuleList.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -383,27 +383,26 @@ size_t ModuleList::FindCompileUnits(const FileSpec &path, bool append,
383383
return sc_list.GetSize();
384384
}
385385

386-
size_t ModuleList::FindGlobalVariables(const ConstString &name, bool append,
386+
size_t ModuleList::FindGlobalVariables(const ConstString &name,
387387
size_t max_matches,
388388
VariableList &variable_list) const {
389389
size_t initial_size = variable_list.GetSize();
390390
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
391391
collection::const_iterator pos, end = m_modules.end();
392392
for (pos = m_modules.begin(); pos != end; ++pos) {
393-
(*pos)->FindGlobalVariables(name, nullptr, append, max_matches,
394-
variable_list);
393+
(*pos)->FindGlobalVariables(name, nullptr, max_matches, variable_list);
395394
}
396395
return variable_list.GetSize() - initial_size;
397396
}
398397

399398
size_t ModuleList::FindGlobalVariables(const RegularExpression &regex,
400-
bool append, size_t max_matches,
399+
size_t max_matches,
401400
VariableList &variable_list) const {
402401
size_t initial_size = variable_list.GetSize();
403402
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
404403
collection::const_iterator pos, end = m_modules.end();
405404
for (pos = m_modules.begin(); pos != end; ++pos) {
406-
(*pos)->FindGlobalVariables(regex, append, max_matches, variable_list);
405+
(*pos)->FindGlobalVariables(regex, max_matches, variable_list);
407406
}
408407
return variable_list.GetSize() - initial_size;
409408
}

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: 2 additions & 3 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
}
178-
const uint32_t match_count = target->GetImages().FindGlobalVariables(
179-
fullname, append, 1, variable_list);
177+
const uint32_t match_count =
178+
target->GetImages().FindGlobalVariables(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
@@ -574,7 +574,7 @@ static void GetSymbolDeclarationFromAddress(ProcessSP process_sp, addr_t addr,
574574
return;
575575

576576
VariableList var_list;
577-
module->FindGlobalVariables(sym_name, nullptr, true, 1U, var_list);
577+
module->FindGlobalVariables(sym_name, nullptr, 1U, var_list);
578578
if (var_list.GetSize() < 1)
579579
return;
580580

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

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

23352335
// Iterate over all the global variables looking for one with a matching type
23362336
// to the Element.
@@ -4076,7 +4076,7 @@ void RSModuleDescriptor::Dump(Stream &strm) const {
40764076
void RSGlobalDescriptor::Dump(Stream &strm) const {
40774077
strm.Indent(m_name.AsCString());
40784078
VariableList var_list;
4079-
m_module->m_module->FindGlobalVariables(m_name, nullptr, true, 1U, var_list);
4079+
m_module->m_module->FindGlobalVariables(m_name, nullptr, 1U, var_list);
40804080
if (var_list.GetSize() == 1) {
40814081
auto var = var_list.GetVariableAtIndex(0);
40824082
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)