r283105 - Fix PR 28885: Fix AST Printer output for the inherited constructor using
Alex Lorenz via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 3 05:22:17 PDT 2016
Author: arphaman
Date: Mon Oct 3 07:22:17 2016
New Revision: 283105
URL: http://llvm.org/viewvc/llvm-project?rev=283105&view=rev
Log:
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
Modified:
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp
Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=283105&r1=283104&r2=283105&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Mon Oct 3 07:22:17 2016
@@ -1346,6 +1346,17 @@ void DeclPrinter::VisitUsingDecl(UsingDe
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;
}
Modified: cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp?rev=283105&r1=283104&r2=283105&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp Mon Oct 3 07:22:17 2016
@@ -43,6 +43,14 @@ template <class C, C...> const char *ope
// 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: ;
More information about the cfe-commits
mailing list