Fixed a performance problem where functions were
being searched for in too heavyweight a way.  Now,
when asking for the address of a function, the
expression parser just asks for a corresponding
data symbol.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@137731 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ClangExpressionDeclMap.cpp b/source/Expression/ClangExpressionDeclMap.cpp
index 71b0b9f..08e7724 100644
--- a/source/Expression/ClangExpressionDeclMap.cpp
+++ b/source/Expression/ClangExpressionDeclMap.cpp
@@ -497,6 +497,21 @@
     return true;
 }
 
+static void
+FindCodeSymbolInContext
+(
+    const ConstString &name,
+    SymbolContext &sym_ctx,
+    SymbolContextList &sc_list
+)
+{
+    if (sym_ctx.module_sp)
+       sym_ctx.module_sp->FindSymbolsWithNameAndType(name, eSymbolTypeCode, sc_list);
+    
+    if (!sc_list.GetSize())
+        sym_ctx.target_sp->GetImages().FindSymbolsWithNameAndType(name, eSymbolTypeCode, sc_list);
+}
+
 bool
 ClangExpressionDeclMap::GetFunctionAddress 
 (
@@ -515,10 +530,9 @@
         return false;
 
     SymbolContextList sc_list;
-    const bool include_symbols = true;
-    const bool append = false;
-    m_parser_vars->m_sym_ctx.FindFunctionsByName(name, include_symbols, append, sc_list);
     
+    FindCodeSymbolInContext(name, m_parser_vars->m_sym_ctx, sc_list);
+        
     if (!sc_list.GetSize())
     {
         // We occasionally get debug information in which a const function is reported 
@@ -536,7 +550,7 @@
             
             ConstString const_name(const_name_scratch.c_str());
                         
-            m_parser_vars->m_sym_ctx.FindFunctionsByName(const_name, include_symbols, append, sc_list);
+            FindCodeSymbolInContext(name, m_parser_vars->m_sym_ctx, sc_list);
             
             if (log)
                 log->Printf("Found %d results with const name %s", sc_list.GetSize(), const_name.GetCString());