[all-commits] [llvm/llvm-project] 8ba6fb: [HLSL] Disable implicit constructors for user-defi...

Helena Kotas via All-commits all-commits at lists.llvm.org
Sat Jun 13 12:07:00 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8ba6fb1bf23748d58224db9df5b0ee7ddd257055
      https://github.com/llvm/llvm-project/commit/8ba6fb1bf23748d58224db9df5b0ee7ddd257055
  Author: Helena Kotas <hekotas at microsoft.com>
  Date:   2026-06-13 (Sat, 13 Jun 2026)

  Changed paths:
    M clang/include/clang/AST/CXXRecordDeclDefinitionBits.def
    M clang/include/clang/AST/DeclCXX.h
    M clang/include/clang/AST/TypeBase.h
    M clang/include/clang/Sema/SemaHLSL.h
    M clang/lib/AST/DeclCXX.cpp
    M clang/lib/AST/Expr.cpp
    M clang/lib/AST/Type.cpp
    M clang/lib/CodeGen/CGExprAgg.cpp
    M clang/lib/CodeGen/CGHLSLRuntime.cpp
    M clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.cpp
    M clang/lib/Sema/SemaExpr.cpp
    M clang/lib/Sema/SemaHLSL.cpp
    M clang/lib/Sema/SemaInit.cpp
    M clang/lib/Sema/SemaOverload.cpp
    M clang/lib/Sema/SemaTemplateInstantiate.cpp
    M clang/test/AST/HLSL/ConstantBuffers-AST-error.hlsl
    A clang/test/AST/HLSL/StructPassing-AST.hlsl
    M clang/test/AST/HLSL/cbuffer.hlsl
    M clang/test/AST/HLSL/matrix-constructors.hlsl
    M clang/test/AST/HLSL/semantic-output-struct-shadow.hlsl
    M clang/test/AST/HLSL/semantic-output-struct.hlsl
    M clang/test/CodeGenHLSL/BasicFeatures/ArrayElementwiseCast.hlsl
    M clang/test/CodeGenHLSL/BasicFeatures/InitLists.hlsl
    M clang/test/CodeGenHLSL/BasicFeatures/MatrixElementTypeCast.hlsl
    M clang/test/CodeGenHLSL/BasicFeatures/StructElementwiseCast.hlsl
    A clang/test/CodeGenHLSL/BasicFeatures/StructPassing.hlsl
    M clang/test/CodeGenHLSL/BasicFeatures/VectorElementwiseCast.hlsl
    M clang/test/CodeGenHLSL/builtins/hlsl_resource_t.hlsl
    M clang/test/CodeGenHLSL/cbuffer_copy_layout.hlsl
    M clang/test/CodeGenHLSL/resources/StructuredBuffers-subscripts.hlsl
    M clang/test/CodeGenHLSL/resources/cbuffer_struct_passing.hlsl
    M clang/test/CodeGenHLSL/resources/resources-in-structs.hlsl
    M clang/test/CodeGenHLSL/semantics/semantic-struct-2-output.hlsl
    M clang/test/CodeGenHLSL/this-assignment-overload.hlsl
    M clang/test/CodeGenHLSL/this-assignment.hlsl
    M clang/test/SemaHLSL/BuiltIns/WaveActiveAllTrue-errors.hlsl
    M clang/test/SemaHLSL/BuiltIns/WaveActiveAnyTrue-errors.hlsl
    M clang/test/SemaHLSL/BuiltIns/WaveActiveBallot-errors.hlsl
    M clang/test/SemaHLSL/BuiltIns/WaveActiveCountBits-errors.hlsl
    M clang/test/SemaHLSL/BuiltIns/dot4add_i8packed-errors.hlsl
    M clang/test/SemaHLSL/BuiltIns/dot4add_u8packed-errors.hlsl
    M clang/test/SemaHLSL/Language/AggregateSplatCast-errors.hlsl
    M clang/test/SemaHLSL/Language/ElementwiseCast-errors.hlsl
    M clang/test/SemaHLSL/Language/ElementwiseCasts.hlsl
    M clang/test/SemaHLSL/Language/InitListAST.hlsl
    M clang/test/SemaHLSL/Language/InitLists.hlsl
    M clang/test/SemaHLSL/Resources/ConstantBuffers.hlsl
    M clang/test/SemaHLSL/prohibit_pointer.hlsl

  Log Message:
  -----------
  [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



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list