[Lldb-commits] [PATCH] D16746: Use an artifical namespace so that member vars do not hide local vars.

Siva Chandra via lldb-commits lldb-commits at lists.llvm.org
Fri Jan 29 18:53:02 PST 2016


sivachandra created this revision.
sivachandra added reviewers: clayborg, spyffe.
sivachandra added a subscriber: lldb-commits.

While evaluating expressions when stopped in a class method, there was a
problem of member variables hiding local variables. This was happening
because, in the context of a method, clang already knew about member
variables with their name and assumed that they were the only variables
with those names in scope. Consequently, clang never checks with LLDB
about the possibility of local variables with the same name and goes
wrong. This change addresses the problem by using an artificial
namespace "$__lldb_local_vars". All local variables in scope are
declared in the "$__lldb_expr" method as follows:

    using $__lldb_local_vars::<local var 1>;
    using $__lldb_local_vars::<local var 2>;
    ...

This hides the member variables with the same name and forces clang to
enquire about the variables which it thinks are declared in
$__lldb_local_vars. When LLDB notices that clang is enquiring about
variables in $__lldb_local_vars, it looks up local vars and conveys
their information if found. This way, member variables do not hide local
variables, leading to correct evaluation of expressions.

http://reviews.llvm.org/D16746

Files:
  include/lldb/Symbol/ClangASTContext.h
  source/Expression/ExpressionSourceCode.cpp
  source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
  source/Symbol/ClangASTContext.cpp
  source/Target/StackFrame.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16746.46460.patch
Type: text/x-patch
Size: 9850 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160130/d74daef3/attachment.bin>


More information about the lldb-commits mailing list