aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/DeclSerialization.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2008-11-07 14:22:23 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2008-11-07 14:22:23 +0000
commitdc5ddbf7de0862ebc4aef9c60be953ca80a62ff2 (patch)
tree648869598256d8d7d826b86ac173763896b14dcb /lib/AST/DeclSerialization.cpp
parentff6ec3903630fa3b97477cf3474b55170eab0164 (diff)
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
Diffstat (limited to 'lib/AST/DeclSerialization.cpp')
-rw-r--r--lib/AST/DeclSerialization.cpp8
1 files changed, 6 insertions, 2 deletions
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**>(&decl->ParamInfo[0]),
decl->Body, next_declarator, C);
else