summaryrefslogtreecommitdiffstats
path: root/lldb/source/Expression/ClangExpressionDeclMap.cpp
diff options
context:
space:
mode:
authorPaul Herman <paulherman@google.com>2015-09-15 23:44:17 +0000
committerPaul Herman <paulherman@google.com>2015-09-15 23:44:17 +0000
commitd628cbb999070e30986a5f9b24b3ffe8ebcd6bc4 (patch)
tree029f2d84d919aaf8a6902d3f5e5daa2d80cb9101 /lldb/source/Expression/ClangExpressionDeclMap.cpp
parentdff84070da5ca09ab89c87036f01e21b31f81a0f (diff)
downloadbcm5719-llvm-d628cbb999070e30986a5f9b24b3ffe8ebcd6bc4.tar.gz
bcm5719-llvm-d628cbb999070e30986a5f9b24b3ffe8ebcd6bc4.zip
Search variables based on clang::DeclContext and clang::Decl tree
Summary: SymbolFileDWARF now creates VarDecl and BlockDecl and adds them to the Decl tree. Then, in ClangExpressionDeclMap it uses the Decl tree to search for a variable. This fixes lots of variable scoping problems. Reviewers: sivachandra, chaoren, spyffe, clayborg Subscribers: tberghammer, jingham, lldb-commits Differential Revision: http://reviews.llvm.org/D12658 llvm-svn: 247746
Diffstat (limited to 'lldb/source/Expression/ClangExpressionDeclMap.cpp')
-rw-r--r--lldb/source/Expression/ClangExpressionDeclMap.cpp41
1 files changed, 25 insertions, 16 deletions
diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp
index e63f8b5ec5b..1678d835227 100644
--- a/lldb/source/Expression/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp
@@ -28,6 +28,7 @@
#include "lldb/Expression/Materializer.h"
#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/CompilerDecl.h"
#include "lldb/Symbol/CompilerDeclContext.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
@@ -1035,6 +1036,9 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
// doesn't start with our phony prefix of '$'
Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
+ SymbolContext sym_ctx;
+ if (frame != nullptr)
+ sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction|lldb::eSymbolContextBlock);
if (name_unique_cstr[0] == '$' && !namespace_decl)
{
static ConstString g_lldb_class_name ("$__lldb_class");
@@ -1046,7 +1050,6 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
if (frame == NULL)
return;
- SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction|lldb::eSymbolContextBlock);
// Find the block that defines the function represented by "sym_ctx"
Block *function_block = sym_ctx.GetFunctionBlock();
@@ -1352,24 +1355,30 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
if (frame && !namespace_decl)
{
- valobj = frame->GetValueForVariableExpressionPath(name_unique_cstr,
- eNoDynamicValues,
- StackFrame::eExpressionPathOptionCheckPtrVsMember |
- StackFrame::eExpressionPathOptionsNoFragileObjcIvar |
- StackFrame::eExpressionPathOptionsNoSyntheticChildren |
- StackFrame::eExpressionPathOptionsNoSyntheticArrayRange,
- var,
- err);
-
- // If we found a variable in scope, no need to pull up function names
- if (err.Success() && var)
+ CompilerDeclContext compiler_decl_context = sym_ctx.block != nullptr ? sym_ctx.block->GetDeclContext() : CompilerDeclContext();
+
+ if (compiler_decl_context)
{
- AddOneVariable(context, var, valobj, current_id);
- context.m_found.variable = true;
- return;
+ // Make sure that the variables are parsed so that we have the declarations
+ VariableListSP vars = frame->GetInScopeVariableList(true);
+ for (size_t i = 0; i < vars->GetSize(); i++)
+ vars->GetVariableAtIndex(i)->GetDecl();
+
+ // Search for declarations matching the name
+ std::vector<CompilerDecl> found_decls = compiler_decl_context.FindDeclByName(name);
+ for (CompilerDecl decl : found_decls)
+ {
+ var = decl.GetAsVariable();
+ if (var)
+ {
+ valobj = ValueObjectVariable::Create(frame, var);
+ AddOneVariable(context, var, valobj, current_id);
+ context.m_found.variable = true;
+ return;
+ }
+ }
}
}
-
if (target)
{
var = FindGlobalVariable (*target,
OpenPOWER on IntegriCloud