diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-02-04 01:21:16 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-02-04 01:21:16 +0000 |
commit | 69cb000974ef63d9c016f2e230a254ea37622286 (patch) | |
tree | 13c5f67669bba909a15fb5bb8140e9c5a389024b /llvm/lib/Support/MemoryBuffer.cpp | |
parent | f5416740fc923ed6b24784c8ce73ccf57b6edbbd (diff) | |
download | bcm5719-llvm-69cb000974ef63d9c016f2e230a254ea37622286.tar.gz bcm5719-llvm-69cb000974ef63d9c016f2e230a254ea37622286.zip |
Fix undefined behavior when compiling in C++14 mode (with sized deletion
enabled): ensure that we do not invoke the sized deallocator for MemoryBuffer
subclasses that have tail-allocated data.
llvm-svn: 259735
Diffstat (limited to 'llvm/lib/Support/MemoryBuffer.cpp')
-rw-r--r-- | llvm/lib/Support/MemoryBuffer.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Support/MemoryBuffer.cpp b/llvm/lib/Support/MemoryBuffer.cpp index 25ddfe52a1d..b935cbf1ae7 100644 --- a/llvm/lib/Support/MemoryBuffer.cpp +++ b/llvm/lib/Support/MemoryBuffer.cpp @@ -86,6 +86,10 @@ public: init(InputData.begin(), InputData.end(), RequiresNullTerminator); } + /// Disable sized deallocation for MemoryBufferMem, because it has + /// tail-allocated data. + void operator delete(void *p) { ::operator delete(p); } + const char *getBufferIdentifier() const override { // The name is stored after the class itself. return reinterpret_cast<const char*>(this + 1); @@ -213,6 +217,10 @@ public: } } + /// Disable sized deallocation for MemoryBufferMMapFile, because it has + /// tail-allocated data. + void operator delete(void *p) { ::operator delete(p); } + const char *getBufferIdentifier() const override { // The name is stored after the class itself. return reinterpret_cast<const char *>(this + 1); |