Skip to content

Commit 75ea8e8

Browse files
authored
[clang][Interp] Call move function for certain primitive types (#104437)
1 parent 29b0a25 commit 75ea8e8

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

clang/lib/AST/Interp/Descriptor.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,14 @@ static BlockDtorFn getDtorPrim(PrimType Type) {
284284
}
285285

286286
static BlockMoveFn getMovePrim(PrimType Type) {
287+
if (Type == PT_Float)
288+
return moveTy<PrimConv<PT_Float>::T>;
289+
if (Type == PT_IntAP)
290+
return moveTy<PrimConv<PT_IntAP>::T>;
291+
if (Type == PT_IntAPS)
292+
return moveTy<PrimConv<PT_IntAPS>::T>;
293+
if (Type == PT_MemberPtr)
294+
return moveTy<PrimConv<PT_MemberPtr>::T>;
287295
COMPOSITE_TYPE_SWITCH(Type, return moveTy<T>, return nullptr);
288296
}
289297

clang/test/AST/Interp/lifetimes.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,11 @@ namespace MoveFnWorks {
6060
}
6161
static_assert(dtor_calls_dtor(), "");
6262
}
63+
64+
namespace PrimitiveMoveFn {
65+
/// This used to crash.
66+
void test() {
67+
const float y = 100;
68+
const float &x = y;
69+
}
70+
}

0 commit comments

Comments
 (0)