Made the expression parser more resilient against
being asked about symbols it doesn't know about.  If
it's asked about a symbol by mangled name and it finds
nothing, then it will try again with the demangled
base name.

llvm-svn: 221660
diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp
index 13f19a1..5b7065d 100644
--- a/lldb/source/Expression/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp
@@ -36,6 +36,7 @@
 #include "lldb/Symbol/TypeList.h"
 #include "lldb/Symbol/Variable.h"
 #include "lldb/Symbol/VariableList.h"
+#include "lldb/Target/CPPLanguageRuntime.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/ObjCLanguageRuntime.h"
 #include "lldb/Target/Process.h"
@@ -543,6 +544,7 @@
     FindCodeSymbolInContext(name, m_parser_vars->m_sym_ctx, sc_list);
 
     uint32_t sc_list_size = sc_list.GetSize();
+    
     if (sc_list_size == 0)
     {
         // We occasionally get debug information in which a const function is reported
@@ -562,6 +564,25 @@
             sc_list_size = sc_list.GetSize();
         }
     }
+    
+    if (sc_list_size == 0)
+    {
+        // Sometimes we get a mangled name for a global function that actually should be "extern C."
+        // This is a hack to compensate.
+        
+        const bool is_mangled = true;
+        Mangled mangled(name, is_mangled);
+                
+        CPPLanguageRuntime::MethodName method_name(mangled.GetDemangledName());
+        
+        llvm::StringRef basename = method_name.GetBasename();
+        
+        if (!basename.empty())
+        {
+            FindCodeSymbolInContext(ConstString(basename), m_parser_vars->m_sym_ctx, sc_list);
+            sc_list_size = sc_list.GetSize();
+        }
+    }
 
     for (uint32_t i=0; i<sc_list_size; ++i)
     {