[clang] [PATCH] [clang][frontend] Fix AllocKind retrieving for `CXXConstructorDecl` refs #132794 (PR #133077)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 26 13:17:18 PDT 2025
================
@@ -2601,10 +2601,11 @@ 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;
----------------
cor3ntin wrote:
This change does not look quite correct.
Indeed `numTrailingObjects` is an internal detail of the object that should preserve its invariants. i.e, it is exactly whether an explicit specifier is **stored** as a trailing object of this object.
However, you are most probably on the right path.
In `ASTWriterDecl`, `addExplicitSpecifier(D->getExplicitSpecifier(), Record);` does indeed look incorrect. Because again, we are trying to serialize that object - not parts that are stored in an other canonicl decl.
I think the solution might be as simple as replacing that line with `addExplicitSpecifier(D->getExplicitSpecifierInternal(), Record);` (`getExplicitSpecifierInternal()` does not call `getCanonicalDecl()`)
https://github.com/llvm/llvm-project/pull/133077
More information about the cfe-commits
mailing list