[clang] [clang][Interp] Call move function for certain primitive types (PR #104437)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 15 06:53:59 PDT 2024
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/104437
None
>From 36c5f883ede65c2ca245354b1c55ac56edec1683 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Thu, 15 Aug 2024 15:51:22 +0200
Subject: [PATCH] [clang][Interp] Call move function for certain primitive
types
---
clang/lib/AST/Interp/Descriptor.cpp | 8 ++++++++
clang/test/AST/Interp/lifetimes.cpp | 8 ++++++++
2 files changed, 16 insertions(+)
diff --git a/clang/lib/AST/Interp/Descriptor.cpp b/clang/lib/AST/Interp/Descriptor.cpp
index 1b7d9f03f8ef0d..47b8885c9ae379 100644
--- a/clang/lib/AST/Interp/Descriptor.cpp
+++ b/clang/lib/AST/Interp/Descriptor.cpp
@@ -284,6 +284,14 @@ static BlockDtorFn getDtorPrim(PrimType Type) {
}
static BlockMoveFn getMovePrim(PrimType Type) {
+ if (Type == PT_Float)
+ return moveTy<PrimConv<PT_Float>::T>;
+ if (Type == PT_IntAP)
+ return moveTy<PrimConv<PT_IntAP>::T>;
+ if (Type == PT_IntAPS)
+ return moveTy<PrimConv<PT_IntAPS>::T>;
+ if (Type == PT_MemberPtr)
+ return moveTy<PrimConv<PT_MemberPtr>::T>;
COMPOSITE_TYPE_SWITCH(Type, return moveTy<T>, return nullptr);
}
diff --git a/clang/test/AST/Interp/lifetimes.cpp b/clang/test/AST/Interp/lifetimes.cpp
index 9fca54fe11120a..9a99485c4a40bf 100644
--- a/clang/test/AST/Interp/lifetimes.cpp
+++ b/clang/test/AST/Interp/lifetimes.cpp
@@ -60,3 +60,11 @@ namespace MoveFnWorks {
}
static_assert(dtor_calls_dtor(), "");
}
+
+namespace PrimitiveMoveFn {
+ /// This used to crash.
+ void test() {
+ const float y = 100;
+ const float &x = y;
+ }
+}
More information about the cfe-commits
mailing list