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);
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);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits