[PATCH] D134054: [clang][Interp] Properly destruct allocated Records

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 29 03:52:17 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG84f1df8aacd0: [clang][Interp] Properly destruct allocated Records (authored by tbaeder).

Changed prior to commit:
  https://reviews.llvm.org/D134054?vs=460813&id=463839#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134054

Files:
  clang/lib/AST/Interp/Program.h
  clang/test/AST/Interp/references.cpp


Index: clang/test/AST/Interp/references.cpp
===================================================================
--- clang/test/AST/Interp/references.cpp
+++ clang/test/AST/Interp/references.cpp
@@ -75,7 +75,6 @@
 constexpr const int &MCE = 1; // expected-error{{must be initialized by a constant expression}}
 
 
-#if 0
 struct S {
   int i, j;
 };
@@ -89,5 +88,4 @@
   return j;
 }
 // FIXME: Should be accepted.
-static_assert(RefToMemberExpr() == 11, "");
-#endif
+static_assert(RefToMemberExpr() == 11, ""); // expected-error {{not an integral constant expression}}
Index: clang/lib/AST/Interp/Program.h
===================================================================
--- clang/lib/AST/Interp/Program.h
+++ clang/lib/AST/Interp/Program.h
@@ -41,6 +41,14 @@
 public:
   Program(Context &Ctx) : Ctx(Ctx) {}
 
+  ~Program() {
+    // Records might actually allocate memory themselves, but they
+    // are allocated using a BumpPtrAllocator. Call their desctructors
+    // here manually so they are properly freeing their resources.
+    for (auto RecordPair : Records)
+      RecordPair.second->~Record();
+  }
+
   /// Marshals a native pointer to an ID for embedding in bytecode.
   unsigned getOrCreateNativePointer(const void *Ptr);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134054.463839.patch
Type: text/x-patch
Size: 1246 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220929/c6a0ca08/attachment.bin>


More information about the cfe-commits mailing list