Skip to content

Commit

Permalink
DynamicAPInt: move static_assert_layout to cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
artagnon committed Jul 6, 2024
1 parent 71fcd1e commit 0b6272e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 1 addition & 7 deletions llvm/include/llvm/ADT/DynamicAPInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,7 @@ class DynamicAPInt {

friend hash_code hash_value(const DynamicAPInt &x); // NOLINT

void static_assert_layout() { // NOLINT
constexpr size_t ValLargeOff =
offsetof(DynamicAPInt, ValLarge.Val.BitWidth);
constexpr size_t ValSmallOff = offsetof(DynamicAPInt, ValSmall);
constexpr size_t ValSmallSz = sizeof(ValSmall);
static_assert(ValLargeOff >= ValSmallOff + ValSmallSz);
}
void static_assert_layout(); // NOLINT

raw_ostream &print(raw_ostream &OS) const;
LLVM_DUMP_METHOD void dump() const;
Expand Down
8 changes: 8 additions & 0 deletions llvm/lib/Support/DynamicAPInt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ hash_code llvm::hash_value(const DynamicAPInt &X) {
return detail::hash_value(X.getLarge());
}

void DynamicAPInt::static_assert_layout() {
constexpr size_t ValLargeOffset =
offsetof(DynamicAPInt, ValLarge.Val.BitWidth);
constexpr size_t ValSmallOffset = offsetof(DynamicAPInt, ValSmall);
constexpr size_t ValSmallSize = sizeof(ValSmall);
static_assert(ValLargeOffset >= ValSmallOffset + ValSmallSize);
}

raw_ostream &DynamicAPInt::print(raw_ostream &OS) const {
if (isSmall())
return OS << ValSmall;
Expand Down

0 comments on commit 0b6272e

Please sign in to comment.