[cfe-commits] r98189 - /cfe/trunk/lib/AST/TypePrinter.cpp

John McCall rjmccall at apple.com
Wed Mar 10 13:05:46 PST 2010


Author: rjmccall
Date: Wed Mar 10 15:05:46 2010
New Revision: 98189

URL: http://llvm.org/viewvc/llvm-project?rev=98189&view=rev
Log:
Suppress the tag when printing an ElaboratedType if the language options
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.


Modified:
    cfe/trunk/lib/AST/TypePrinter.cpp

Modified: cfe/trunk/lib/AST/TypePrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=98189&r1=98188&r2=98189&view=diff
==============================================================================
--- cfe/trunk/lib/AST/TypePrinter.cpp (original)
+++ cfe/trunk/lib/AST/TypePrinter.cpp Wed Mar 10 15:05:46 2010
@@ -474,7 +474,12 @@
 
 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, 





More information about the cfe-commits mailing list