This revision was automatically updated to reflect the committed changes.
Closed by commit rL283102: Fix PR 28885: Fix AST Printer output for the 
inherited constructor using (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D25131?vs=73145&id=73410#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25131

Files:
  cfe/trunk/lib/AST/DeclPrinter.cpp
  cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp


Index: cfe/trunk/lib/AST/DeclPrinter.cpp
===================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp
+++ cfe/trunk/lib/AST/DeclPrinter.cpp
@@ -1346,6 +1346,17 @@
   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;
 }
 
Index: cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp
===================================================================
--- cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp
+++ cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp
@@ -43,6 +43,14 @@
 // 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: ;


Index: cfe/trunk/lib/AST/DeclPrinter.cpp
===================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp
+++ cfe/trunk/lib/AST/DeclPrinter.cpp
@@ -1346,6 +1346,17 @@
   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;
 }
 
Index: cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp
===================================================================
--- cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp
+++ cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp
@@ -43,6 +43,14 @@
 // 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: ;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to