summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/TrailingObjectsTest.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-02-09 01:03:42 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-02-09 01:03:42 +0000
commit1b65c3279d75428d2e1ae1a196c4884d6745d0d8 (patch)
tree047d45e440ccac0844ec594b1c857db4a9763151 /llvm/unittests/Support/TrailingObjectsTest.cpp
parentfed557ef7611a3d4a83f17c86067369044e74063 (diff)
downloadbcm5719-llvm-1b65c3279d75428d2e1ae1a196c4884d6745d0d8.tar.gz
bcm5719-llvm-1b65c3279d75428d2e1ae1a196c4884d6745d0d8.zip
Re-commit r259942 (reverted in r260053) with a different workaround for the MSVC bug.
This fixes undefined behavior in C++14 due to the size of the object being deleted being different from sizeof(dynamic type) when it is allocated with trailing objects. MSVC seems to have several bugs around using-declarations changing the access of a member inherited from a base class, so use forwarding functions instead of using-declarations to make TrailingObjects::operator delete accessible where desired. llvm-svn: 260180
Diffstat (limited to 'llvm/unittests/Support/TrailingObjectsTest.cpp')
-rw-r--r--llvm/unittests/Support/TrailingObjectsTest.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/unittests/Support/TrailingObjectsTest.cpp b/llvm/unittests/Support/TrailingObjectsTest.cpp
index 170cbc372b8..282f402ec8e 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);
}
+ void operator delete(void *p) { TrailingObjects::operator delete(p); }
short get(unsigned Num) const { return getTrailingObjects<short>()[Num]; }
@@ -78,6 +79,7 @@ public:
*C->getTrailingObjects<double>() = D;
return C;
}
+ void operator delete(void *p) { TrailingObjects::operator delete(p); }
short getShort() const {
if (!HasShort)
OpenPOWER on IntegriCloud