llvm-project
8ba6fb1b - [HLSL] Disable implicit constructors for user-defined structs/classes (#194989)

Commit
60 days ago
[HLSL] Disable implicit constructors for user-defined structs/classes (#194989) Disables implicit constructors and assignment operators on user-defined structs/classes in HLSL. When a struct is copied or passed as an argument to a function, instead of using copy constructor the compiler inserts an implicit _lvalue_-to-_rvalue_ cast where necessary to copy the value. In C++ these implicit casts are not allowed. Sema initialization and overloading code has been adjusted to enable this code path for HLSL. For struct in a constant buffer, the implicit cast changes the constant address space to the default one. Codegen recognized this pattern and instead of translating the copy as `memcpy`, it copies the struct element-by-element (because the constant address space struct can have a different layout). To efficiently recognize whether a `CXXRecordDecl` is a user-defined struct/class or if it is an HLSL built-in struct/class, a new bit `IsHLSLBuiltinRecord` has been added to the `CXXRecordDecl` definition data. This property is set for struct/classes created in `HLSLExternalSemaSource`. Part of #185466 Fixes #153055
Author
Parents
Loading