Add a DecltypeType type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74099 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index 7b45b21..9894adf 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -1052,6 +1052,11 @@
   assert(!isa<TypedefType>(can) && "Invalid canonical type");
 }
 
+DecltypeType::DecltypeType(Expr *E, QualType can)
+  : Type(Decltype, can, E->isTypeDependent()), E(E) {
+  assert(!isa<TypedefType>(can) && "Invalid canonical type");
+}
+
 TagType::TagType(TypeClass TC, TagDecl *D, QualType can) 
   : Type(TC, can, D->isDependentType()), decl(D, 0) {}
 
@@ -1421,6 +1426,16 @@
   InnerString = "typeof(" + Tmp + ")" + InnerString;
 }
 
+void DecltypeType::getAsStringInternal(std::string &InnerString, 
+                                       const PrintingPolicy &Policy) const {
+  if (!InnerString.empty())    // Prefix the basic type, e.g. 'decltype(t) X'.
+    InnerString = ' ' + InnerString;
+  std::string Str;
+  llvm::raw_string_ostream s(Str);
+  getUnderlyingExpr()->printPretty(s, 0, Policy);
+  InnerString = "decltype(" + s.str() + ")" + InnerString;
+}
+
 void FunctionNoProtoType::getAsStringInternal(std::string &S, const PrintingPolicy &Policy) const {
   // If needed for precedence reasons, wrap the inner part in grouping parens.
   if (!S.empty())