[clang] [PATCH] [clang][frontend] Fix AllocKind retrieving for `CXXConstructorDecl` refs #132794 (PR #133077)
Paul Schwabauer via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 26 06:29:59 PDT 2025
https://github.com/koplas created https://github.com/llvm/llvm-project/pull/133077
When getting the `ExplicitSpecifier` of the `CXXConstructorDecl`, one of the canonical declaration is returned. When writing the declaration record with `ExplicitSpecifier`, the `AllocKind` of the canonical declaration has to be used.
If this is not done, it will later crash when on deserialization.
TODO: Add reduced test from #132794.
>From 98e6c674244099fd15e13026081caac9102f7c3d Mon Sep 17 00:00:00 2001
From: koplas <paul at schwabauer.co>
Date: Wed, 26 Mar 2025 13:49:44 +0100
Subject: [PATCH] [PATCH] [clang][frontend] Fix AllocKind retrieving for
`CXXConstructorDecl` refs #132794
When getting the `ExplicitSpecifier` of the `CXXConstructorDecl`, one
of the canonical declaration is returned. When writing the declaration
record with `ExplicitSpecifier`, the `AllocKind` of the canonical
declaration has to be used.
If this is not done it will later crash when on deserialization.
---
clang/include/clang/AST/DeclCXX.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h
index dbd02ef7f8011..eaa9d9c526000 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -2601,10 +2601,10 @@ class CXXConstructorDecl final
void anchor() override;
size_t numTrailingObjects(OverloadToken<InheritedConstructor>) const {
- return CXXConstructorDeclBits.IsInheritingConstructor;
+ return getCanonicalDecl()->CXXConstructorDeclBits.IsInheritingConstructor;
}
size_t numTrailingObjects(OverloadToken<ExplicitSpecifier>) const {
- return CXXConstructorDeclBits.HasTrailingExplicitSpecifier;
+ return getCanonicalDecl()->CXXConstructorDeclBits.HasTrailingExplicitSpecifier;
}
ExplicitSpecifier getExplicitSpecifierInternal() const {
More information about the cfe-commits
mailing list