[clang] [HLSL] Disable implicit constructors for user-defined structs/classes (PR #194989)
Joshua Batista via cfe-commits
cfe-commits at lists.llvm.org
Fri May 1 13:09:56 PDT 2026
================
@@ -759,19 +759,40 @@ class CXXRecordDecl : public RecordDecl {
needsImplicitDefaultConstructor();
}
+ // Used by HLSL to determine if a record is a built-in implicit HLSL
+ // struct/class or a user-defined one. User-defined HLSL records cannot
+ // have ctors, dtors, or overloaded operators, while implicit built-in
+ // HLSL records such as resource classes can. It would be nice to use the
+ // isImplicit() methods to determine that, but this flag is not propagated
+ // to template-instanticated classes.
+ //
+ /// Determines whether this class has any user provided special members.
+ bool hasUserProvidedSpecialMembers() const {
+ return data().UserDeclaredSpecialMembers &
+ (SMF_MoveConstructor | SMF_MoveAssignment | SMF_Destructor |
----------------
bob80905 wrote:
You might consider `SMF_All & ~SMF_DefaultConstructor` instead of
`(SMF_MoveConstructor | SMF_MoveAssignment | SMF_Destructor | SMF_CopyAssignment | SMF_CopyConstructor)` as a simplification, if the intent here is to include everything except default constructors.
https://github.com/llvm/llvm-project/pull/194989
More information about the cfe-commits
mailing list