Introduce needsCleanup() for APFloat and APInt.
[oota-llvm.git] / include / llvm / ADT / APInt.h
index a9df4036be2d90047594e35b7cc560d1fe8b1331..e5797b8be238e45665e775711b1cd63665dfbefe 100644 (file)
@@ -293,7 +293,7 @@ public:
 
   /// \brief Destructor.
   ~APInt() {
-    if (!isSingleWord())
+    if (needsCleanup())
       delete[] pVal;
   }
 
@@ -303,6 +303,9 @@ public:
   ///  method Read).
   explicit APInt() : BitWidth(1) {}
 
+  /// \brief Returns whether this instance allocated memory.
+  bool needsCleanup() const { return !isSingleWord(); }
+
   /// Used to insert APInt objects, or objects that contain APInt objects, into
   ///  FoldingSets.
   void Profile(FoldingSetNodeID &id) const;