@@ -6092,14 +6092,12 @@ void ASTWriter::WriteDeclUpdatesBlocks(ASTContext &Context,
6092
6092
6093
6093
// An updated body is emitted last, so that the reader doesn't need
6094
6094
// 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)
6099
6098
HasAddedVarDefinition = true ;
6100
- } else {
6099
+ else
6101
6100
Record.push_back (Kind);
6102
- }
6103
6101
6104
6102
switch (Kind) {
6105
6103
case UPD_CXX_ADDED_IMPLICIT_MEMBER:
@@ -7232,6 +7230,9 @@ void ASTWriter::CompletedImplicitDefinition(const FunctionDecl *D) {
7232
7230
if (!D->isFromASTFile ())
7233
7231
return ; // Declaration not imported from PCH.
7234
7232
7233
+ if (!D->doesThisDeclarationHaveABody ())
7234
+ return ; // The function definition may not have a body due to parsing errors.
7235
+
7235
7236
// Implicit function decl from a PCH was defined.
7236
7237
DeclUpdates[D].push_back (DeclUpdate (UPD_CXX_ADDED_FUNCTION_DEFINITION));
7237
7238
}
@@ -7250,6 +7251,8 @@ void ASTWriter::FunctionDefinitionInstantiated(const FunctionDecl *D) {
7250
7251
assert (!WritingAST && " Already writing the AST!" );
7251
7252
if (!D->isFromASTFile ())
7252
7253
return ;
7254
+ if (!D->doesThisDeclarationHaveABody ())
7255
+ return ; // The function definition may not have a body due to parsing errors.
7253
7256
7254
7257
DeclUpdates[D].push_back (DeclUpdate (UPD_CXX_ADDED_FUNCTION_DEFINITION));
7255
7258
}
0 commit comments