diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/llvm/ADT/APFloat.h | 3 | ||||
| -rw-r--r-- | include/llvm/ADT/APInt.h | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/include/llvm/ADT/APFloat.h b/include/llvm/ADT/APFloat.h index 64e56a0..33f997e 100644 --- a/include/llvm/ADT/APFloat.h +++ b/include/llvm/ADT/APFloat.h @@ -201,6 +201,9 @@ public: /// @} + /// \brief Returns whether this instance allocated memory. + bool needsCleanup() const { return partCount() > 1; } + /// \name Convenience "constructors" /// @{ diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h index a9df403..e5797b8 100644 --- a/include/llvm/ADT/APInt.h +++ b/include/llvm/ADT/APInt.h @@ -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; |
