summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-02-05 22:32:52 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-02-05 22:32:52 +0000
commitebfdf26d934913e37b89bdaa037d0e4232f600a3 (patch)
tree00180b90ca680661250e0e9a0fc1750b06bd23a8
parent6219836edd78a7dd4f710cef314409e0061d8c8d (diff)
downloadbcm5719-llvm-ebfdf26d934913e37b89bdaa037d0e4232f600a3.tar.gz
bcm5719-llvm-ebfdf26d934913e37b89bdaa037d0e4232f600a3.zip
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. llvm-svn: 259942
-rw-r--r--llvm/include/llvm/Support/TrailingObjects.h8
-rw-r--r--llvm/lib/IR/AttributeImpl.h4
-rw-r--r--llvm/unittests/Support/TrailingObjectsTest.cpp2
3 files changed, 13 insertions, 1 deletions
diff --git a/llvm/include/llvm/Support/TrailingObjects.h b/llvm/include/llvm/Support/TrailingObjects.h
index 6c721f267be..8719702e5e6 100644
--- a/llvm/include/llvm/Support/TrailingObjects.h
+++ b/llvm/include/llvm/Support/TrailingObjects.h
@@ -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
diff --git a/llvm/lib/IR/AttributeImpl.h b/llvm/lib/IR/AttributeImpl.h
index ca7ae5cbb29..f23e9585cf0 100644
--- a/llvm/lib/IR/AttributeImpl.h
+++ b/llvm/lib/IR/AttributeImpl.h
@@ -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; }
diff --git a/llvm/unittests/Support/TrailingObjectsTest.cpp b/llvm/unittests/Support/TrailingObjectsTest.cpp
index 170cbc372b8..92cdd6d3824 100644
--- a/llvm/unittests/Support/TrailingObjectsTest.cpp
+++ b/llvm/unittests/Support/TrailingObjectsTest.cpp
@@ -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)
OpenPOWER on IntegriCloud