aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/TypePrinter.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-03-10 21:05:46 +0000
committerJohn McCall <rjmccall@apple.com>2010-03-10 21:05:46 +0000
commit327fb2d32243e1206b69c5f05d4fa2e3d89a0dcb (patch)
tree25ac6219f5f5e68729d04d902a37616854fb50b7 /lib/AST/TypePrinter.cpp
parenta96a2e961a3bce0ad2fc44a115ac949a481d42db (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98189 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/TypePrinter.cpp')
-rw-r--r--lib/AST/TypePrinter.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/AST/TypePrinter.cpp b/lib/AST/TypePrinter.cpp
index 037bc14e7a..09a61736d2 100644
--- a/lib/AST/TypePrinter.cpp
+++ b/lib/AST/TypePrinter.cpp
@@ -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,