We have an issue where if you use a C function right now that has no prototype, it...
authorGreg Clayton <gclayton@apple.com>
Mon, 6 Apr 2015 17:14:02 +0000 (17:14 +0000)
committerGreg Clayton <gclayton@apple.com>
Mon, 6 Apr 2015 17:14:02 +0000 (17:14 +0000)
This used to be the case for "printf" before a function prototype was added to the builtin expression prefix file. This fix makes sure that if we get a mangled name that we don't find in the current target, that we only fall back to looking up function by basename if the function isn't contained in a namespace or class (no decl context).

llvm-svn: 234178

lldb/source/Expression/ClangExpressionDeclMap.cpp

index 5b92e74..1a694f7 100644 (file)
@@ -598,13 +598,17 @@ ClangExpressionDeclMap::GetFunctionAddress
         Mangled mangled(name, is_mangled);
                 
         CPPLanguageRuntime::MethodName method_name(mangled.GetDemangledName());
-        
-        llvm::StringRef basename = method_name.GetBasename();
-        
-        if (!basename.empty())
+
+        // the C++ context must be empty before we can think of searching for symbol by a simple basename
+        if (method_name.GetContext().empty())
         {
-            FindCodeSymbolInContext(ConstString(basename), m_parser_vars->m_sym_ctx, sc_list);
-            sc_list_size = sc_list.GetSize();
+            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();
+            }
         }
     }