]> granicus.if.org Git - clang/commit
Fix printing of anonymous struct typedefs.
authorSteven Watanabe <steven@providere-consulting.com>
Fri, 18 Mar 2016 21:35:59 +0000 (21:35 +0000)
committerSteven Watanabe <steven@providere-consulting.com>
Fri, 18 Mar 2016 21:35:59 +0000 (21:35 +0000)
commit7d8134a1ff132cd975eaf1c75cf9e193ef16b788
tree072a1e8fa12c691c47ea1c43b0ce8e69aa19b061
parent1d22cda9dbf116c761db465ee2c7ce50acb7863d
Fix printing of anonymous struct typedefs.

clang -cc1 -ast-print put the struct
definition in the wrong place, like this:

  struct {} typedef S;

The reason that this happens is that the printing code
first prints the struct definition, and then tells the next
declaration to leave out the type. This behavior
is correct for simple variable declarations, but fails for
typedefs (or extern, mutable, etc).

The patch address this problem by skipping the struct
declaration when we first see it, and then telling the first
subsequent declaration that it needs to print out the full
struct definition.

Differential Revision: http://reviews.llvm.org/D17285

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263836 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/AST/PrettyPrinter.h
include/clang/AST/Type.h
lib/AST/DeclPrinter.cpp
lib/AST/TypePrinter.cpp
test/Sema/ast-print.c