diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp index 3d9397fb0b540..6b524cfcd2d71 100644 --- a/clang/lib/AST/TextNodeDumper.cpp +++ b/clang/lib/AST/TextNodeDumper.cpp @@ -843,7 +843,10 @@ void TextNodeDumper::Visit(const APValue &Value, QualType Ty) { } ColorScope Color(OS, ShowColors, DeclNameColor); - OS << Value.getMemberPointerDecl()->getDeclName(); + if (const ValueDecl *MemDecl = Value.getMemberPointerDecl()) + OS << MemDecl->getDeclName(); + else + OS << "null"; return; } case APValue::AddrLabelDiff: diff --git a/clang/test/AST/ast-dump-APValue-lvalue.cpp b/clang/test/AST/ast-dump-APValue-lvalue.cpp index 51d22a5ba8b6d..f4cf2f5291760 100644 --- a/clang/test/AST/ast-dump-APValue-lvalue.cpp +++ b/clang/test/AST/ast-dump-APValue-lvalue.cpp @@ -67,6 +67,10 @@ void Test(int (&arr)[10]) { // 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:{{.*}} pmi 'int (MP::*const)' constexpr cinit - // CHECK-NEXT: |-value: MemberPointer MP::x + // CHECK: | `-VarDecl {{.*}} col:{{.*}} pmi 'int (MP::*const)' constexpr cinit + // CHECK-NEXT: | |-value: MemberPointer MP::x + + constexpr int(MP::*pmn) = (int MP::*)nullptr; + // CHECK: `-VarDecl {{.*}} col:{{.*}} pmn 'int (MP::*const)' constexpr cinit + // CHECK-NEXT: |-value: MemberPointer null }