#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/Support/DataTypes.h"
+#include "llvm/Support/MathExtras.h"
namespace clang {
/// getQuantity - Get the raw integer representation of this quantity.
QuantityType getQuantity() const { return Quantity; }
+ /// RoundUpToAlignment - Returns the next integer (mod 2**64) that is
+ /// greater than or equal to this quantity and is a multiple of \arg
+ /// Align. Align must be non-zero.
+ CharUnits RoundUpToAlignment(const CharUnits &Align) {
+ return CharUnits(llvm::RoundUpToAlignment(Quantity,
+ Align.Quantity));
+ }
+
}; // class CharUnit
} // namespace clang
// The runtime needs a minimum alignment of a void *.
CharUnits MinAlign = getContext().getTypeAlignInChars(getContext().VoidPtrTy);
- BlockOffset = CharUnits::fromQuantity(
- llvm::RoundUpToAlignment(BlockOffset.getQuantity(),
- MinAlign.getQuantity()));
+ BlockOffset = BlockOffset.RoundUpToAlignment(MinAlign);
Info.BlockSize = BlockOffset;
Info.BlockAlign = BlockAlign;
CharUnits OldOffset = BlockOffset;
// Ensure proper alignment, even if it means we have to have a gap
- BlockOffset = CharUnits::fromQuantity(
- llvm::RoundUpToAlignment(BlockOffset.getQuantity(), Align.getQuantity()));
+ BlockOffset = BlockOffset.RoundUpToAlignment(Align);
BlockAlign = std::max(Align, BlockAlign);
CharUnits Pad = BlockOffset - OldOffset;