Skip to content

Commit 66000be

Browse files
committed
Merge from 'main' to 'sycl-web' (48 commits)
CONFLICT (content): Merge conflict in clang/test/Driver/HLSL/metal-converter.hlsl CONFLICT (content): Merge conflict in clang/test/Driver/dxc_dxv_path.hlsl
2 parents aa0479b + b7b501e commit 66000be

File tree

151 files changed

+3363
-1511
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+3363
-1511
lines changed

clang-tools-extra/clang-tidy/bugprone/InvalidEnumDefaultInitializationCheck.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ bool isCompleteAndHasNoZeroValue(const EnumDecl *D) {
2222
const EnumDecl *Definition = D->getDefinition();
2323
return Definition && Definition->isComplete() &&
2424
!Definition->enumerators().empty() &&
25-
std::none_of(Definition->enumerator_begin(),
26-
Definition->enumerator_end(),
27-
[](const EnumConstantDecl *Value) {
28-
return Value->getInitVal().isZero();
29-
});
25+
llvm::none_of(Definition->enumerators(),
26+
[](const EnumConstantDecl *Value) {
27+
return Value->getInitVal().isZero();
28+
});
3029
}
3130

3231
AST_MATCHER(EnumDecl, isCompleteAndHasNoZeroValue) {

clang-tools-extra/clang-tidy/bugprone/NonZeroEnumToBoolConversionCheck.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ namespace {
2222
AST_MATCHER(EnumDecl, isCompleteAndHasNoZeroValue) {
2323
const EnumDecl *Definition = Node.getDefinition();
2424
return Definition && Node.isComplete() &&
25-
std::none_of(Definition->enumerator_begin(),
26-
Definition->enumerator_end(),
27-
[](const EnumConstantDecl *Value) {
28-
return Value->getInitVal().isZero();
29-
});
25+
llvm::none_of(Definition->enumerators(),
26+
[](const EnumConstantDecl *Value) {
27+
return Value->getInitVal().isZero();
28+
});
3029
}
3130

3231
} // namespace

clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,10 @@ RenamerClangTidyCheck::addUsage(
432432
if (FixLocation.isInvalid())
433433
return {NamingCheckFailures.end(), false};
434434

435+
// Skip if in system system header
436+
if (SourceMgr.isInSystemHeader(FixLocation))
437+
return {NamingCheckFailures.end(), false};
438+
435439
auto EmplaceResult = NamingCheckFailures.try_emplace(FailureId);
436440
NamingCheckFailure &Failure = EmplaceResult.first->second;
437441

@@ -455,6 +459,9 @@ RenamerClangTidyCheck::addUsage(
455459
void RenamerClangTidyCheck::addUsage(const NamedDecl *Decl,
456460
SourceRange UsageRange,
457461
const SourceManager &SourceMgr) {
462+
if (SourceMgr.isInSystemHeader(Decl->getLocation()))
463+
return;
464+
458465
if (hasNoName(Decl))
459466
return;
460467

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ Changes in existing checks
130130
<clang-tidy/checks/bugprone/infinite-loop>` check by adding detection for
131131
variables introduced by structured bindings.
132132

133+
- Improved :doc:`bugprone-reserved-identifier
134+
<clang-tidy/checks/bugprone/reserved-identifier>` check by ignoring
135+
declarations in system headers.
136+
133137
- Improved :doc:`bugprone-signed-char-misuse
134138
<clang-tidy/checks/bugprone/signed-char-misuse>` check by fixing
135139
false positives on C23 enums with the fixed underlying type of signed char.
@@ -160,6 +164,10 @@ Changes in existing checks
160164
<clang-tidy/checks/portability/template-virtual-member-function>` check to
161165
avoid false positives on pure virtual member functions.
162166

167+
- Improved :doc:`readability-identifier-naming
168+
<clang-tidy/checks/readability/identifier-naming>` check by ignoring
169+
declarations in system headers.
170+
163171
- Improved :doc:`readability-qualified-auto
164172
<clang-tidy/checks/readability/qualified-auto>` check by adding the option
165173
`IgnoreAliasing`, that allows not looking at underlying types of type aliases.

clang/docs/LanguageExtensions.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,7 +2018,7 @@ even if there is no valid ``std::tuple_element`` specialization or suitable
20182018
Blocks
20192019
======
20202020

2021-
The syntax and high level language feature description is in
2021+
The syntax and high-level language feature description is in
20222022
:doc:`BlockLanguageSpec<BlockLanguageSpec>`. Implementation and ABI details for
20232023
the clang implementation are in :doc:`Block-ABI-Apple<Block-ABI-Apple>`.
20242024

@@ -2088,7 +2088,7 @@ producing an object with the following member functions
20882088
constexpr size_t size() const;
20892089

20902090
such as ``std::string``, ``std::string_view``, ``std::vector<char>``.
2091-
This mechanism follow the same rules as ``static_assert`` messages in
2091+
This mechanism follows the same rules as ``static_assert`` messages in
20922092
C++26, see ``[dcl.pre]/p12``.
20932093

20942094
Query for this feature with ``__has_extension(gnu_asm_constexpr_strings)``.
@@ -2335,7 +2335,7 @@ Objective-C Autosynthesis of Properties
23352335
23362336
Clang provides support for autosynthesis of declared properties. Using this
23372337
feature, clang provides default synthesis of those properties not declared
2338-
@dynamic and not having user provided backing getter and setter methods.
2338+
@dynamic and not having user-provided backing getter and setter methods.
23392339
``__has_feature(objc_default_synthesize_properties)`` checks for availability
23402340
of this feature in version of clang being used.
23412341
@@ -2349,7 +2349,7 @@ In Objective-C, functions and methods are generally assumed to follow the
23492349
<https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html>`_
23502350
conventions for ownership of object arguments and
23512351
return values. However, there are exceptions, and so Clang provides attributes
2352-
to allow these exceptions to be documented. This are used by ARC and the
2352+
to allow these exceptions to be documented. These are used by ARC and the
23532353
`static analyzer <https://clang-analyzer.llvm.org>`_ Some exceptions may be
23542354
better described using the ``objc_method_family`` attribute instead.
23552355
@@ -2575,7 +2575,7 @@ Such functionality is not conformant and does not guarantee to compile
25752575
correctly in any circumstances. It can be used if:
25762576
25772577
- the kernel source does not contain call expressions to (member-) function
2578-
pointers, or virtual functions. For example this extension can be used in
2578+
pointers, or virtual functions. For example, this extension can be used in
25792579
metaprogramming algorithms to be able to specify/detect types generically.
25802580
25812581
- the generated kernel binary does not contain indirect calls because they
@@ -2613,7 +2613,7 @@ functions with variadic prototypes do not get generated in binary e.g. the
26132613
variadic prototype is used to specify a function type with any number of
26142614
arguments in metaprogramming algorithms in C++ for OpenCL.
26152615
2616-
This extensions can also be used when the kernel code is intended for targets
2616+
This extension can also be used when the kernel code is intended for targets
26172617
supporting the variadic arguments e.g. majority of CPU targets.
26182618
26192619
**Example of Use**:
@@ -2702,7 +2702,7 @@ address space qualifiers, therefore, other type qualifiers such as
27022702
Legacy 1.x atomics with generic address space
27032703
---------------------------------------------
27042704
2705-
Clang allows use of atomic functions from the OpenCL 1.x standards
2705+
Clang allows the use of atomic functions from the OpenCL 1.x standards
27062706
with the generic address space pointer in C++ for OpenCL mode.
27072707
27082708
This is a non-portable feature and might not be supported by all
@@ -2833,7 +2833,7 @@ to a possibly overlapping destination region. It takes five arguments.
28332833
The first argument is the destination WebAssembly table, and the second
28342834
argument is the source WebAssembly table. The third argument is the
28352835
destination index from where the copy starts, the fourth argument is the
2836-
source index from there the copy starts, and the fifth and last argument
2836+
source index from where the copy starts, and the fifth and last argument
28372837
is the number of elements to copy. It returns nothing.
28382838
28392839
.. code-block:: c++
@@ -3133,7 +3133,7 @@ Query for this feature with ``__has_builtin(__builtin_get_vtable_pointer)``.
31333133
------------------------------------
31343134
31353135
``__builtin_call_with_static_chain`` is used to perform a static call while
3136-
setting updating the static chain register.
3136+
updating the static chain register.
31373137
31383138
**Syntax**:
31393139
@@ -3245,7 +3245,7 @@ Query for this feature with ``__has_builtin(__builtin_readsteadycounter)``.
32453245
The ``__builtin_cpu_supports`` function detects if the run-time CPU supports
32463246
features specified in string argument. It returns a positive integer if all
32473247
features are supported and 0 otherwise. Feature names are target specific. On
3248-
AArch64 features are combined using ``+`` like this
3248+
AArch64, features are combined using ``+`` like this
32493249
``__builtin_cpu_supports("flagm+sha3+lse+rcpc2+fcma+memtag+bti+sme2")``.
32503250
If a feature name is not supported, Clang will issue a warning and replace
32513251
builtin by the constant 0.
@@ -3465,7 +3465,7 @@ Query for this feature with ``__has_builtin(__builtin_convertvector)``.
34653465
**Description**:
34663466
34673467
The '``__builtin_bitreverse``' family of builtins is used to reverse
3468-
the bitpattern of an integer value; for example ``0b10110110`` becomes
3468+
the bitpattern of an integer value; for example, ``0b10110110`` becomes
34693469
``0b01101101``. These builtins can be used within constant expressions.
34703470
34713471
``__builtin_rotateleft``
@@ -3970,7 +3970,7 @@ the debugging experience.
39703970
39713971
``__builtin_allow_runtime_check`` returns true if the check at the current
39723972
program location should be executed. It is expected to be used to implement
3973-
``assert`` like checks which can be safely removed by optimizer.
3973+
``assert`` like checks which can be safely removed by the optimizer.
39743974
39753975
**Syntax**:
39763976

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ Improvements to Clang's diagnostics
123123
Moved the warning for a missing (though implied) attribute on a redeclaration into this group.
124124
Added a new warning in this group for the case where the attribute is missing/implicit on
125125
an override of a virtual method.
126+
- Fixed fix-it hint for fold expressions. Clang now correctly places the suggested right
127+
parenthesis when diagnosing malformed fold expressions. (#GH151787)
126128

127129
Improvements to Clang's time-trace
128130
----------------------------------

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,12 @@ TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk8_bf16_fp4, "V8yUiUiIUi", "nc", "gfx
721721
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk8_f32_fp8, "V8fV2UiUiIUi", "nc", "gfx1250-insts")
722722
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk8_f32_bf8, "V8fV2UiUiIUi", "nc", "gfx1250-insts")
723723
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk8_f32_fp4, "V8fUiUiIUi", "nc", "gfx1250-insts")
724+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk16_f16_fp6, "V16hV3UiUiIUi", "nc", "gfx1250-insts")
725+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk16_bf16_fp6, "V16yV3UiUiIUi", "nc", "gfx1250-insts")
726+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk16_f16_bf6, "V16hV3UiUiIUi", "nc", "gfx1250-insts")
727+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk16_bf16_bf6, "V16yV3UiUiIUi", "nc", "gfx1250-insts")
728+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk16_f32_fp6, "V16fV3UiUiIUi", "nc", "gfx1250-insts")
729+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scale_pk16_f32_bf6, "V16fV3UiUiIUi", "nc", "gfx1250-insts")
724730
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk8_fp8_bf16, "V2UiV8yf", "nc", "gfx1250-insts")
725731
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk8_bf8_bf16, "V2UiV8yf", "nc", "gfx1250-insts")
726732
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk8_fp8_f16, "V2UiV8hf", "nc", "gfx1250-insts")
@@ -730,6 +736,12 @@ TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk8_bf8_f32, "V2UiV8ff", "nc", "gfx
730736
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk8_fp4_f32, "UiV8ff", "nc", "gfx1250-insts")
731737
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk8_fp4_f16, "UiV8hf", "nc", "gfx1250-insts")
732738
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk8_fp4_bf16, "UiV8yf", "nc", "gfx1250-insts")
739+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk16_fp6_f32, "V3UiV16ff", "nc", "gfx1250-insts")
740+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk16_bf6_f32, "V3UiV16ff", "nc", "gfx1250-insts")
741+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk16_fp6_f16, "V3UiV16hf", "nc", "gfx1250-insts")
742+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk16_bf6_f16, "V3UiV16hf", "nc", "gfx1250-insts")
743+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk16_fp6_bf16, "V3UiV16yf", "nc", "gfx1250-insts")
744+
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_pk16_bf6_bf16, "V3UiV16yf", "nc", "gfx1250-insts")
733745
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_sr_pk8_fp8_bf16, "V2UiV8yUif", "nc", "gfx1250-insts")
734746
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_sr_pk8_bf8_bf16, "V2UiV8yUif", "nc", "gfx1250-insts")
735747
TARGET_BUILTIN(__builtin_amdgcn_cvt_scalef32_sr_pk8_fp8_f16, "V2UiV8hUif", "nc", "gfx1250-insts")
@@ -750,6 +762,10 @@ TARGET_BUILTIN(__builtin_amdgcn_permlane_down, "iiii", "nc", "gfx1250-insts,wave
750762
TARGET_BUILTIN(__builtin_amdgcn_permlane_xor, "iiii", "nc", "gfx1250-insts,wavefrontsize32")
751763
TARGET_BUILTIN(__builtin_amdgcn_permlane_idx_gen, "iii", "nc", "gfx1250-insts,wavefrontsize32")
752764

765+
TARGET_BUILTIN(__builtin_amdgcn_perm_pk16_b4_u4, "V2UiUiUiV2Ui", "nc", "tensor-cvt-lut-insts")
766+
TARGET_BUILTIN(__builtin_amdgcn_perm_pk16_b6_u4, "V3UiUiULiV2Ui", "nc", "tensor-cvt-lut-insts")
767+
TARGET_BUILTIN(__builtin_amdgcn_perm_pk16_b8_u4, "V4UiULiULiV2Ui", "nc", "tensor-cvt-lut-insts")
768+
753769
// GFX1250 WMMA builtins
754770
TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_16x16x4_f32, "V8fIbV2fIbV2fIsV8fIbIb", "nc", "gfx1250-insts,wavefrontsize32")
755771
TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_16x16x32_bf16, "V8fIbV16yIbV16yIsV8fIbIb", "nc", "gfx1250-insts,wavefrontsize32")

clang/lib/AST/ByteCode/ByteCodeEmitter.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,21 +137,21 @@ int32_t ByteCodeEmitter::getOffset(LabelTy Label) {
137137
template <typename T>
138138
static void emit(Program &P, std::vector<std::byte> &Code, const T &Val,
139139
bool &Success) {
140+
size_t ValPos = Code.size();
140141
size_t Size;
141142

142143
if constexpr (std::is_pointer_v<T>)
143-
Size = sizeof(uint32_t);
144+
Size = align(sizeof(uint32_t));
144145
else
145-
Size = sizeof(T);
146+
Size = align(sizeof(T));
146147

147-
if (Code.size() + Size > std::numeric_limits<unsigned>::max()) {
148+
if (ValPos + Size > std::numeric_limits<unsigned>::max()) {
148149
Success = false;
149150
return;
150151
}
151152

152153
// Access must be aligned!
153-
size_t ValPos = align(Code.size());
154-
Size = align(Size);
154+
assert(aligned(ValPos));
155155
assert(aligned(ValPos + Size));
156156
Code.resize(ValPos + Size);
157157

@@ -168,17 +168,16 @@ static void emit(Program &P, std::vector<std::byte> &Code, const T &Val,
168168
template <typename T>
169169
static void emitSerialized(std::vector<std::byte> &Code, const T &Val,
170170
bool &Success) {
171-
size_t Size = Val.bytesToSerialize();
171+
size_t ValPos = Code.size();
172+
size_t Size = align(Val.bytesToSerialize());
172173

173-
if (Code.size() + Size > std::numeric_limits<unsigned>::max()) {
174+
if (ValPos + Size > std::numeric_limits<unsigned>::max()) {
174175
Success = false;
175176
return;
176177
}
177178

178179
// Access must be aligned!
179-
assert(aligned(Code.size()));
180-
size_t ValPos = Code.size();
181-
Size = align(Size);
180+
assert(aligned(ValPos));
182181
assert(aligned(ValPos + Size));
183182
Code.resize(ValPos + Size);
184183

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
331331
}
332332

333333
case CK_FloatingToIntegral: {
334+
if (!CE->getType()->isIntegralOrEnumerationType())
335+
return false;
334336
if (!this->visit(SubExpr))
335337
return false;
336338
PrimType ToT = classifyPrim(CE);
@@ -1369,10 +1371,15 @@ bool Compiler<Emitter>::VisitVectorBinOp(const BinaryOperator *E) {
13691371
// BitAdd/BitOr/BitXor/Shl/Shr doesn't support bool type, we need perform the
13701372
// integer promotion.
13711373
bool NeedIntPromot = ElemT == PT_Bool && (E->isBitwiseOp() || E->isShiftOp());
1372-
QualType PromotTy =
1373-
Ctx.getASTContext().getPromotedIntegerType(Ctx.getASTContext().BoolTy);
1374-
PrimType PromotT = classifyPrim(PromotTy);
1375-
PrimType OpT = NeedIntPromot ? PromotT : ElemT;
1374+
QualType PromotTy;
1375+
PrimType PromotT = PT_Bool;
1376+
PrimType OpT = ElemT;
1377+
if (NeedIntPromot) {
1378+
PromotTy =
1379+
Ctx.getASTContext().getPromotedIntegerType(Ctx.getASTContext().BoolTy);
1380+
PromotT = classifyPrim(PromotTy);
1381+
OpT = PromotT;
1382+
}
13761383

13771384
auto getElem = [=](unsigned Offset, PrimType ElemT, unsigned Index) {
13781385
if (!this->emitGetLocal(PT_Ptr, Offset, E))

clang/lib/AST/ByteCode/Descriptor.cpp

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,31 @@
2121
using namespace clang;
2222
using namespace clang::interp;
2323

24+
template <typename T> static constexpr bool needsCtor() {
25+
if constexpr (std::is_same_v<T, Integral<8, true>> ||
26+
std::is_same_v<T, Integral<8, false>> ||
27+
std::is_same_v<T, Integral<16, true>> ||
28+
std::is_same_v<T, Integral<16, false>> ||
29+
std::is_same_v<T, Integral<32, true>> ||
30+
std::is_same_v<T, Integral<32, false>> ||
31+
std::is_same_v<T, Integral<64, true>> ||
32+
std::is_same_v<T, Integral<64, false>> ||
33+
std::is_same_v<T, Boolean>)
34+
return false;
35+
36+
return true;
37+
}
38+
2439
template <typename T>
2540
static void ctorTy(Block *, std::byte *Ptr, bool, bool, bool, bool, bool,
2641
const Descriptor *) {
42+
static_assert(needsCtor<T>());
2743
new (Ptr) T();
2844
}
2945

3046
template <typename T>
3147
static void dtorTy(Block *, std::byte *Ptr, const Descriptor *) {
48+
static_assert(needsCtor<T>());
3249
reinterpret_cast<T *>(Ptr)->~T();
3350
}
3451

@@ -45,9 +62,11 @@ static void ctorArrayTy(Block *, std::byte *Ptr, bool, bool, bool, bool, bool,
4562
const Descriptor *D) {
4663
new (Ptr) InitMapPtr(std::nullopt);
4764

48-
Ptr += sizeof(InitMapPtr);
49-
for (unsigned I = 0, NE = D->getNumElems(); I < NE; ++I) {
50-
new (&reinterpret_cast<T *>(Ptr)[I]) T();
65+
if constexpr (needsCtor<T>()) {
66+
Ptr += sizeof(InitMapPtr);
67+
for (unsigned I = 0, NE = D->getNumElems(); I < NE; ++I) {
68+
new (&reinterpret_cast<T *>(Ptr)[I]) T();
69+
}
5170
}
5271
}
5372

@@ -57,9 +76,12 @@ static void dtorArrayTy(Block *, std::byte *Ptr, const Descriptor *D) {
5776

5877
if (IMP)
5978
IMP = std::nullopt;
60-
Ptr += sizeof(InitMapPtr);
61-
for (unsigned I = 0, NE = D->getNumElems(); I < NE; ++I) {
62-
reinterpret_cast<T *>(Ptr)[I].~T();
79+
80+
if constexpr (needsCtor<T>()) {
81+
Ptr += sizeof(InitMapPtr);
82+
for (unsigned I = 0, NE = D->getNumElems(); I < NE; ++I) {
83+
reinterpret_cast<T *>(Ptr)[I].~T();
84+
}
6385
}
6486
}
6587

@@ -74,10 +96,14 @@ static void moveArrayTy(Block *, std::byte *Src, std::byte *Dst,
7496
}
7597
Src += sizeof(InitMapPtr);
7698
Dst += sizeof(InitMapPtr);
77-
for (unsigned I = 0, NE = D->getNumElems(); I < NE; ++I) {
78-
auto *SrcPtr = &reinterpret_cast<T *>(Src)[I];
79-
auto *DstPtr = &reinterpret_cast<T *>(Dst)[I];
80-
new (DstPtr) T(std::move(*SrcPtr));
99+
if constexpr (!needsCtor<T>()) {
100+
std::memcpy(Dst, Src, D->getNumElems() * D->getElemSize());
101+
} else {
102+
for (unsigned I = 0, NE = D->getNumElems(); I < NE; ++I) {
103+
auto *SrcPtr = &reinterpret_cast<T *>(Src)[I];
104+
auto *DstPtr = &reinterpret_cast<T *>(Dst)[I];
105+
new (DstPtr) T(std::move(*SrcPtr));
106+
}
81107
}
82108
}
83109

0 commit comments

Comments
 (0)