A couple more UB fixes for C++14 sized deallocation.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 8 Mar 2016 00:59:44 +0000 (00:59 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 8 Mar 2016 00:59:44 +0000 (00:59 +0000)
llvm-svn: 262891

llvm/include/llvm/TableGen/Record.h
llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp

index 2069b27..9140b3a 100644 (file)
@@ -468,6 +468,9 @@ class BitsInit final : public TypedInit, public FoldingSetNode,
   BitsInit &operator=(const BitsInit &Other) = delete;
 
 public:
+  // Do not use sized deallocation due to trailing objects.
+  void operator delete(void *p) { ::operator delete(p); }
+
   static bool classof(const Init *I) {
     return I->getKind() == IK_BitsInit;
   }
@@ -601,6 +604,9 @@ private:
   ListInit &operator=(const ListInit &Other) = delete;
 
 public:
+  // Do not use sized deallocation due to trailing objects.
+  void operator delete(void *p) { ::operator delete(p); }
+
   static bool classof(const Init *I) {
     return I->getKind() == IK_ListInit;
   }
index 5c64d78..a0b15d5 100644 (file)
@@ -378,6 +378,10 @@ public:
     }
   }
 
+  // Disable use of sized deallocation due to overallocation of PPCOperand
+  // objects in CreateTokenWithStringCopy.
+  void operator delete(void *p) { ::operator delete(p); }
+
   /// getStartLoc - Get the location of the first token of this operand.
   SMLoc getStartLoc() const override { return StartLoc; }