Support DependentSizedArrayType for PCH.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107267 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Frontend/PCHBitCodes.h b/include/clang/Frontend/PCHBitCodes.h
index fec40c8..9bb537a 100644
--- a/include/clang/Frontend/PCHBitCodes.h
+++ b/include/clang/Frontend/PCHBitCodes.h
@@ -425,7 +425,9 @@
       /// \brief A DependentNameType record.
       TYPE_DEPENDENT_NAME           = 31,
       /// \brief A DependentTemplateSpecializationType record.
-      TYPE_DEPENDENT_TEMPLATE_SPECIALIZATION = 32
+      TYPE_DEPENDENT_TEMPLATE_SPECIALIZATION = 32,
+      /// \brief A DependentSizedArrayType record.
+      TYPE_DEPENDENT_SIZED_ARRAY    = 33
     };
 
     /// \brief The type IDs for special types constructed by semantic
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp
index a526fd6..b5ddc86 100644
--- a/lib/Frontend/PCHReader.cpp
+++ b/lib/Frontend/PCHReader.cpp
@@ -2226,6 +2226,23 @@
     return Context->getDependentTemplateSpecializationType(Keyword, NNS, Name,
                                                       Args.size(), Args.data());
   }
+  
+  case pch::TYPE_DEPENDENT_SIZED_ARRAY: {
+    unsigned Idx = 0;
+
+    // ArrayType
+    QualType ElementType = GetType(Record[Idx++]);
+    ArrayType::ArraySizeModifier ASM
+      = (ArrayType::ArraySizeModifier)Record[Idx++];
+    unsigned IndexTypeQuals = Record[Idx++];
+
+    // DependentSizedArrayType
+    Expr *NumElts = ReadExpr();
+    SourceRange Brackets = ReadSourceRange(Record, Idx);
+
+    return Context->getDependentSizedArrayType(ElementType, NumElts, ASM,
+                                               IndexTypeQuals, Brackets);
+  }
 
   case pch::TYPE_TEMPLATE_SPECIALIZATION: {
     unsigned Idx = 0;
diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp
index d947f72..4181531 100644
--- a/lib/Frontend/PCHWriter.cpp
+++ b/lib/Frontend/PCHWriter.cpp
@@ -230,8 +230,10 @@
 
 void
 PCHTypeWriter::VisitDependentSizedArrayType(const DependentSizedArrayType *T) {
-  // FIXME: Serialize this type (C++ only)
-  assert(false && "Cannot serialize dependent sized array types");
+  VisitArrayType(T);
+  Writer.AddStmt(T->getSizeExpr());
+  Writer.AddSourceRange(T->getBracketsRange(), Record);
+  Code = pch::TYPE_DEPENDENT_SIZED_ARRAY;
 }
 
 void
diff --git a/test/PCH/cxx-templates.h b/test/PCH/cxx-templates.h
index bfc0def..c089e1c 100644
--- a/test/PCH/cxx-templates.h
+++ b/test/PCH/cxx-templates.h
@@ -22,6 +22,7 @@
 T templ_f(T x) {
   int z = templ_f<int, 5>(3);
   z = tmpl_f2<y+2>();
+  T data[y];
   return x+y;
 }