summaryrefslogtreecommitdiff
path: root/include/llvm/ADT/APInt.h
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2013-06-03 13:03:05 +0000
committerManuel Klimek <klimek@google.com>2013-06-03 13:03:05 +0000
commitabff3aa8217049cffe6da77c91e510c66b8c2313 (patch)
treebb733eb4d9b3fd6799811554fad43be8add63741 /include/llvm/ADT/APInt.h
parente7cbb792c95cb27a9704551579da19ebcaa06cdb (diff)
downloadllvm-abff3aa8217049cffe6da77c91e510c66b8c2313.tar.gz
llvm-abff3aa8217049cffe6da77c91e510c66b8c2313.tar.bz2
llvm-abff3aa8217049cffe6da77c91e510c66b8c2313.tar.xz
Introduce needsCleanup() for APFloat and APInt.
This is needed in clang so one can check if the object needs the destructor called after its memory was freed. This is useful when creating many APInt/APFloat objects with placement new, where the overhead of tracking the pointers for cleanup is significant. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183100 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/APInt.h')
-rw-r--r--include/llvm/ADT/APInt.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h
index a9df4036be..e5797b8be2 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;