[PATCH] D16438: Fix printing of types in initializers with suppressed tags.

Nick Sumner via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 22 02:09:46 PST 2016


nick.sumner retitled this revision from "Fix printing of nested variable declarations with suppressed tags" to "Fix printing of types in initializers with suppressed tags.".
nick.sumner updated the summary for this revision.
nick.sumner updated this revision to Diff 45658.
nick.sumner added a comment.

Updated to reset tag and specifier suppression precisely when printing initializers.


http://reviews.llvm.org/D16438

Files:
  lib/AST/DeclPrinter.cpp
  test/Sema/ast-print.c

Index: test/Sema/ast-print.c
===================================================================
--- test/Sema/ast-print.c
+++ test/Sema/ast-print.c
@@ -53,3 +53,13 @@
 
 // CHECK: struct pair_t p = {a: 3, .b = 4};
 struct pair_t p = {a: 3, .b = 4};
+
+void initializers() {
+  // CHECK: int *x = ((void *)0), *y = ((void *)0);
+  int *x = ((void *)0), *y = ((void *)0);
+  struct Z{};
+  struct {
+    struct Z z;
+  // CHECK: } z = {(struct Z){}};
+  } z = {(struct Z){}};
+}
Index: lib/AST/DeclPrinter.cpp
===================================================================
--- lib/AST/DeclPrinter.cpp
+++ lib/AST/DeclPrinter.cpp
@@ -751,7 +751,10 @@
       else if (D->getInitStyle() == VarDecl::CInit) {
         Out << " = ";
       }
-      Init->printPretty(Out, nullptr, Policy, Indentation);
+      PrintingPolicy SubPolicy(Policy);
+      SubPolicy.SuppressSpecifiers = false;
+      SubPolicy.SuppressTag = false;
+      Init->printPretty(Out, nullptr, SubPolicy, Indentation);
       if ((D->getInitStyle() == VarDecl::CallInit) && !isa<ParenListExpr>(Init))
         Out << ")";
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16438.45658.patch
Type: text/x-patch
Size: 1100 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160122/f9a25ac1/attachment.bin>


More information about the cfe-commits mailing list