Skip to content

Commit ea9b59a

Browse files
committedOct 3, 2016
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: 283105
1 parent 4ff920b commit ea9b59a

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
 

‎clang/lib/AST/DeclPrinter.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,17 @@ void DeclPrinter::VisitUsingDecl(UsingDecl *D) {
13461346
if (D->hasTypename())
13471347
Out << "typename ";
13481348
D->getQualifier()->print(Out, Policy);
1349+
1350+
// Use the correct record name when the using declaration is used for
1351+
// inheriting constructors.
1352+
for (const auto *Shadow : D->shadows()) {
1353+
if (const auto *ConstructorShadow =
1354+
dyn_cast<ConstructorUsingShadowDecl>(Shadow)) {
1355+
assert(Shadow->getDeclContext() == ConstructorShadow->getDeclContext());
1356+
Out << *ConstructorShadow->getNominatedBaseClass();
1357+
return;
1358+
}
1359+
}
13491360
Out << *D;
13501361
}
13511362

‎clang/test/SemaCXX/cxx11-ast-print.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ template <class C, C...> const char *operator"" _suffix();
4343
// CHECK: const char *PR23120 = operator""_suffix<char32_t, 66615>();
4444
const char *PR23120 = U"𐐷"_suffix;
4545

46+
// PR28885
47+
struct A {
48+
A();
49+
};
50+
struct B : A {
51+
using A::A; // CHECK: using A::A;
52+
}; // CHECK-NEXT: };
53+
4654
// CHECK: ;
4755
;
4856
// CHECK-NOT: ;

0 commit comments

Comments
 (0)
Please sign in to comment.