aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Type.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2009-09-05 06:31:47 +0000
committerJohn McCall <rjmccall@apple.com>2009-09-05 06:31:47 +0000
commit2191b20bfb31fc0e22a158f6b4204cd0b7dbd0fd (patch)
treef83185278453f6702e0ebee829f34e2cd58b6a4f /lib/AST/Type.cpp
parenta2f4ec0df645fc249d2945beef9653f03b175417 (diff)
Start emitting ElaboratedTypes in C++ mode. Support the effort in various
ways: remove elab types during desugaring, enhance pretty-printing to allow tags to be suppressed without suppressing scopes, look through elab types when associating a typedef name with an anonymous record type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81065 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Type.cpp')
-rw-r--r--lib/AST/Type.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index f4dad13f41..9bcfb2ad8f 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -143,6 +143,8 @@ QualType QualType::getDesugaredType(bool ForDisplay) const {
QualType Type::getDesugaredType(bool ForDisplay) const {
if (const TypedefType *TDT = dyn_cast<TypedefType>(this))
return TDT->LookThroughTypedefs().getDesugaredType();
+ if (const ElaboratedType *ET = dyn_cast<ElaboratedType>(this))
+ return ET->getUnderlyingType().getDesugaredType();
if (const TypeOfExprType *TOE = dyn_cast<TypeOfExprType>(this))
return TOE->getUnderlyingExpr()->getType().getDesugaredType();
if (const TypeOfType *TOT = dyn_cast<TypeOfType>(this))
@@ -1575,6 +1577,7 @@ void QualifiedNameType::getAsStringInternal(std::string &InnerString, const Prin
std::string TypeStr;
PrintingPolicy InnerPolicy(Policy);
InnerPolicy.SuppressTagKind = true;
+ InnerPolicy.SuppressScope = true;
NamedType.getAsStringInternal(TypeStr, InnerPolicy);
MyString += TypeStr;
@@ -1715,7 +1718,7 @@ void TagType::getAsStringInternal(std::string &InnerString, const PrintingPolicy
InnerString = TemplateArgsStr + InnerString;
}
- if (Kind) {
+ if (!Policy.SuppressScope) {
// Compute the full nested-name-specifier for this type. In C,
// this will always be empty.
std::string ContextStr;
@@ -1745,7 +1748,10 @@ void TagType::getAsStringInternal(std::string &InnerString, const PrintingPolicy
ContextStr = MyPart + "::" + ContextStr;
}
- InnerString = std::string(Kind) + " " + ContextStr + ID + InnerString;
+ if (Kind)
+ InnerString = std::string(Kind) + ' ' + ContextStr + ID + InnerString;
+ else
+ InnerString = ContextStr + ID + InnerString;
} else
InnerString = ID + InnerString;
}