Changed SymbolContext so when you search for functions
it returns a list of functions as a SymbolContextList.
Rewrote the clients of SymbolContext to use this
SymbolContextList.
Rewrote some of the providers of the data to SymbolContext
to make them respect preferences as to whether the list
should be cleared first; propagated that change out.
ClangExpressionDeclMap and ClangASTSource use this new
function list to properly generate function definitions -
even for functions that don't have a prototype in the
debug information.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@109476 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Symbol/SymbolContext.cpp b/source/Symbol/SymbolContext.cpp
index 7963a1f..a045d18 100644
--- a/source/Symbol/SymbolContext.cpp
+++ b/source/Symbol/SymbolContext.cpp
@@ -354,17 +354,18 @@
}
-Function *
-SymbolContext::FindFunctionByName (const char *name) const
-{
- ConstString name_const_str (name);
+size_t
+SymbolContext::FindFunctionsByName (const ConstString &name, bool append, SymbolContextList &sc_list) const
+{
+ if (!append)
+ sc_list.Clear();
+
if (function != NULL)
{
// FIXME: Look in the class of the current function, if it exists,
// for methods matching name.
}
- //
if (comp_unit != NULL)
{
// Make sure we've read in all the functions. We should be able to check and see
@@ -374,33 +375,24 @@
lldb::FunctionSP func_sp;
for (func_idx = 0; (func_sp = comp_unit->GetFunctionAtIndex(func_idx)) != NULL; ++func_idx)
{
- if (func_sp->GetMangled().GetName() == name_const_str)
- return func_sp.get();
+ if (func_sp->GetMangled().GetName() == name)
+ {
+ SymbolContext sym_ctx(target_sp,
+ module_sp,
+ comp_unit,
+ func_sp.get());
+ sc_list.Append(sym_ctx);
+ }
}
}
+
if (module_sp != NULL)
- {
- SymbolContextList sc_matches;
- if (module_sp->FindFunctions (name_const_str, eFunctionNameTypeBase | eFunctionNameTypeFull, false, sc_matches) > 0)
- {
- SymbolContext sc;
- sc_matches.GetContextAtIndex (0, sc);
- return sc.function;
- }
- }
+ module_sp->FindFunctions (name, eFunctionNameTypeBase | eFunctionNameTypeFull, true, sc_list);
if (target_sp)
- {
- SymbolContextList sc_matches;
- if (target_sp->GetImages().FindFunctions (name_const_str, eFunctionNameTypeBase | eFunctionNameTypeFull, sc_matches) > 0)
- {
- SymbolContext sc;
- sc_matches.GetContextAtIndex (0, sc);
- return sc.function;
- }
- }
+ target_sp->GetImages().FindFunctions (name, eFunctionNameTypeBase | eFunctionNameTypeFull, true, sc_list);
- return NULL;
+ return sc_list.GetSize();
}
lldb::VariableSP