Added an API to SymbolContext to hide the complexity of getting the
function name from a symbol context.  Use that in CommandCompletions
to get the right name.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@140628 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandCompletions.cpp b/source/Commands/CommandCompletions.cpp
index 3ea62aa..4fb2d97 100644
--- a/source/Commands/CommandCompletions.cpp
+++ b/source/Commands/CommandCompletions.cpp
@@ -627,14 +627,9 @@
         {
             if (sc_list.GetContextAtIndex(i, sc))
             {
-                if (sc.function)
-                {
-                    m_match_set.insert (sc.function->GetMangled().GetDemangledName());
-                }
-                else if (sc.symbol && sc.symbol->GetAddressRangePtr())
-                {
-                    m_match_set.insert (sc.symbol->GetMangled().GetName());
-                }
+                ConstString func_name = sc.GetFunctionName(Mangled::ePreferDemangled);
+                if (!func_name.IsEmpty())
+                    m_match_set.insert (func_name);
             }
         }
     }
diff --git a/source/Symbol/SymbolContext.cpp b/source/Symbol/SymbolContext.cpp
index c7b2fb2..80ffd34 100644
--- a/source/Symbol/SymbolContext.cpp
+++ b/source/Symbol/SymbolContext.cpp
@@ -575,6 +575,29 @@
     return false;
 }
 
+ConstString 
+SymbolContext::GetFunctionName (Mangled::NamePreference preference)
+{
+    if (function)
+    {
+        if (block)
+        {
+            const InlineFunctionInfo *inline_info = block->GetInlinedFunctionInfo();
+            if (inline_info)
+                return inline_info->GetName(); 
+        }
+        return function->GetMangled().GetName(preference);
+    }
+    else if (symbol && symbol->GetAddressRangePtr())
+    {
+        return symbol->GetMangled().GetName(preference);
+    }
+    else
+    {
+        // No function, return an empty string.
+        return ConstString();
+    }
+}
 
 //----------------------------------------------------------------------
 //