diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index a6a9911c8992a..de33d79eeb484 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/lib/AST/DeclPrinter.cpp @@ -321,6 +321,8 @@ void DeclPrinter::PrintConstructorInitializers(CXXConstructorDecl *CDecl, if (BMInitializer->isAnyMemberInitializer()) { FieldDecl *FD = BMInitializer->getAnyMember(); Out << *FD; + } else if (BMInitializer->isDelegatingInitializer()) { + Out << CDecl->getNameAsString(); } else { Out << QualType(BMInitializer->getBaseClass(), 0).getAsString(Policy); } diff --git a/clang/test/AST/ast-print-method-decl.cpp b/clang/test/AST/ast-print-method-decl.cpp new file mode 100644 index 0000000000000..4a3f5440fe158 --- /dev/null +++ b/clang/test/AST/ast-print-method-decl.cpp @@ -0,0 +1,48 @@ +// RUN: %clang_cc1 -ast-print %s -o - -std=c++20 | FileCheck %s + +// CHECK: struct A { +struct A { + // CHECK-NEXT: A(); + A(); + + // CHECK-NEXT: A(int) : A() { + A(int) : A() { + // CHECK-NEXT: } + } + + // CHECK-NEXT: }; +}; + + +// CHECK: struct B { +struct B { + // CHECK-NEXT: template B(Ty); + template B(Ty); + + // FIXME: Implicitly specialized method should not be output + // CHECK-NEXT: template<> B(float); + + // CHECK-NEXT: B(int X) : B((float)X) { + B(int X) : B((float)X) { + // CHECK-NEXT: } + } + + // CHECK-NEXT: }; +}; + +// CHECK: struct C { +struct C { + // FIXME: template <> should not be output + // CHECK: template <> C(auto); + C(auto); + + // FIXME: Implicitly specialized method should not be output + // CHECK: template<> C(const char *); + + // CHECK: C(int) : C("") { + C(int) : C("") { + // CHECK-NEXT: } + } + + // CHECK-NEXT: }; +};