<rdar://problem/10998370>

Improved the error message when we can find a function in the current program by printing the demangled name.

Also added the ability to create lldb_private::Mangled instances with a ConstString when we already have a ConstString for a mangled or demangled name. Also added the ability to call SetValue with a ConstString and also without a boolean to indicate if the string is mangled where we will now auto-detect if the string is mangled.




git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@160450 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/IRForTarget.cpp b/source/Expression/IRForTarget.cpp
index 534445d..e5a93fc 100644
--- a/source/Expression/IRForTarget.cpp
+++ b/source/Expression/IRForTarget.cpp
@@ -229,7 +229,7 @@
     {
         if (!m_decl_map->GetFunctionInfo (fun_decl, fun_addr)) 
         {
-            lldb_private::ConstString alternate_mangling_const_str;
+            lldb_private::ConstString altnernate_name;
             bool found_it = m_decl_map->GetFunctionAddress (name, fun_addr);
             if (!found_it)
             {
@@ -240,27 +240,35 @@
                 {
                     std::string alternate_mangling("_ZNKSs");
                     alternate_mangling.append (name_cstr + strlen("_ZNKSbIcE"));
-                    alternate_mangling_const_str.SetCString(alternate_mangling.c_str());
-                    found_it = m_decl_map->GetFunctionAddress (alternate_mangling_const_str, fun_addr);
+                    altnernate_name.SetCString(alternate_mangling.c_str());
+                    found_it = m_decl_map->GetFunctionAddress (altnernate_name, fun_addr);
                 }
             }
             
             if (!found_it)
             {
+                lldb_private::Mangled mangled_name(name);
+                lldb_private::Mangled alt_mangled_name(altnernate_name);
                 if (log)
                 {
-                    if (alternate_mangling_const_str)
-                        log->Printf("Function \"%s\" (alternate name \"%s\") has no address", name.GetCString(), alternate_mangling_const_str.GetCString());
+                    if (alt_mangled_name)
+                        log->Printf("Function \"%s\" (alternate name \"%s\") has no address",
+                                    mangled_name.GetName().GetCString(),
+                                    alt_mangled_name.GetName().GetCString());
                     else
-                        log->Printf("Function \"%s\" had no address", name.GetCString());
+                        log->Printf("Function \"%s\" had no address",
+                                    mangled_name.GetName().GetCString());
                 }
                 
                 if (m_error_stream)
                 {
-                    if (alternate_mangling_const_str)
-                        m_error_stream->Printf("error: call to a function '%s' (alternate name '%s') that is not present in the target\n", name.GetCString(), alternate_mangling_const_str.GetCString());
+                    if (alt_mangled_name)
+                        m_error_stream->Printf("error: call to a function '%s' (alternate name '%s') that is not present in the target\n",
+                                               mangled_name.GetName().GetCString(),
+                                               alt_mangled_name.GetName().GetCString());
                     else
-                        m_error_stream->Printf("error: call to a function '%s' that is not present in the target\n", name.GetCString());
+                        m_error_stream->Printf("error: call to a function '%s' that is not present in the target\n",
+                                               mangled_name.GetName().GetCString());
                 }
                 return false;
             }