diff --git a/llvm/include/llvm/Support/Alignment.h b/llvm/include/llvm/Support/Alignment.h --- a/llvm/include/llvm/Support/Alignment.h +++ b/llvm/include/llvm/Support/Alignment.h @@ -55,7 +55,7 @@ public: /// Default is byte-aligned. - Align() = default; + constexpr Align() = default; /// Do not perform checks in case of copy/move construct/assign, because the /// checks have been performed when building `Other`. Align(const Align &Other) = default; @@ -73,6 +73,8 @@ /// This is a hole in the type system and should not be abused. /// Needed to interact with C for instance. uint64_t value() const { return uint64_t(1) << ShiftValue; } + + constexpr static const Align None() { return llvm::Align(); } }; /// Treats the value 0 as a 1, so Align is always at least 1. diff --git a/llvm/unittests/Support/AlignmentTest.cpp b/llvm/unittests/Support/AlignmentTest.cpp --- a/llvm/unittests/Support/AlignmentTest.cpp +++ b/llvm/unittests/Support/AlignmentTest.cpp @@ -28,7 +28,10 @@ return Out; } -TEST(AlignmentTest, AlignDefaultCTor) { EXPECT_EQ(Align().value(), 1ULL); } +TEST(AlignmentTest, AlignDefaultCTor) { + EXPECT_EQ(Align().value(), 1ULL); + EXPECT_EQ(Align::None().value(), 1ULL); +} TEST(AlignmentTest, MaybeAlignDefaultCTor) { EXPECT_FALSE(MaybeAlign().hasValue());