Skip to content

Commit a218706

Browse files
committed
[clang-format] Add tests for spacing between ref-qualifier and noexcept. NFC.
Cf. llvm#44542. Cf. llvm@ae1b785.
1 parent abc8736 commit a218706

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

clang/unittests/Format/FormatTest.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9589,8 +9589,11 @@ TEST_F(FormatTest, UnderstandsOverloadedOperators) {
95899589
}
95909590

95919591
TEST_F(FormatTest, UnderstandsFunctionRefQualification) {
9592+
verifyFormat("void A::b() && {}");
9593+
verifyFormat("void A::b() &&noexcept {}");
95929594
verifyFormat("Deleted &operator=(const Deleted &) & = default;");
95939595
verifyFormat("Deleted &operator=(const Deleted &) && = delete;");
9596+
verifyFormat("Deleted &operator=(const Deleted &) &noexcept = default;");
95949597
verifyFormat("SomeType MemberFunction(const Deleted &) & = delete;");
95959598
verifyFormat("SomeType MemberFunction(const Deleted &) && = delete;");
95969599
verifyFormat("Deleted &operator=(const Deleted &) &;");
@@ -9600,16 +9603,21 @@ TEST_F(FormatTest, UnderstandsFunctionRefQualification) {
96009603
verifyFormat("SomeType MemberFunction(const Deleted &) && {}");
96019604
verifyFormat("SomeType MemberFunction(const Deleted &) && final {}");
96029605
verifyFormat("SomeType MemberFunction(const Deleted &) && override {}");
9606+
verifyFormat("SomeType MemberFunction(const Deleted &) &&noexcept {}");
96039607
verifyFormat("void Fn(T const &) const &;");
96049608
verifyFormat("void Fn(T const volatile &&) const volatile &&;");
9609+
verifyFormat("void Fn(T const volatile &&) const volatile &&noexcept;");
96059610
verifyFormat("template <typename T>\n"
96069611
"void F(T) && = delete;",
96079612
getGoogleStyle());
96089613

96099614
FormatStyle AlignLeft = getLLVMStyle();
96109615
AlignLeft.PointerAlignment = FormatStyle::PAS_Left;
96119616
verifyFormat("void A::b() && {}", AlignLeft);
9617+
verifyFormat("void A::b() && noexcept {}", AlignLeft);
96129618
verifyFormat("Deleted& operator=(const Deleted&) & = default;", AlignLeft);
9619+
verifyFormat("Deleted& operator=(const Deleted&) & noexcept = default;",
9620+
AlignLeft);
96139621
verifyFormat("SomeType MemberFunction(const Deleted&) & = delete;",
96149622
AlignLeft);
96159623
verifyFormat("Deleted& operator=(const Deleted&) &;", AlignLeft);
@@ -9620,6 +9628,29 @@ TEST_F(FormatTest, UnderstandsFunctionRefQualification) {
96209628
verifyFormat("auto Function(T) & -> void;", AlignLeft);
96219629
verifyFormat("void Fn(T const&) const&;", AlignLeft);
96229630
verifyFormat("void Fn(T const volatile&&) const volatile&&;", AlignLeft);
9631+
verifyFormat("void Fn(T const volatile&&) const volatile&& noexcept;",
9632+
AlignLeft);
9633+
9634+
FormatStyle AlignMiddle = getLLVMStyle();
9635+
AlignMiddle.PointerAlignment = FormatStyle::PAS_Middle;
9636+
verifyFormat("void A::b() && {}", AlignMiddle);
9637+
verifyFormat("void A::b() && noexcept {}", AlignMiddle);
9638+
verifyFormat("Deleted & operator=(const Deleted &) & = default;",
9639+
AlignMiddle);
9640+
verifyFormat("Deleted & operator=(const Deleted &) & noexcept = default;",
9641+
AlignMiddle);
9642+
verifyFormat("SomeType MemberFunction(const Deleted &) & = delete;",
9643+
AlignMiddle);
9644+
verifyFormat("Deleted & operator=(const Deleted &) &;", AlignMiddle);
9645+
verifyFormat("SomeType MemberFunction(const Deleted &) &;", AlignMiddle);
9646+
verifyFormat("auto Function(T t) & -> void {}", AlignMiddle);
9647+
verifyFormat("auto Function(T... t) & -> void {}", AlignMiddle);
9648+
verifyFormat("auto Function(T) & -> void {}", AlignMiddle);
9649+
verifyFormat("auto Function(T) & -> void;", AlignMiddle);
9650+
verifyFormat("void Fn(T const &) const &;", AlignMiddle);
9651+
verifyFormat("void Fn(T const volatile &&) const volatile &&;", AlignMiddle);
9652+
verifyFormat("void Fn(T const volatile &&) const volatile && noexcept;",
9653+
AlignMiddle);
96239654

96249655
FormatStyle Spaces = getLLVMStyle();
96259656
Spaces.SpacesInCStyleCastParentheses = true;

0 commit comments

Comments
 (0)