r283102 - 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:12:04 PDT 2016


Author: arphaman
Date: Mon Oct  3 07:12:03 2016
New Revision: 283102

URL: http://llvm.org/viewvc/llvm-project?rev=283102&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=283102&r1=283101&r2=283102&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Mon Oct  3 07:12:03 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=283102&r1=283101&r2=283102&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp Mon Oct  3 07:12:03 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