Skip to content

Commit

Permalink
Remove TrailingObjects::operator delete. It's still suffering from
Browse files Browse the repository at this point in the history
compiler-specific issues. Instead, repeat an 'operator delete' definition in
each derived class that is actually deleted, and give up on the static type
safety of an error when sized delete is accidentally used on a type derived
from TrailingObjects.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260190 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
zygoloid committed Feb 9, 2016
1 parent 8a618ff commit 749e602
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
4 changes: 0 additions & 4 deletions include/llvm/Support/TrailingObjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,6 @@ class TrailingObjects : private trailing_objects_internal::TrailingObjectsImpl<
// Make this (privately inherited) member public.
using ParentType::OverloadToken;

/// Disable sized deallocation for all objects with trailing object storage;
/// the inferred size will typically not be correct.
void operator delete(void *P) { return ::operator delete(P); }

/// Returns a pointer to the trailing object array of the given type
/// (which must be one of those specified in the class template). The
/// array may have zero or more elements in it.
Expand Down
4 changes: 2 additions & 2 deletions lib/IR/AttributeImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class AttributeSetNode final
void operator=(const AttributeSetNode &) = delete;
AttributeSetNode(const AttributeSetNode &) = delete;
public:
void operator delete(void *p) { TrailingObjects::operator delete(p); }
void operator delete(void *p) { ::operator delete(p); }

static AttributeSetNode *get(LLVMContext &C, ArrayRef<Attribute> Attrs);

Expand Down Expand Up @@ -268,7 +268,7 @@ class AttributeSetImpl final
}
}

void operator delete(void *p) { TrailingObjects::operator delete(p); }
void operator delete(void *p) { ::operator delete(p); }

/// \brief Get the context that created this AttributeSetImpl.
LLVMContext &getContext() { return Context; }
Expand Down
4 changes: 2 additions & 2 deletions unittests/Support/TrailingObjectsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Class1 final : protected TrailingObjects<Class1, short> {
void *Mem = ::operator new(totalSizeToAlloc<short>(NumShorts));
return new (Mem) Class1(ShortArray, NumShorts);
}
void operator delete(void *p) { TrailingObjects::operator delete(p); }
void operator delete(void *p) { ::operator delete(p); }

short get(unsigned Num) const { return getTrailingObjects<short>()[Num]; }

Expand Down Expand Up @@ -79,7 +79,7 @@ class Class2 final : protected TrailingObjects<Class2, double, short> {
*C->getTrailingObjects<double>() = D;
return C;
}
void operator delete(void *p) { TrailingObjects::operator delete(p); }
void operator delete(void *p) { ::operator delete(p); }

short getShort() const {
if (!HasShort)
Expand Down

0 comments on commit 749e602

Please sign in to comment.