Skip to content

Commit

Permalink
Fix PR 28885: Fix AST Printer output for the inherited constructor using
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hyp committed Oct 3, 2016
1 parent 10874f7 commit 2bc0289
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions clang/lib/AST/DeclPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 8 additions & 0 deletions clang/test/SemaCXX/cxx11-ast-print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: ;
Expand Down

0 comments on commit 2bc0289

Please sign in to comment.