[PATCH] D156523: [clang][DeclPrinter] Fix AST print to suppress output of implicit (non-written) constructor initializers

Timo Stripf via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 7 16:14:39 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG291eb2589fdc: [clang][DeclPrinter] Fix AST print to suppress output of implicit (non-written)… (authored by strimo378).

Changed prior to commit:
  https://reviews.llvm.org/D156523?vs=545102&id=547988#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156523/new/

https://reviews.llvm.org/D156523

Files:
  clang/lib/AST/DeclPrinter.cpp
  clang/test/AST/ast-print-method-decl.cpp


Index: clang/test/AST/ast-print-method-decl.cpp
===================================================================
--- clang/test/AST/ast-print-method-decl.cpp
+++ clang/test/AST/ast-print-method-decl.cpp
@@ -100,3 +100,26 @@
 
   // CHECK-NEXT: };
 };
+
+
+// ---- Check that implict (non-written) constructor initializers are not output
+
+struct ImplicitCtorInit1 {
+  int a;
+};
+
+// CHECK: struct ImplicitCtorInit2 : ImplicitCtorInit1 {
+struct ImplicitCtorInit2 : ImplicitCtorInit1 {
+
+  // CHECK-NEXT: ImplicitCtorInit2(int *) {
+  ImplicitCtorInit2(int *) {
+  // CHECK-NEXT: }
+  }
+
+  // CHECK-NEXT: ImplicitCtorInit2(int **) : ImplicitCtorInit1() {
+  ImplicitCtorInit2(int **) : ImplicitCtorInit1() {
+  // CHECK-NEXT: }
+  }
+
+  // CHECK-NEXT: };
+};
Index: clang/lib/AST/DeclPrinter.cpp
===================================================================
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -309,6 +309,8 @@
   for (const auto *BMInitializer : CDecl->inits()) {
     if (BMInitializer->isInClassMemberInitializer())
       continue;
+    if (!BMInitializer->isWritten())
+      continue;
 
     if (!HasInitializerList) {
       Proto += " : ";


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156523.547988.patch
Type: text/x-patch
Size: 1199 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230807/0802992d/attachment.bin>


More information about the cfe-commits mailing list