From: Argyrios Kyrtzidis Date: Fri, 7 Nov 2008 14:22:23 +0000 (+0000) Subject: Properly deserialize ParamInfo of FunctionDecl. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dc5ddbf7de0862ebc4aef9c60be953ca80a62ff2;p=clang Properly deserialize ParamInfo of FunctionDecl. When allocating an array for ParamInfo, the "decl->getNumParams()" call was used, but this will return 0 since it checks ParamInfo (which isn't yet defined and is null). The result was that ParamInfo got an array of zero length to hold the ParmVarDecls. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58850 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/DeclSerialization.cpp b/lib/AST/DeclSerialization.cpp index f2aa3f3027..34066a5039 100644 --- a/lib/AST/DeclSerialization.cpp +++ b/lib/AST/DeclSerialization.cpp @@ -402,6 +402,7 @@ void FunctionDecl::EmitImpl(Serializer& S) const { if (ParamInfo != NULL) { S.EmitBool(true); + S.EmitInt(getNumParams()); S.BatchEmitOwnedPtrs(getNumParams(),&ParamInfo[0], Body, getNextDeclarator()); } @@ -425,14 +426,17 @@ FunctionDecl* FunctionDecl::CreateImpl(Deserializer& D, ASTContext& C) { Decl* next_declarator; + int numParams; bool hasParamDecls = D.ReadBool(); + if (hasParamDecls) + numParams = D.ReadInt(); decl->ParamInfo = hasParamDecls - ? new ParmVarDecl*[decl->getNumParams()] + ? new ParmVarDecl*[numParams] : NULL; if (hasParamDecls) - D.BatchReadOwnedPtrs(decl->getNumParams(), + D.BatchReadOwnedPtrs(numParams, reinterpret_cast(&decl->ParamInfo[0]), decl->Body, next_declarator, C); else