teak-llvm/lldb/packages/Python/lldbsuite/test/lang/cpp
Siva Chandra 375882dddb Use an artifical namespace so that member vars do not hide local vars.
Summary:
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.

A point to keep in mind is that the above solution does not solve the
problem for one specific case:

    namespace N
    {
        int a;
    }

    class A
    {
    public:
        void Method();
        int a;
    };

    void
    A::Method()
    {
        using N::a;
        ...

        // Since the above solution only touches locals, it does not
        // force clang to enquire about "a" coming from namespace N.
    }

Reviewers: clayborg, spyffe

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D16746

llvm-svn: 259810
2016-02-04 18:38:35 +00:00
..
auto Move some of the common decorators to decorators.py. 2016-02-04 18:03:01 +00:00
bool
breakpoint-commands Remove use_lldb_suite from the package, and don't import it anymore. 2015-11-03 19:20:39 +00:00
call-function
chained-calls
char1632_t Always write the session file in UTF-8. 2016-02-01 18:12:59 +00:00
class_static Remove assumptions that thread 0 is always the main thread. 2016-01-21 21:07:30 +00:00
class_types Remove assumptions that thread 0 is always the main thread. 2016-01-21 21:07:30 +00:00
diamond Remove assumptions that thread 0 is always the main thread. 2016-01-21 21:07:30 +00:00
dynamic-value Remove use_lldb_suite from the package, and don't import it anymore. 2015-11-03 19:20:39 +00:00
enum_types Remove use_lldb_suite from the package, and don't import it anymore. 2015-11-03 19:20:39 +00:00
exceptions Remove use_lldb_suite from the package, and don't import it anymore. 2015-11-03 19:20:39 +00:00
frame-var-anon-unions Fix up LLDB for a change in the way clang represents anonymous unions such that the 'frame variable' command can still find the members of such union as if they were top-level variables in the current scope 2015-11-19 22:28:58 +00:00
global_operators
incomplete-types Trying to submit 254476 one more time. This implement -gmodule debugging support. 2015-12-08 01:02:08 +00:00
limit-debug-info Move some of the common decorators to decorators.py. 2016-02-04 18:03:01 +00:00
member-and-local-vars-with-same-name Use an artifical namespace so that member vars do not hide local vars. 2016-02-04 18:38:35 +00:00
namespace XFail TestNamespaceLookup tests on Windows. 2016-01-22 23:05:29 +00:00
nsimport XFAIL TestCppNsImport on FreeBSD 2015-12-22 19:10:09 +00:00
overloaded-functions
rdar12991846 Remove use_lldb_suite from the package, and don't import it anymore. 2015-11-03 19:20:39 +00:00
rvalue-references
scope
signed_types NFC. Corrects name of test class and a comment. 2016-01-21 21:10:00 +00:00
static_members Remove use_lldb_suite from the package, and don't import it anymore. 2015-11-03 19:20:39 +00:00
static_methods
stl Remove assumptions that thread 0 is always the main thread. 2016-01-21 21:07:30 +00:00
this
unique-types Remove use_lldb_suite from the package, and don't import it anymore. 2015-11-03 19:20:39 +00:00
unsigned_types Remove use_lldb_suite from the package, and don't import it anymore. 2015-11-03 19:20:39 +00:00
virtual Move some of the common decorators to decorators.py. 2016-02-04 18:03:01 +00:00
wchar_t Remove use_lldb_suite from the package, and don't import it anymore. 2015-11-03 19:20:39 +00:00