Skip to content

[clang][ast]: Add DynamicAllocLValue and TypeInfoLValue support to APValue::dump(). #135178

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 5 commits into from
Apr 15, 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
8 changes: 8 additions & 0 deletions clang/lib/AST/TextNodeDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,14 @@ void TextNodeDumper::Visit(const APValue &Value, QualType Ty) {
else if (const auto *BE = B.dyn_cast<const Expr *>()) {
OS << BE->getStmtClassName() << ' ';
dumpPointer(BE);
} else if (const auto BTI = B.dyn_cast<TypeInfoLValue>()) {
OS << "TypeInfoLValue ";
ColorScope Color(OS, ShowColors, TypeColor);
BTI.print(OS, PrintPolicy);
} else if (B.is<DynamicAllocLValue>()) {
OS << "DynamicAllocLValue";
auto BDA = B.getDynamicAllocType();
dumpType(BDA);
} else {
const auto *VDB = B.get<const ValueDecl *>();
OS << VDB->getDeclKindName() << "Decl";
Expand Down
12 changes: 10 additions & 2 deletions clang/test/AST/ast-dump-APValue-lvalue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ struct F {
};
F f;

namespace std {
class type_info;
}

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

constexpr const int *n = nullptr;
// CHECK: `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} n 'const int *const' constexpr cinit
// CHECK-NEXT: |-value: LValue Base=null, Null=1, Offset=0, HasPath=1, PathLength=0, Path=()
// CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} n 'const int *const' constexpr cinit
// 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=()
}
Loading