Author: Timm Baeder
Date: 2024-08-15T19:59:55+02:00
New Revision: 75ea8e803a6560b5e16644bb25d6340926156503

URL: 
https://github.com/llvm/llvm-project/commit/75ea8e803a6560b5e16644bb25d6340926156503
DIFF: 
https://github.com/llvm/llvm-project/commit/75ea8e803a6560b5e16644bb25d6340926156503.diff

LOG: [clang][Interp] Call move function for certain primitive types (#104437)

Added: 
    

Modified: 
    clang/lib/AST/Interp/Descriptor.cpp
    clang/test/AST/Interp/lifetimes.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/Descriptor.cpp 
b/clang/lib/AST/Interp/Descriptor.cpp
index 1b7d9f03f8ef0..47b8885c9ae37 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 9fca54fe11120..9a99485c4a40b 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;
+  }
+}


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to