[lldb] Fix member access in GetExpressionPath
authorTonko Sabolčec <tonkosi123@gmail.com>
Wed, 12 Oct 2022 11:46:23 +0000 (11:46 +0000)
committerAndy Yankovsky <weratt@gmail.com>
Wed, 12 Oct 2022 12:08:57 +0000 (12:08 +0000)
commit0205aa4a02570dfeda5807f66756ebdbb102744b
treef29df407f3a7e4d2be9f12716d34021a832e50a4
parentb781ef890fcf4d4fdf1734fa437099bdf5d8d6fc
[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/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py
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]