This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaf67614f7905: [clang][Interp] Call dtor of Floating values 
(authored by tbaeder).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154928/new/

https://reviews.llvm.org/D154928

Files:
  clang/lib/AST/Interp/Descriptor.cpp
  clang/test/AST/Interp/floats.cpp


Index: clang/test/AST/Interp/floats.cpp
===================================================================
--- clang/test/AST/Interp/floats.cpp
+++ clang/test/AST/Interp/floats.cpp
@@ -125,3 +125,7 @@
   constexpr A<double> b{12};
   static_assert(a.f == 0.0, "");
 };
+
+namespace LongDouble {
+  constexpr long double ld = 3.1425926539;
+}
Index: clang/lib/AST/Interp/Descriptor.cpp
===================================================================
--- clang/lib/AST/Interp/Descriptor.cpp
+++ clang/lib/AST/Interp/Descriptor.cpp
@@ -186,6 +186,11 @@
 }
 
 static BlockDtorFn getDtorPrim(PrimType Type) {
+  // Floating types are special. They are primitives, but need their
+  // destructor called, since they might allocate memory.
+  if (Type == PT_Float)
+    return dtorTy<PrimConv<PT_Float>::T>;
+
   COMPOSITE_TYPE_SWITCH(Type, return dtorTy<T>, return nullptr);
 }
 


Index: clang/test/AST/Interp/floats.cpp
===================================================================
--- clang/test/AST/Interp/floats.cpp
+++ clang/test/AST/Interp/floats.cpp
@@ -125,3 +125,7 @@
   constexpr A<double> b{12};
   static_assert(a.f == 0.0, "");
 };
+
+namespace LongDouble {
+  constexpr long double ld = 3.1425926539;
+}
Index: clang/lib/AST/Interp/Descriptor.cpp
===================================================================
--- clang/lib/AST/Interp/Descriptor.cpp
+++ clang/lib/AST/Interp/Descriptor.cpp
@@ -186,6 +186,11 @@
 }
 
 static BlockDtorFn getDtorPrim(PrimType Type) {
+  // Floating types are special. They are primitives, but need their
+  // destructor called, since they might allocate memory.
+  if (Type == PT_Float)
+    return dtorTy<PrimConv<PT_Float>::T>;
+
   COMPOSITE_TYPE_SWITCH(Type, return dtorTy<T>, return nullptr);
 }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to