[clang] [clang] Do not serialize function definitions without a body (PR #121550)
Alejandro Álvarez Ayllón via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 6 00:19:29 PST 2025
================
@@ -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()) {
----------------
alejandro-alvarez-sonarsource wrote:
Changed as suggested.
https://github.com/llvm/llvm-project/pull/121550
More information about the cfe-commits
mailing list