This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG2ca74162258b: [clang][DeclPrinter] Fix AST print of delegating constructors (authored by strimo378).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D154186/new/ https://reviews.llvm.org/D154186 Files: clang/lib/AST/DeclPrinter.cpp clang/test/AST/ast-print-method-decl.cpp Index: clang/test/AST/ast-print-method-decl.cpp =================================================================== --- /dev/null +++ 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 <typename Ty> B(Ty); + template <typename Ty> B(Ty); + + // FIXME: Implicitly specialized method should not be output + // CHECK-NEXT: template<> B<float>(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 *>(const char *); + + // CHECK: C(int) : C("") { + C(int) : C("") { + // CHECK-NEXT: } + } + + // CHECK-NEXT: }; +}; Index: clang/lib/AST/DeclPrinter.cpp =================================================================== --- clang/lib/AST/DeclPrinter.cpp +++ clang/lib/AST/DeclPrinter.cpp @@ -321,6 +321,8 @@ if (BMInitializer->isAnyMemberInitializer()) { FieldDecl *FD = BMInitializer->getAnyMember(); Out << *FD; + } else if (BMInitializer->isDelegatingInitializer()) { + Out << CDecl->getNameAsString(); } else { Out << QualType(BMInitializer->getBaseClass(), 0).getAsString(Policy); }
Index: clang/test/AST/ast-print-method-decl.cpp =================================================================== --- /dev/null +++ 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 <typename Ty> B(Ty); + template <typename Ty> B(Ty); + + // FIXME: Implicitly specialized method should not be output + // CHECK-NEXT: template<> B<float>(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 *>(const char *); + + // CHECK: C(int) : C("") { + C(int) : C("") { + // CHECK-NEXT: } + } + + // CHECK-NEXT: }; +}; Index: clang/lib/AST/DeclPrinter.cpp =================================================================== --- clang/lib/AST/DeclPrinter.cpp +++ clang/lib/AST/DeclPrinter.cpp @@ -321,6 +321,8 @@ if (BMInitializer->isAnyMemberInitializer()) { FieldDecl *FD = BMInitializer->getAnyMember(); Out << *FD; + } else if (BMInitializer->isDelegatingInitializer()) { + Out << CDecl->getNameAsString(); } else { Out << QualType(BMInitializer->getBaseClass(), 0).getAsString(Policy); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits