@@ -6092,14 +6092,12 @@ void ASTWriter::WriteDeclUpdatesBlocks(ASTContext &Context,
60926092
60936093 // An updated body is emitted last, so that the reader doesn't need
60946094 // to skip over the lazy body to reach statements for other records.
6095- if (Kind == UPD_CXX_ADDED_FUNCTION_DEFINITION) {
6096- assert (isa<FunctionDecl>(D) && " expected FunctionDecl" );
6097- HasUpdatedBody = cast<FunctionDecl>(D)->hasBody ();
6098- } else if (Kind == UPD_CXX_ADDED_VAR_DEFINITION) {
6095+ if (Kind == UPD_CXX_ADDED_FUNCTION_DEFINITION)
6096+ HasUpdatedBody = true ;
6097+ else if (Kind == UPD_CXX_ADDED_VAR_DEFINITION)
60996098 HasAddedVarDefinition = true ;
6100- } else {
6099+ else
61016100 Record.push_back (Kind);
6102- }
61036101
61046102 switch (Kind) {
61056103 case UPD_CXX_ADDED_IMPLICIT_MEMBER:
@@ -7232,6 +7230,9 @@ void ASTWriter::CompletedImplicitDefinition(const FunctionDecl *D) {
72327230 if (!D->isFromASTFile ())
72337231 return ; // Declaration not imported from PCH.
72347232
7233+ if (!D->doesThisDeclarationHaveABody ())
7234+ return ; // The function definition may not have a body due to parsing errors.
7235+
72357236 // Implicit function decl from a PCH was defined.
72367237 DeclUpdates[D].push_back (DeclUpdate (UPD_CXX_ADDED_FUNCTION_DEFINITION));
72377238}
@@ -7250,6 +7251,8 @@ void ASTWriter::FunctionDefinitionInstantiated(const FunctionDecl *D) {
72507251 assert (!WritingAST && " Already writing the AST!" );
72517252 if (!D->isFromASTFile ())
72527253 return ;
7254+ if (!D->doesThisDeclarationHaveABody ())
7255+ return ; // The function definition may not have a body due to parsing errors.
72537256
72547257 DeclUpdates[D].push_back (DeclUpdate (UPD_CXX_ADDED_FUNCTION_DEFINITION));
72557258}
0 commit comments