]> granicus.if.org Git - clang/commitdiff
Properly deserialize ParamInfo of FunctionDecl.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 7 Nov 2008 14:22:23 +0000 (14:22 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 7 Nov 2008 14:22:23 +0000 (14:22 +0000)
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

lib/AST/DeclSerialization.cpp

index f2aa3f30276c72f3975226e63f96748606e92b4c..34066a5039d57373960bc80a11d2259ed3d13785 100644 (file)
@@ -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**>(&decl->ParamInfo[0]),
                          decl->Body, next_declarator, C);
   else