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

Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 25 02:38:14 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL258679: Fix printing of types in initializers with suppressed tags. (authored by d0k).

Changed prior to commit:
  http://reviews.llvm.org/D16438?vs=45658&id=45849#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16438

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

Index: cfe/trunk/test/Sema/ast-print.c
===================================================================
--- cfe/trunk/test/Sema/ast-print.c
+++ cfe/trunk/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: cfe/trunk/lib/AST/DeclPrinter.cpp
===================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp
+++ cfe/trunk/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.45849.patch
Type: text/x-patch
Size: 1160 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160125/41dbe52d/attachment.bin>


More information about the cfe-commits mailing list