[llvm] r259735 - Fix undefined behavior when compiling in C++14 mode (with sized deletion
Richard Smith via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 3 17:21:16 PST 2016
Author: rsmith
Date: Wed Feb 3 19:21:16 2016
New Revision: 259735
URL: http://llvm.org/viewvc/llvm-project?rev=259735&view=rev
Log:
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.
Modified:
llvm/trunk/lib/Support/MemoryBuffer.cpp
Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=259735&r1=259734&r2=259735&view=diff
==============================================================================
--- llvm/trunk/lib/Support/MemoryBuffer.cpp (original)
+++ llvm/trunk/lib/Support/MemoryBuffer.cpp Wed Feb 3 19:21:16 2016
@@ -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);
More information about the llvm-commits
mailing list