[lldb] Fix member access in GetExpressionPath
authorTonko Sabolčec <tonkosi123@gmail.com>
Fri, 30 Sep 2022 11:10:32 +0000 (11:10 +0000)
committerAndy Yankovsky <weratt@gmail.com>
Fri, 30 Sep 2022 11:25:07 +0000 (11:25 +0000)
commit14642dc7405ebd93a46dda1f2dba616395660715
treecf168ef11726b40e3ce3825a422b55b7a8322884
parentc720fad16fd90d625a1373d562e568cd36770fd1
[lldb] Fix member access in GetExpressionPath

This change fixes two issues in ValueObject::GetExpressionPath method:

 1. Accessing members of struct references used to produce expression
    paths such as "str.&str.member" (instead of the expected
    "str.member"). This is fixed by assigning the flag tha the child
    value is a dereference when calling Dereference() on references
    and adjusting logic in expression path creation.

 2. If the parent of member access is dereference, the produced
    expression path was "*(ptr).member". This is incorrect, since it
    dereferences the member instead of the pointer. This is fixed by
    wrapping dereference expression into parenthesis, resulting with
    "(*(ptr)).member".

Reviewed By: werat, clayborg

Differential Revision: https://reviews.llvm.org/D132734
lldb/source/Core/ValueObject.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/test/API/python_api/expression_path/Makefile [new file with mode: 0644]
lldb/test/API/python_api/expression_path/TestExpressionPath.py [new file with mode: 0644]
lldb/test/API/python_api/expression_path/main.cpp [new file with mode: 0644]