1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

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.

llvm-svn: 183100
This commit is contained in:
Manuel Klimek 2013-06-03 13:03:05 +00:00
parent 2d5d39937e
commit 77c6916919
3 changed files with 8 additions and 2 deletions

View File

@ -201,6 +201,9 @@ public:
/// @}
/// \brief Returns whether this instance allocated memory.
bool needsCleanup() const { return partCount() > 1; }
/// \name Convenience "constructors"
/// @{

View 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;

View File

@ -580,7 +580,7 @@ APFloat::initialize(const fltSemantics *ourSemantics)
void
APFloat::freeSignificand()
{
if (partCount() > 1)
if (needsCleanup())
delete [] significand.parts;
}