[all-commits] [llvm/llvm-project] 65c5c9: ADT: Rely on std::aligned_union_t for math in Alig...

Duncan P. N. Exon Smith via All-commits all-commits at lists.llvm.org
Wed Dec 2 15:56:34 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 65c5c9f92ec514ae41c8ea407d1c885737d699ec
      https://github.com/llvm/llvm-project/commit/65c5c9f92ec514ae41c8ea407d1c885737d699ec
  Author: Duncan P. N. Exon Smith <dexonsmith at apple.com>
  Date:   2020-12-02 (Wed, 02 Dec 2020)

  Changed paths:
    M llvm/include/llvm/Support/AlignOf.h

  Log Message:
  -----------
  ADT: Rely on std::aligned_union_t for math in AlignedCharArrayUnion, NFC

Instead of computing the alignment and size of the `char` buffer in
`AlignedCharArrayUnion`, rely on the math in `std::aligned_union_t`.
Because some users of this rely on the `buffer` field existing with a
type convertible to `char *`, we can't change the field type, but we can
still avoid duplicating the logic.

A potential follow up would be to delete `AlignedCharArrayUnion` after
updating its users to use `std::aligned_union_t` directly; or if we like
our template parameters better, could update users to stop peeking
inside and then replace the definition with:
```
template <class T, class... Ts>
using AlignedCharArrayUnion = std::aligned_union_t<1, T, Ts...>;
```

Differential Revision: https://reviews.llvm.org/D92500




More information about the All-commits mailing list