From: Alex Lorenz Date: Mon, 3 Oct 2016 12:12:03 +0000 (+0000) Subject: Fix PR 28885: Fix AST Printer output for the inherited constructor using X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e894d1642cd56332998c9943f827a28d305ae6d9;p=clang Fix PR 28885: Fix AST Printer output for the inherited constructor using declarations. This commit ensures that the correct record type is printed out for the using declarations that represent C++ inherited constructors. It fixes a regression introduced in r274049 which changed the name that's stored in the using declarations that correspond to inherited constructors. Differential Revision: https://reviews.llvm.org/D25131 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@283102 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp index 7e786990be..6d47dd7b88 100644 --- a/lib/AST/DeclPrinter.cpp +++ b/lib/AST/DeclPrinter.cpp @@ -1346,6 +1346,17 @@ void DeclPrinter::VisitUsingDecl(UsingDecl *D) { if (D->hasTypename()) Out << "typename "; D->getQualifier()->print(Out, Policy); + + // Use the correct record name when the using declaration is used for + // inheriting constructors. + for (const auto *Shadow : D->shadows()) { + if (const auto *ConstructorShadow = + dyn_cast(Shadow)) { + assert(Shadow->getDeclContext() == ConstructorShadow->getDeclContext()); + Out << *ConstructorShadow->getNominatedBaseClass(); + return; + } + } Out << *D; } diff --git a/test/SemaCXX/cxx11-ast-print.cpp b/test/SemaCXX/cxx11-ast-print.cpp index 1eeb67a3d9..9c617af4e9 100644 --- a/test/SemaCXX/cxx11-ast-print.cpp +++ b/test/SemaCXX/cxx11-ast-print.cpp @@ -43,6 +43,14 @@ template const char *operator"" _suffix(); // CHECK: const char *PR23120 = operator""_suffix(); const char *PR23120 = U"𐐷"_suffix; +// PR28885 +struct A { + A(); +}; +struct B : A { + using A::A; // CHECK: using A::A; +}; // CHECK-NEXT: }; + // CHECK: ; ; // CHECK-NOT: ;