aboutsummaryrefslogtreecommitdiff
path: root/source/Expression/ClangExpressionDeclMap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Expression/ClangExpressionDeclMap.cpp')
-rw-r--r--source/Expression/ClangExpressionDeclMap.cpp51
1 files changed, 47 insertions, 4 deletions
diff --git a/source/Expression/ClangExpressionDeclMap.cpp b/source/Expression/ClangExpressionDeclMap.cpp
index 43c8a5fb1bcb..e3027378422f 100644
--- a/source/Expression/ClangExpressionDeclMap.cpp
+++ b/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 @@ ClangExpressionDeclMap::GetFunctionAddress
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 @@ ClangExpressionDeclMap::GetFunctionAddress
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)
{
@@ -1274,10 +1295,9 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
{
valobj = frame->GetValueForVariableExpressionPath(name_unique_cstr,
eNoDynamicValues,
- StackFrame::eExpressionPathOptionCheckPtrVsMember ||
- StackFrame::eExpressionPathOptionsAllowDirectIVarAccess ||
- StackFrame::eExpressionPathOptionsNoFragileObjcIvar ||
- StackFrame::eExpressionPathOptionsNoSyntheticChildren ||
+ StackFrame::eExpressionPathOptionCheckPtrVsMember |
+ StackFrame::eExpressionPathOptionsNoFragileObjcIvar |
+ StackFrame::eExpressionPathOptionsNoSyntheticChildren |
StackFrame::eExpressionPathOptionsNoSyntheticArrayRange,
var,
err);
@@ -1307,6 +1327,16 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
return;
}
}
+
+ std::vector<clang::NamedDecl *> decls_from_modules;
+
+ if (target)
+ {
+ if (ClangModulesDeclVendor *decl_vendor = target->GetClangModulesDeclVendor())
+ {
+ decl_vendor->FindDecls(name, false, UINT32_MAX, decls_from_modules);
+ }
+ }
if (!context.m_found.variable)
{
@@ -1384,6 +1414,19 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
non_extern_symbol = sym_ctx.symbol;
}
}
+
+ if (!context.m_found.function_with_type_info)
+ {
+ for (clang::NamedDecl *decl : decls_from_modules)
+ {
+ if (llvm::isa<clang::FunctionDecl>(decl))
+ {
+ clang::NamedDecl *copied_decl = llvm::cast<FunctionDecl>(m_ast_importer->CopyDecl(m_ast_context, &decl->getASTContext(), decl));
+ context.AddNamedDecl(copied_decl);
+ context.m_found.function_with_type_info = true;
+ }
+ }
+ }
if (!context.m_found.function_with_type_info)
{