diff options
author | Alex Lorenz <arphaman@gmail.com> | 2016-10-03 12:12:03 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2016-10-03 12:12:03 +0000 |
commit | 2bc02892be4fa05a03b3777cbcce4e2a962141ae (patch) | |
tree | d2447e383343b1baeedeb18d71feac5a49740038 /clang | |
parent | 10874f70fa274c4dac2efd7ea1eb729cc05b6fcc (diff) | |
download | bcm5719-llvm-2bc02892be4fa05a03b3777cbcce4e2a962141ae.tar.gz bcm5719-llvm-2bc02892be4fa05a03b3777cbcce4e2a962141ae.zip |
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
llvm-svn: 283102
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/AST/DeclPrinter.cpp | 11 | ||||
-rw-r--r-- | clang/test/SemaCXX/cxx11-ast-print.cpp | 8 |
2 files changed, 19 insertions, 0 deletions
diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index 7e786990bec..6d47dd7b883 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/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<ConstructorUsingShadowDecl>(Shadow)) { + assert(Shadow->getDeclContext() == ConstructorShadow->getDeclContext()); + Out << *ConstructorShadow->getNominatedBaseClass(); + return; + } + } Out << *D; } diff --git a/clang/test/SemaCXX/cxx11-ast-print.cpp b/clang/test/SemaCXX/cxx11-ast-print.cpp index 1eeb67a3d9b..9c617af4e95 100644 --- a/clang/test/SemaCXX/cxx11-ast-print.cpp +++ b/clang/test/SemaCXX/cxx11-ast-print.cpp @@ -43,6 +43,14 @@ template <class C, C...> const char *operator"" _suffix(); // CHECK: const char *PR23120 = operator""_suffix<char32_t, 66615>(); const char *PR23120 = U"𐐷"_suffix; +// PR28885 +struct A { + A(); +}; +struct B : A { + using A::A; // CHECK: using A::A; +}; // CHECK-NEXT: }; + // CHECK: ; ; // CHECK-NOT: ; |