]> granicus.if.org Git - clang/commitdiff
Suppress the tag when printing an ElaboratedType if the language options
authorJohn McCall <rjmccall@apple.com>
Wed, 10 Mar 2010 21:05:46 +0000 (21:05 +0000)
committerJohn McCall <rjmccall@apple.com>
Wed, 10 Mar 2010 21:05:46 +0000 (21:05 +0000)
claim this is C.  We don't make ElaboratedTypes in C, but sometimes
the language options during pretty-print lie to us.

The rewriter should really be fixed to not rely on how types are pretty-printed,
though.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98189 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/TypePrinter.cpp

index 037bc14e7a9199ce5dedb5993ea1a4b9324f9abd..09a61736d27e06fdd0a5acbe1122383e5937f249 100644 (file)
@@ -474,7 +474,12 @@ void TypePrinter::PrintEnum(const EnumType *T, std::string &S) {
 
 void TypePrinter::PrintElaborated(const ElaboratedType *T, std::string &S) { 
   Print(T->getUnderlyingType(), S);
-  S = std::string(T->getNameForTagKind(T->getTagKind())) + ' ' + S;  
+
+  // We don't actually make these in C, but the language options
+  // sometimes lie to us -- for example, if someone calls
+  // QualType::getAsString().  Just suppress the redundant tag if so.
+  if (Policy.LangOpts.CPlusPlus)
+    S = std::string(T->getNameForTagKind(T->getTagKind())) + ' ' + S;  
 }
 
 void TypePrinter::PrintTemplateTypeParm(const TemplateTypeParmType *T,