From 85d4a4bcc717a31ff40c4bd979dd6d78beb84b43 Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Tue, 22 Dec 2020 10:11:31 -0800 Subject: [PATCH] Revert "Fix memory leak complicated non-type template arguments." This reverts commit ed13d8c66781b50ff007cb089c5905f9bb9e8af2. This is part of 5 commits being reverted due to https://crbug.com/1161059. See bug for repro. --- clang/include/clang/AST/ASTContext.h | 4 ++-- clang/lib/AST/TemplateBase.cpp | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index a9bfdb4d5fa5..0c5d82b3e9aa 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -2818,8 +2818,8 @@ public: /// for destruction. template void addDestruction(T *Ptr) const { if (!std::is_trivially_destructible::value) { - auto DestroyPtr = [](void *V) { ((T*)V)->~T(); }; - AddDeallocation(DestroyPtr, (void*)Ptr); + auto DestroyPtr = [](void *V) { static_cast(V)->~T(); }; + AddDeallocation(DestroyPtr, Ptr); } } diff --git a/clang/lib/AST/TemplateBase.cpp b/clang/lib/AST/TemplateBase.cpp index a746db315d85..0029c90a0ab6 100644 --- a/clang/lib/AST/TemplateBase.cpp +++ b/clang/lib/AST/TemplateBase.cpp @@ -137,7 +137,6 @@ TemplateArgument::TemplateArgument(const ASTContext &Ctx, QualType Type, else { Value.Kind = UncommonValue; Value.Value = new (Ctx) APValue(V); - Ctx.addDestruction(Value.Value); Value.Type = Type.getAsOpaquePtr(); } }