We have an issue where if you use a C function right now that has no prototype, it isn't marked as extern "C" and the name to lookup is some C++ mangled form of the name.

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
This commit is contained in:
Greg Clayton 2015-04-06 17:14:02 +00:00
parent 936c56393c
commit b23c24c2a8
1 changed files with 10 additions and 6 deletions

View File

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