Skip to content

Commit 85d4a4b

Browse files
committed
Revert "Fix memory leak complicated non-type template arguments."
This reverts commit ed13d8c. This is part of 5 commits being reverted due to https://crbug.com/1161059. See bug for repro.
1 parent 612ddc3 commit 85d4a4b

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

clang/include/clang/AST/ASTContext.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2818,8 +2818,8 @@ class ASTContext : public RefCountedBase<ASTContext> {
28182818
/// for destruction.
28192819
template <typename T> void addDestruction(T *Ptr) const {
28202820
if (!std::is_trivially_destructible<T>::value) {
2821-
auto DestroyPtr = [](void *V) { ((T*)V)->~T(); };
2822-
AddDeallocation(DestroyPtr, (void*)Ptr);
2821+
auto DestroyPtr = [](void *V) { static_cast<T *>(V)->~T(); };
2822+
AddDeallocation(DestroyPtr, Ptr);
28232823
}
28242824
}
28252825

clang/lib/AST/TemplateBase.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ TemplateArgument::TemplateArgument(const ASTContext &Ctx, QualType Type,
137137
else {
138138
Value.Kind = UncommonValue;
139139
Value.Value = new (Ctx) APValue(V);
140-
Ctx.addDestruction(Value.Value);
141140
Value.Type = Type.getAsOpaquePtr();
142141
}
143142
}

0 commit comments

Comments
 (0)