Introduce basic support for dependent types, type-dependent
expressions, and value-dependent expressions. This permits us to parse
some template definitions.

This is not a complete solution; we're missing type- and
value-dependent computations for most of the expression types, and
we're missing checks for dependent types and type-dependent
expressions throughout Sema.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60615 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index 303fc7e..5909c97 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -43,6 +43,10 @@
   delete this;  
 }
 
+void DependentSizedArrayType::Destroy(ASTContext& C) {
+  SizeExpr->Destroy(C);
+  delete this;
+}
 
 /// getArrayElementTypeNoTypeQual - If this is an array type, return the
 /// element type of the array, potentially with type qualifiers missing.
@@ -634,11 +638,12 @@
 
 /// isConstantSizeType - Return true if this is not a variable sized type,
 /// according to the rules of C99 6.7.5p3.  It is not legal to call this on
-/// incomplete types.
+/// incomplete types or dependent types.
 bool Type::isConstantSizeType() const {
   if (const ASQualType *ASQT = dyn_cast<ASQualType>(CanonicalType))
     return ASQT->getBaseType()->isConstantSizeType();
   assert(!isIncompleteType() && "This doesn't make sense for incomplete types");
+  assert(!isDependentType() && "This doesn't make sense for dependent types");
   // The VAT must have a size, as it is known to be complete.
   return !isa<VariableArrayType>(CanonicalType);
 }
@@ -706,6 +711,7 @@
   case LongDouble:        return "long double";
   case WChar:             return "wchar_t";
   case Overload:          return "<overloaded function type>";
+  case Dependent:         return "<dependent type>";
   }
 }
 
@@ -780,6 +786,11 @@
   }
 }
 
+TypeOfExpr::TypeOfExpr(Expr *E, QualType can)
+  : Type(TypeOfExp, can, E->isTypeDependent()), TOExpr(E) {
+  assert(!isa<TypedefType>(can) && "Invalid canonical type");
+}
+
 bool RecordType::classof(const TagType *TT) {
   return isa<RecordDecl>(TT->getDecl());
 }
@@ -932,6 +943,30 @@
   getElementType().getAsStringInternal(S);
 }
 
+void DependentSizedArrayType::getAsStringInternal(std::string &S) const {
+  S += '[';
+  
+  if (getIndexTypeQualifier()) {
+    AppendTypeQualList(S, getIndexTypeQualifier());
+    S += ' ';
+  }
+  
+  if (getSizeModifier() == Static)
+    S += "static";
+  else if (getSizeModifier() == Star)
+    S += '*';
+  
+  if (getSizeExpr()) {
+    std::string SStr;
+    llvm::raw_string_ostream s(SStr);
+    getSizeExpr()->printPretty(s);
+    S += s.str();
+  }
+  S += ']';
+  
+  getElementType().getAsStringInternal(S);
+}
+
 void VectorType::getAsStringInternal(std::string &S) const {
   // FIXME: We prefer to print the size directly here, but have no way
   // to get the size of the type.