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
34 lines
566 B
C++
34 lines
566 B
C++
struct StructA {
|
|
int x;
|
|
int y;
|
|
};
|
|
|
|
struct StructB {
|
|
int x;
|
|
StructA &a_ref;
|
|
StructA *&a_ptr_ref;
|
|
};
|
|
|
|
struct StructC : public StructB {
|
|
int y;
|
|
|
|
StructC(int x, StructA &a_ref, StructA *&a_ref_ptr, int y)
|
|
: StructB{x, a_ref, a_ref_ptr}, y(y) {}
|
|
};
|
|
|
|
int main() {
|
|
StructA a{1, 2};
|
|
StructA *a_ptr = &a;
|
|
|
|
StructB b{3, a, a_ptr};
|
|
StructB *b_ptr = &b;
|
|
StructB &b_ref = b;
|
|
StructB *&b_ptr_ref = b_ptr;
|
|
|
|
StructC c(4, a, a_ptr, 5);
|
|
StructC *c_ptr = &c;
|
|
StructC &c_ref = c;
|
|
StructC *&c_ptr_ref = c_ptr;
|
|
|
|
return 0; // Set breakpoint here
|
|
} |