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
diff --git a/lib/AST/NestedNameSpecifier.cpp b/lib/AST/NestedNameSpecifier.cpp
index 0c24c89..24fb752 100644
--- a/lib/AST/NestedNameSpecifier.cpp
+++ b/lib/AST/NestedNameSpecifier.cpp
@@ -143,6 +143,7 @@
 
     PrintingPolicy InnerPolicy(Policy);
     InnerPolicy.SuppressTagKind = true;
+    InnerPolicy.SuppressScope = true;
     
     // Nested-name-specifiers are intended to contain minimally-qualified
     // types. An actual QualifiedNameType will not occur, since we'll store
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index f4dad13..9bcfb2a 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -143,6 +143,8 @@
 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 @@
   std::string TypeStr;
   PrintingPolicy InnerPolicy(Policy);
   InnerPolicy.SuppressTagKind = true;
+  InnerPolicy.SuppressScope = true;
   NamedType.getAsStringInternal(TypeStr, InnerPolicy);
 
   MyString += TypeStr;
@@ -1715,7 +1718,7 @@
     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 @@
         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;
 }