[clang] [HLSL] Disable implicit constructors for user-defined structs/classes (PR #194989)

Helena Kotas via cfe-commits cfe-commits at lists.llvm.org
Wed May 6 11:01:36 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 |
----------------
hekota wrote:

Good idea! We actually need to check for default constructors as well. I have simplified the condition.

https://github.com/llvm/llvm-project/pull/194989


More information about the cfe-commits mailing list