diff options
| author | Ted Kremenek <kremenek@apple.com> | 2007-11-13 22:51:08 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2007-11-13 22:51:08 +0000 |
| commit | d86dcfe8caa1b1cacc98bb0c2084081c351627d1 (patch) | |
| tree | 9e5c9630ca7c151f24e0f10fe26711d934a7468f /clang/AST/DeclSerialization.cpp | |
| parent | da551c3b1e68d989ebd56068eba8c8e8e28d74e4 (diff) | |
| download | bcm5719-llvm-d86dcfe8caa1b1cacc98bb0c2084081c351627d1.tar.gz bcm5719-llvm-d86dcfe8caa1b1cacc98bb0c2084081c351627d1.zip | |
Fixed bug in FunctionDecl serialization where we crashed when the
FunctionDecl had decls for its parameters but still had greater than 0
arguments.
llvm-svn: 44076
Diffstat (limited to 'clang/AST/DeclSerialization.cpp')
| -rw-r--r-- | clang/AST/DeclSerialization.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/clang/AST/DeclSerialization.cpp b/clang/AST/DeclSerialization.cpp index 71706e3e518..b881cbe5b50 100644 --- a/clang/AST/DeclSerialization.cpp +++ b/clang/AST/DeclSerialization.cpp @@ -226,9 +226,15 @@ void FunctionDecl::EmitImpl(Serializer& S) const { // NOTE: We do not need to serialize out the number of parameters, because // that is encoded in the type (accessed via getNumParams()). - S.BatchEmitOwnedPtrs(getNumParams(),&ParamInfo[0], // From FunctionDecl. - Body, // From FunctionDecl. - getNextDeclarator()); // From ScopedDecl. + if (ParamInfo != NULL) { + S.EmitBool(true); + S.BatchEmitOwnedPtrs(getNumParams(),&ParamInfo[0], Body, + getNextDeclarator()); + } + else { + S.EmitBool(false); + S.BatchEmitOwnedPtrs(Body,getNextDeclarator()); + } } FunctionDecl* FunctionDecl::CreateImpl(Deserializer& D) { @@ -247,10 +253,14 @@ FunctionDecl* FunctionDecl::CreateImpl(Deserializer& D) { Decl* next_declarator; - D.BatchReadOwnedPtrs(decl->getNumParams(), - reinterpret_cast<Decl**>(&decl->ParamInfo[0]), // FunctionDecl. - decl->Body, // From FunctionDecl. - next_declarator); // From ScopedDecl. + bool hasParamDecls = D.ReadBool(); + + if (hasParamDecls) + D.BatchReadOwnedPtrs(decl->getNumParams(), + reinterpret_cast<Decl**>(&decl->ParamInfo[0]), + decl->Body, next_declarator); + else + D.BatchReadOwnedPtrs(decl->Body, next_declarator); decl->setNextDeclarator(cast_or_null<ScopedDecl>(next_declarator)); |

