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 <ttromey@mozilla.com>.

llvm-svn: 333639
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index 5a970aa..0811a79 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -720,9 +720,9 @@
   VariableList vars;
 
   if (module && namespace_decl)
-    module->FindGlobalVariables(name, namespace_decl, true, -1, vars);
+    module->FindGlobalVariables(name, namespace_decl, -1, vars);
   else
-    target.GetImages().FindGlobalVariables(name, true, -1, vars);
+    target.GetImages().FindGlobalVariables(name, -1, vars);
 
   if (vars.GetSize()) {
     if (type) {
diff --git a/lldb/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp b/lldb/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp
index 9212e18..3a10a1d 100644
--- a/lldb/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp
@@ -171,12 +171,11 @@
 VariableSP FindGlobalVariable(TargetSP target, llvm::Twine name) {
   ConstString fullname(name.str());
   VariableList variable_list;
-  const bool append = true;
   if (!target) {
     return nullptr;
   }
-  const uint32_t match_count = target->GetImages().FindGlobalVariables(
-      fullname, append, 1, variable_list);
+  const uint32_t match_count =
+      target->GetImages().FindGlobalVariables(fullname, 1, variable_list);
   if (match_count == 1) {
     return variable_list.GetVariableAtIndex(0);
   }
diff --git a/lldb/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp b/lldb/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp
index 7c4b7be..6ce50f5 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp
+++ b/lldb/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp
@@ -573,7 +573,7 @@
     return;
 
   VariableList var_list;
-  module->FindGlobalVariables(sym_name, nullptr, true, 1U, var_list);
+  module->FindGlobalVariables(sym_name, nullptr, 1U, var_list);
   if (var_list.GetSize() < 1)
     return;
 
diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
index 6cb665c..62e0883 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -2328,7 +2328,7 @@
   VariableList var_list;
   for (auto module_sp : m_rsmodules)
     module_sp->m_module->FindGlobalVariables(
-        RegularExpression(llvm::StringRef(".")), true, UINT32_MAX, var_list);
+        RegularExpression(llvm::StringRef(".")), UINT32_MAX, var_list);
 
   // Iterate over all the global variables looking for one with a matching type
   // to the Element. We make the assumption a match exists since there needs to
@@ -4065,7 +4065,7 @@
 void RSGlobalDescriptor::Dump(Stream &strm) const {
   strm.Indent(m_name.AsCString());
   VariableList var_list;
-  m_module->m_module->FindGlobalVariables(m_name, nullptr, true, 1U, var_list);
+  m_module->m_module->FindGlobalVariables(m_name, nullptr, 1U, var_list);
   if (var_list.GetSize() == 1) {
     auto var = var_list.GetVariableAtIndex(0);
     auto type = var->GetType();
diff --git a/lldb/source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp b/lldb/source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp
index 5c74939..3f60839 100644
--- a/lldb/source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp
+++ b/lldb/source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp
@@ -402,7 +402,6 @@
 
 ValueObjectSP OperatingSystemGo::FindGlobal(TargetSP target, const char *name) {
   VariableList variable_list;
-  const bool append = true;
 
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OS));
 
@@ -414,7 +413,7 @@
   }
 
   uint32_t match_count = target->GetImages().FindGlobalVariables(
-      ConstString(name), append, 1, variable_list);
+      ConstString(name), 1, variable_list);
   if (match_count > 0) {
     ExecutionContextScope *exe_scope = target->GetProcessSP().get();
     if (exe_scope == NULL)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index b8f5e60..f6abfdc 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1968,14 +1968,15 @@
 
 uint32_t SymbolFileDWARF::FindGlobalVariables(
     const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
-    bool append, uint32_t max_matches, VariableList &variables) {
+    uint32_t max_matches, VariableList &variables) {
   Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
 
   if (log)
     GetObjectFile()->GetModule()->LogMessage(
-        log, "SymbolFileDWARF::FindGlobalVariables (name=\"%s\", "
-             "parent_decl_ctx=%p, append=%u, max_matches=%u, variables)",
-        name.GetCString(), static_cast<const void *>(parent_decl_ctx), append,
+        log,
+        "SymbolFileDWARF::FindGlobalVariables (name=\"%s\", "
+        "parent_decl_ctx=%p, max_matches=%u, variables)",
+        name.GetCString(), static_cast<const void *>(parent_decl_ctx),
         max_matches);
 
   if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
@@ -1985,12 +1986,7 @@
   if (info == NULL)
     return 0;
 
-  // If we aren't appending the results to this list, then clear the list
-  if (!append)
-    variables.Clear();
-
-  // Remember how many variables are in the list before we search in case we
-  // are appending the results to a variable list.
+  // Remember how many variables are in the list before we search.
   const uint32_t original_size = variables.GetSize();
 
   DIEArray die_offsets;
@@ -2047,36 +2043,33 @@
   const uint32_t num_matches = variables.GetSize() - original_size;
   if (log && num_matches > 0) {
     GetObjectFile()->GetModule()->LogMessage(
-        log, "SymbolFileDWARF::FindGlobalVariables (name=\"%s\", "
-             "parent_decl_ctx=%p, append=%u, max_matches=%u, variables) => %u",
-        name.GetCString(), static_cast<const void *>(parent_decl_ctx), append,
+        log,
+        "SymbolFileDWARF::FindGlobalVariables (name=\"%s\", "
+        "parent_decl_ctx=%p, max_matches=%u, variables) => %u",
+        name.GetCString(), static_cast<const void *>(parent_decl_ctx),
         max_matches, num_matches);
   }
   return num_matches;
 }
 
 uint32_t SymbolFileDWARF::FindGlobalVariables(const RegularExpression &regex,
-                                              bool append, uint32_t max_matches,
+                                              uint32_t max_matches,
                                               VariableList &variables) {
   Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
 
   if (log) {
     GetObjectFile()->GetModule()->LogMessage(
-        log, "SymbolFileDWARF::FindGlobalVariables (regex=\"%s\", append=%u, "
-             "max_matches=%u, variables)",
-        regex.GetText().str().c_str(), append, max_matches);
+        log,
+        "SymbolFileDWARF::FindGlobalVariables (regex=\"%s\", "
+        "max_matches=%u, variables)",
+        regex.GetText().str().c_str(), max_matches);
   }
 
   DWARFDebugInfo *info = DebugInfo();
   if (info == NULL)
     return 0;
 
-  // If we aren't appending the results to this list, then clear the list
-  if (!append)
-    variables.Clear();
-
-  // Remember how many variables are in the list before we search in case we
-  // are appending the results to a variable list.
+  // Remember how many variables are in the list before we search.
   const uint32_t original_size = variables.GetSize();
 
   DIEArray die_offsets;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index 3eb87fc..1eabe98 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -179,11 +179,11 @@
   uint32_t
   FindGlobalVariables(const lldb_private::ConstString &name,
                       const lldb_private::CompilerDeclContext *parent_decl_ctx,
-                      bool append, uint32_t max_matches,
+                      uint32_t max_matches,
                       lldb_private::VariableList &variables) override;
 
   uint32_t FindGlobalVariables(const lldb_private::RegularExpression &regex,
-                               bool append, uint32_t max_matches,
+                               uint32_t max_matches,
                                lldb_private::VariableList &variables) override;
 
   uint32_t
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index 0d7fd32..e2811e8 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -801,8 +801,8 @@
     if (comp_unit_info) {
       SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx);
       if (oso_dwarf) {
-        if (oso_dwarf->FindGlobalVariables(name, parent_decl_ctx, true,
-                                           max_matches, variables))
+        if (oso_dwarf->FindGlobalVariables(name, parent_decl_ctx, max_matches,
+                                           variables))
           if (variables.GetSize() > max_matches)
             break;
       }
@@ -813,21 +813,16 @@
 
 uint32_t SymbolFileDWARFDebugMap::FindGlobalVariables(
     const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
-    bool append, uint32_t max_matches, VariableList &variables) {
+    uint32_t max_matches, VariableList &variables) {
 
-  // If we aren't appending the results to this list, then clear the list
-  if (!append)
-    variables.Clear();
-
-  // Remember how many variables are in the list before we search in case we
-  // are appending the results to a variable list.
+  // Remember how many variables are in the list before we search.
   const uint32_t original_size = variables.GetSize();
 
   uint32_t total_matches = 0;
 
   ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
     const uint32_t oso_matches = oso_dwarf->FindGlobalVariables(
-        name, parent_decl_ctx, true, max_matches, variables);
+        name, parent_decl_ctx, max_matches, variables);
     if (oso_matches > 0) {
       total_matches += oso_matches;
 
@@ -853,20 +848,15 @@
 
 uint32_t
 SymbolFileDWARFDebugMap::FindGlobalVariables(const RegularExpression &regex,
-                                             bool append, uint32_t max_matches,
+                                             uint32_t max_matches,
                                              VariableList &variables) {
-  // If we aren't appending the results to this list, then clear the list
-  if (!append)
-    variables.Clear();
-
-  // Remember how many variables are in the list before we search in case we
-  // are appending the results to a variable list.
+  // Remember how many variables are in the list before we search.
   const uint32_t original_size = variables.GetSize();
 
   uint32_t total_matches = 0;
   ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
     const uint32_t oso_matches =
-        oso_dwarf->FindGlobalVariables(regex, true, max_matches, variables);
+        oso_dwarf->FindGlobalVariables(regex, max_matches, variables);
     if (oso_matches > 0) {
       total_matches += oso_matches;
 
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
index 04599eb..5042d87 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -95,10 +95,10 @@
   uint32_t
   FindGlobalVariables(const lldb_private::ConstString &name,
                       const lldb_private::CompilerDeclContext *parent_decl_ctx,
-                      bool append, uint32_t max_matches,
+                      uint32_t max_matches,
                       lldb_private::VariableList &variables) override;
   uint32_t FindGlobalVariables(const lldb_private::RegularExpression &regex,
-                               bool append, uint32_t max_matches,
+                               uint32_t max_matches,
                                lldb_private::VariableList &variables) override;
   uint32_t
   FindFunctions(const lldb_private::ConstString &name,
diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
index e490433..f298749 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -949,10 +949,8 @@
 
 uint32_t SymbolFilePDB::FindGlobalVariables(
     const lldb_private::ConstString &name,
-    const lldb_private::CompilerDeclContext *parent_decl_ctx, bool append,
+    const lldb_private::CompilerDeclContext *parent_decl_ctx,
     uint32_t max_matches, lldb_private::VariableList &variables) {
-  if (!append)
-    variables.Clear();
   if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
     return 0;
   if (name.IsEmpty())
@@ -989,7 +987,7 @@
 
 uint32_t
 SymbolFilePDB::FindGlobalVariables(const lldb_private::RegularExpression &regex,
-                                   bool append, uint32_t max_matches,
+                                   uint32_t max_matches,
                                    lldb_private::VariableList &variables) {
   if (!regex.IsValid())
     return 0;
diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
index 177eef9..96b62d6 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
+++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
@@ -111,11 +111,11 @@
   uint32_t
   FindGlobalVariables(const lldb_private::ConstString &name,
                       const lldb_private::CompilerDeclContext *parent_decl_ctx,
-                      bool append, uint32_t max_matches,
+                      uint32_t max_matches,
                       lldb_private::VariableList &variables) override;
 
   uint32_t FindGlobalVariables(const lldb_private::RegularExpression &regex,
-                               bool append, uint32_t max_matches,
+                               uint32_t max_matches,
                                lldb_private::VariableList &variables) override;
 
   uint32_t