Skip to content

[clang] Implement dump() for MemberPointer APValues #136130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions clang/lib/AST/TextNodeDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,9 +829,21 @@ void TextNodeDumper::Visit(const APValue &Value, QualType Ty) {

return;
}
case APValue::MemberPointer:
OS << "MemberPointer <todo>";
case APValue::MemberPointer: {
OS << "MemberPointer ";
auto Path = Value.getMemberPointerPath();
for (const CXXRecordDecl *D : Path) {
{
ColorScope Color(OS, ShowColors, DeclNameColor);
OS << D->getDeclName();
}
OS << "::";
}

ColorScope Color(OS, ShowColors, DeclNameColor);
OS << Value.getMemberPointerDecl()->getDeclName();
return;
}
case APValue::AddrLabelDiff:
OS << "AddrLabelDiff <todo>";
return;
Expand Down
18 changes: 16 additions & 2 deletions clang/test/AST/ast-dump-APValue-lvalue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ namespace std {
class type_info;
}

struct P {
int x;
};
struct Q {
float m;
};
struct MP : P, Q {
int i;
};

void Test(int (&arr)[10]) {
constexpr int *pi = &i;
// CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pi 'int *const' constexpr cinit
Expand All @@ -53,6 +63,10 @@ void Test(int (&arr)[10]) {
// CHECK-NEXT: | |-value: LValue Base=null, Null=1, Offset=0, HasPath=1, PathLength=0, Path=()

constexpr const std::type_info* pti = &typeid(int);
// CHECK: `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pti 'const std::type_info *const' constexpr cinit
// CHECK-NEXT: |-value: LValue Base=TypeInfoLValue typeid(int), Null=0, Offset=0, HasPath=1, PathLength=0, Path=()
// CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pti 'const std::type_info *const' constexpr cinit
// CHECK-NEXT: | |-value: LValue Base=TypeInfoLValue typeid(int), Null=0, Offset=0, HasPath=1, PathLength=0, Path=()

constexpr int(MP::*pmi) = (int MP::*)&P::x;
// CHECK: `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pmi 'int (MP::*const)' constexpr cinit
// CHECK-NEXT: |-value: MemberPointer MP::x
}
22 changes: 0 additions & 22 deletions clang/test/AST/ast-dump-APValue-todo.cpp

This file was deleted.

Loading