[PATCH] D16438: Fix printing of nested variable declarations with suppressed tags
Nick Sumner via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 21 18:23:03 PST 2016
nick.sumner created this revision.
nick.sumner added reviewers: bkramer, rsmith.
nick.sumner added a subscriber: cfe-commits.
Allow nested variable declarations using suppressed tags.
This is the logical conclusion of a handful of patches needed to correctly print types in nested declarations and casts:
http://reviews.llvm.org/D16352
http://reviews.llvm.org/D16430
http://reviews.llvm.org/D16437
Currently, for the code:
enum Foo { FOO = 0 };
struct { enum Foo foo; } anon = {({
enum Foo foo2 = FOO;
foo2;
})};
The nested declaration of foo2 omits the tagged type name when printed:
foo2 = FOO;
With this patch, the tagged type name is included:
enum Foo foo2 = FOO;
http://reviews.llvm.org/D16438
Files:
lib/AST/StmtPrinter.cpp
test/Sema/ast-print.c
Index: test/Sema/ast-print.c
===================================================================
--- test/Sema/ast-print.c
+++ test/Sema/ast-print.c
@@ -71,6 +71,15 @@
int c = 1;
c;
});
+
+ enum Foo { FOO = 0 };
+ struct {
+ enum Foo foo;
+ } anon = {({
+// CHECK: enum Foo foo2 = FOO;
+ enum Foo foo2 = FOO;
+ foo2;
+ })};
}
// CHECK: char c = '\x80';
Index: lib/AST/StmtPrinter.cpp
===================================================================
--- lib/AST/StmtPrinter.cpp
+++ lib/AST/StmtPrinter.cpp
@@ -129,6 +129,7 @@
SmallVector<Decl*, 2> Decls(S->decls());
PrintingPolicy SubPolicy(Policy);
SubPolicy.SuppressSpecifiers = false;
+ SubPolicy.SuppressTag = false;
Decl::printGroup(Decls.data(), Decls.size(), OS, SubPolicy, IndentLevel);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16438.45634.patch
Type: text/x-patch
Size: 796 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160122/28962597/attachment-0001.bin>
More information about the cfe-commits
mailing list