summaryrefslogtreecommitdiffstats
path: root/lldb/source/Expression
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2010-07-27 00:55:47 +0000
committerSean Callanan <scallanan@apple.com>2010-07-27 00:55:47 +0000
commit8ade104a0a10442b83347e21da001f0a26a73785 (patch)
tree0894b3f7eee5ad6b9d3b0e0b28e90b39f5a092c4 /lldb/source/Expression
parentce3a8293a0473078fa29178a00f2dc7945438572 (diff)
downloadbcm5719-llvm-8ade104a0a10442b83347e21da001f0a26a73785.tar.gz
bcm5719-llvm-8ade104a0a10442b83347e21da001f0a26a73785.zip
Changed SymbolContext so when you search for functions
it returns a list of functions as a SymbolContextList. Rewrote the clients of SymbolContext to use this SymbolContextList. Rewrote some of the providers of the data to SymbolContext to make them respect preferences as to whether the list should be cleared first; propagated that change out. ClangExpressionDeclMap and ClangASTSource use this new function list to properly generate function definitions - even for functions that don't have a prototype in the debug information. llvm-svn: 109476
Diffstat (limited to 'lldb/source/Expression')
-rw-r--r--lldb/source/Expression/ClangASTSource.cpp16
-rw-r--r--lldb/source/Expression/ClangExpressionDeclMap.cpp86
2 files changed, 76 insertions, 26 deletions
diff --git a/lldb/source/Expression/ClangASTSource.cpp b/lldb/source/Expression/ClangASTSource.cpp
index 2ea2bce1e1f..3f83acf4b8a 100644
--- a/lldb/source/Expression/ClangASTSource.cpp
+++ b/lldb/source/Expression/ClangASTSource.cpp
@@ -146,3 +146,19 @@ clang::NamedDecl *NameSearchContext::AddFunDecl(void *type) {
return Decl;
}
+
+clang::NamedDecl *NameSearchContext::AddGenericFunDecl()
+{
+ QualType generic_function_type(ASTSource.Context.getFunctionType(ASTSource.Context.getSizeType(), // result
+ NULL, // argument types
+ 0, // number of arguments
+ true, // variadic?
+ 0, // type qualifiers
+ false, // has exception specification?
+ false, // has any exception specification?
+ 0, // number of exceptions
+ NULL, // exceptions
+ FunctionType::ExtInfo())); // defaults for noreturn, regparm, calling convention
+
+ return AddFunDecl(generic_function_type.getAsOpaquePtr());
+}
diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp
index 8d19766608a..d5d381d64a2 100644
--- a/lldb/source/Expression/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp
@@ -603,12 +603,23 @@ ClangExpressionDeclMap::GetDecls(NameSearchContext &context,
}
ConstString name_cs(name);
+ SymbolContextList sym_ctxs;
- Function *fn = m_sym_ctx->FindFunctionByName(name_cs.GetCString());
+ m_sym_ctx->FindFunctionsByName(name_cs, false, sym_ctxs);
+
+ for (uint32_t index = 0, num_indices = sym_ctxs.GetSize();
+ index < num_indices;
+ ++index)
+ {
+ SymbolContext sym_ctx;
+ sym_ctxs.GetContextAtIndex(index, sym_ctx);
+
+ if (sym_ctx.function)
+ AddOneFunction(context, sym_ctx.function, NULL);
+ else if(sym_ctx.symbol)
+ AddOneFunction(context, NULL, sym_ctx.symbol);
+ }
- if (fn)
- AddOneFunction(context, fn);
-
Variable *var = FindVariableInScope(*m_sym_ctx, name);
if (var)
@@ -749,41 +760,64 @@ ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
void
ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
- Function* fun)
+ Function* fun,
+ Symbol* symbol)
{
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS);
-
- Type *fun_type = fun->GetType();
- if (!fun_type)
- {
- if (log)
- log->PutCString("Skipped a function because it has no type");
- return;
- }
+ NamedDecl *fun_decl;
+ std::auto_ptr<Value> fun_location(new Value);
+ const Address *fun_address;
- void *fun_opaque_type = fun_type->GetOpaqueClangQualType();
+ // only valid for Functions, not for Symbols
+ void *fun_opaque_type = NULL;
+ clang::ASTContext *fun_ast_context = NULL;
- if (!fun_opaque_type)
+ if (fun)
+ {
+ Type *fun_type = fun->GetType();
+
+ if (!fun_type)
+ {
+ if (log)
+ log->PutCString("Skipped a function because it has no type");
+ return;
+ }
+
+ fun_opaque_type = fun_type->GetOpaqueClangQualType();
+
+ if (!fun_opaque_type)
+ {
+ if (log)
+ log->PutCString("Skipped a function because it has no Clang type");
+ return;
+ }
+
+ fun_address = &fun->GetAddressRange().GetBaseAddress();
+
+ TypeList *type_list = fun_type->GetTypeList();
+ fun_ast_context = type_list->GetClangASTContext().getASTContext();
+ void *copied_type = ClangASTContext::CopyType(context.GetASTContext(), fun_ast_context, fun_opaque_type);
+
+ fun_decl = context.AddFunDecl(copied_type);
+ }
+ else if (symbol)
+ {
+ fun_address = &symbol->GetAddressRangeRef().GetBaseAddress();
+
+ fun_decl = context.AddGenericFunDecl();
+ }
+ else
{
if (log)
- log->PutCString("Skipped a function because it has no Clang type");
+ log->PutCString("AddOneFunction called with no function and no symbol");
return;
}
- std::auto_ptr<Value> fun_location(new Value);
-
- const Address &fun_address = fun->GetAddressRange().GetBaseAddress();
- lldb::addr_t load_addr = fun_address.GetLoadAddress(m_exe_ctx->process);
+ lldb::addr_t load_addr = fun_address->GetLoadAddress(m_exe_ctx->process);
fun_location->SetValueType(Value::eValueTypeLoadAddress);
fun_location->GetScalar() = load_addr;
- TypeList *type_list = fun_type->GetTypeList();
- clang::ASTContext *fun_ast_context = type_list->GetClangASTContext().getASTContext();
- void *copied_type = ClangASTContext::CopyType(context.GetASTContext(), fun_ast_context, fun_opaque_type);
-
- NamedDecl *fun_decl = context.AddFunDecl(copied_type);
-
Tuple tuple;
tuple.m_decl = fun_decl;
OpenPOWER on IntegriCloud