From: Argyrios Kyrtzidis Date: Wed, 30 Jun 2010 08:49:25 +0000 (+0000) Subject: Support DependentSizedArrayType for PCH. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ae8b17f1d5d303af53db5a4f4a375ea6b9356566;p=clang 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 fec40c825d..9bb537a490 100644 --- a/include/clang/Frontend/PCHBitCodes.h +++ b/include/clang/Frontend/PCHBitCodes.h @@ -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 diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index a526fd6dc5..b5ddc86369 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -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; diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp index d947f7250d..41815314d7 100644 --- a/lib/Frontend/PCHWriter.cpp +++ b/lib/Frontend/PCHWriter.cpp @@ -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 diff --git a/test/PCH/cxx-templates.h b/test/PCH/cxx-templates.h index bfc0def146..c089e1c5a9 100644 --- a/test/PCH/cxx-templates.h +++ b/test/PCH/cxx-templates.h @@ -22,6 +22,7 @@ template T templ_f(T x) { int z = templ_f(3); z = tmpl_f2(); + T data[y]; return x+y; }