mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-14 07:31:53 +00:00
More workarounds for undefined behavior exposed when compiling in C++14 with
-fsized-deallocation. Disable sized deallocation for all objects derived from TrailingObjects, as we expect the storage allocated for these objects to be larger than the size of their dynamic type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@259942 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
165b22a2ae
commit
2597d07f15
@ -79,6 +79,11 @@ public:
|
||||
|
||||
/// The base class for TrailingObjects* classes.
|
||||
class TrailingObjectsBase {
|
||||
public:
|
||||
/// 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); }
|
||||
|
||||
protected:
|
||||
/// OverloadToken's purpose is to allow specifying function overloads
|
||||
/// for different types, without actually taking the types as
|
||||
@ -290,7 +295,8 @@ class TrailingObjects : private trailing_objects_internal::TrailingObjectsImpl<
|
||||
}
|
||||
|
||||
public:
|
||||
// make this (privately inherited) class public.
|
||||
// Make these (privately inherited) members public.
|
||||
using ParentType::operator delete;
|
||||
using ParentType::OverloadToken;
|
||||
|
||||
/// Returns a pointer to the trailing object array of the given type
|
||||
|
@ -171,6 +171,8 @@ class AttributeSetNode final
|
||||
void operator=(const AttributeSetNode &) = delete;
|
||||
AttributeSetNode(const AttributeSetNode &) = delete;
|
||||
public:
|
||||
using TrailingObjects::operator delete;
|
||||
|
||||
static AttributeSetNode *get(LLVMContext &C, ArrayRef<Attribute> Attrs);
|
||||
|
||||
bool hasAttribute(Attribute::AttrKind Kind) const {
|
||||
@ -266,6 +268,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
using TrailingObjects::operator delete;
|
||||
|
||||
/// \brief Get the context that created this AttributeSetImpl.
|
||||
LLVMContext &getContext() { return Context; }
|
||||
|
||||
|
@ -34,6 +34,7 @@ public:
|
||||
void *Mem = ::operator new(totalSizeToAlloc<short>(NumShorts));
|
||||
return new (Mem) Class1(ShortArray, NumShorts);
|
||||
}
|
||||
using TrailingObjects::operator delete;
|
||||
|
||||
short get(unsigned Num) const { return getTrailingObjects<short>()[Num]; }
|
||||
|
||||
@ -78,6 +79,7 @@ public:
|
||||
*C->getTrailingObjects<double>() = D;
|
||||
return C;
|
||||
}
|
||||
using TrailingObjects::operator delete;
|
||||
|
||||
short getShort() const {
|
||||
if (!HasShort)
|
||||
|
Loading…
Reference in New Issue
Block a user