]> granicus.if.org Git - clang/commitdiff
Support DependentSizedArrayType for PCH.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 30 Jun 2010 08:49:25 +0000 (08:49 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 30 Jun 2010 08:49:25 +0000 (08:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107267 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Frontend/PCHBitCodes.h
lib/Frontend/PCHReader.cpp
lib/Frontend/PCHWriter.cpp
test/PCH/cxx-templates.h

index fec40c825daa317dfc3e051606fd33c035f6c437..9bb537a4908cc3c23ab139e440eedf9568fb7854 100644 (file)
@@ -425,7 +425,9 @@ namespace clang {
       /// \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
index a526fd6dc5c76e9994a4bbddeb0b3c162929e237..b5ddc86369dc21a573a0b917fb087e9b05148d8f 100644 (file)
@@ -2226,6 +2226,23 @@ QualType PCHReader::ReadTypeRecord(uint64_t Offset) {
     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;
index d947f7250d2a44105f278ddff6af6e6ef97b0ea1..41815314d791441fa6dc9509639d493af493f503 100644 (file)
@@ -230,8 +230,10 @@ PCHTypeWriter::VisitTemplateSpecializationType(
 
 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
index bfc0def146a371ac7bf688bb032493985ae20620..c089e1c5a9bcef7613849dc39c0d2a07f28e52bd 100644 (file)
@@ -22,6 +22,7 @@ template <typename T, int y>
 T templ_f(T x) {
   int z = templ_f<int, 5>(3);
   z = tmpl_f2<y+2>();
+  T data[y];
   return x+y;
 }