================ @@ -6227,8 +6227,10 @@ void ASTWriter::WriteDeclUpdatesBlocks(ASTContext &Context, // Add a trailing update record, if any. These must go last because we // lazily load their attached statement. if (!GeneratingReducedBMI || !CanElideDeclDef(D)) { - if (HasUpdatedBody) { - const auto *Def = cast<FunctionDecl>(D); + assert(!(HasUpdatedBody && HasAddedVarDefinition) && + "Declaration can not be both a FunctionDecl and a VarDecl"); + if (const auto *Def = dyn_cast<FunctionDecl>(D); + HasUpdatedBody && Def->doesThisDeclarationHaveABody()) { ---------------- ChuanqiXu9 wrote:
Logically, it looks better to not set `HasUpdatedBody` if the declaration doesn't have a body. https://github.com/llvm/llvm-project/pull/121550 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits