Fix pretty-printing for unnamed unions.

This is just a couple of minor fixes to account for the existence
of ElaboratedType.

llvm-svn: 188209
This commit is contained in:
Eli Friedman 2013-08-12 21:54:04 +00:00
parent e2358c1deb
commit 24b3fed69f
3 changed files with 15 additions and 0 deletions

View File

@ -260,6 +260,8 @@ void DeclPrinter::VisitDeclContext(DeclContext *DC, bool Indent) {
QualType CurDeclType = getDeclType(*D);
if (!Decls.empty() && !CurDeclType.isNull()) {
QualType BaseType = GetBaseType(CurDeclType);
if (!BaseType.isNull() && isa<ElaboratedType>(BaseType))
BaseType = cast<ElaboratedType>(BaseType)->getNamedType();
if (!BaseType.isNull() && isa<TagType>(BaseType) &&
cast<TagType>(BaseType)->getDecl() == Decls[0]) {
Decls.push_back(*D);

View File

@ -1003,6 +1003,8 @@ void TypePrinter::printInjectedClassNameAfter(const InjectedClassNameType *T,
void TypePrinter::printElaboratedBefore(const ElaboratedType *T,
raw_ostream &OS) {
if (Policy.SuppressTag && isa<TagType>(T->getNamedType()))
return;
OS << TypeWithKeyword::getKeywordName(T->getKeyword());
if (T->getKeyword() != ETK_None)
OS << " ";

View File

@ -153,3 +153,14 @@ void test13() {
__c11_atomic_load(&i, 0);
}
// CHECK: void test14() {
// CHECK: struct X {
// CHECK: union {
// CHECK: int x;
// CHECK: } x;
// CHECK: };
// CHECK: }
void test14() {
struct X { union { int x; } x; };
}