Fix memory leak complicated non-type template arguments.
This commit is contained in:
parent
72d8f79f0c
commit
ed13d8c667
|
@ -2818,8 +2818,8 @@ public:
|
|||
/// for destruction.
|
||||
template <typename T> void addDestruction(T *Ptr) const {
|
||||
if (!std::is_trivially_destructible<T>::value) {
|
||||
auto DestroyPtr = [](void *V) { static_cast<T *>(V)->~T(); };
|
||||
AddDeallocation(DestroyPtr, Ptr);
|
||||
auto DestroyPtr = [](void *V) { ((T*)V)->~T(); };
|
||||
AddDeallocation(DestroyPtr, (void*)Ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -137,6 +137,7 @@ 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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue