[clang] a218706 - [clang-format] Add tests for spacing between ref-qualifier and `noexcept`. NFC.
Marek Kurdej via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 11 01:51:29 PST 2022
Author: Marek Kurdej
Date: 2022-02-11T10:50:05+01:00
New Revision: a218706cba90248be0c60bd6a8f10dbcf0270955
URL: https://github.com/llvm/llvm-project/commit/a218706cba90248be0c60bd6a8f10dbcf0270955
DIFF: https://github.com/llvm/llvm-project/commit/a218706cba90248be0c60bd6a8f10dbcf0270955.diff
LOG: [clang-format] Add tests for spacing between ref-qualifier and `noexcept`. NFC.
Cf. https://github.com/llvm/llvm-project/issues/44542.
Cf. https://github.com/llvm/llvm-project/commit/ae1b7859cbd61d2284d9690bc53482d0b6a46f63.
Added:
Modified:
clang/unittests/Format/FormatTest.cpp
Removed:
################################################################################
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 8639a72eceb12..aa50d73499d04 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -9589,8 +9589,11 @@ TEST_F(FormatTest, UnderstandsOverloadedOperators) {
}
TEST_F(FormatTest, UnderstandsFunctionRefQualification) {
+ verifyFormat("void A::b() && {}");
+ verifyFormat("void A::b() &&noexcept {}");
verifyFormat("Deleted &operator=(const Deleted &) & = default;");
verifyFormat("Deleted &operator=(const Deleted &) && = delete;");
+ verifyFormat("Deleted &operator=(const Deleted &) &noexcept = default;");
verifyFormat("SomeType MemberFunction(const Deleted &) & = delete;");
verifyFormat("SomeType MemberFunction(const Deleted &) && = delete;");
verifyFormat("Deleted &operator=(const Deleted &) &;");
@@ -9600,8 +9603,10 @@ TEST_F(FormatTest, UnderstandsFunctionRefQualification) {
verifyFormat("SomeType MemberFunction(const Deleted &) && {}");
verifyFormat("SomeType MemberFunction(const Deleted &) && final {}");
verifyFormat("SomeType MemberFunction(const Deleted &) && override {}");
+ verifyFormat("SomeType MemberFunction(const Deleted &) &&noexcept {}");
verifyFormat("void Fn(T const &) const &;");
verifyFormat("void Fn(T const volatile &&) const volatile &&;");
+ verifyFormat("void Fn(T const volatile &&) const volatile &&noexcept;");
verifyFormat("template <typename T>\n"
"void F(T) && = delete;",
getGoogleStyle());
@@ -9609,7 +9614,10 @@ TEST_F(FormatTest, UnderstandsFunctionRefQualification) {
FormatStyle AlignLeft = getLLVMStyle();
AlignLeft.PointerAlignment = FormatStyle::PAS_Left;
verifyFormat("void A::b() && {}", AlignLeft);
+ verifyFormat("void A::b() && noexcept {}", AlignLeft);
verifyFormat("Deleted& operator=(const Deleted&) & = default;", AlignLeft);
+ verifyFormat("Deleted& operator=(const Deleted&) & noexcept = default;",
+ AlignLeft);
verifyFormat("SomeType MemberFunction(const Deleted&) & = delete;",
AlignLeft);
verifyFormat("Deleted& operator=(const Deleted&) &;", AlignLeft);
@@ -9620,6 +9628,29 @@ TEST_F(FormatTest, UnderstandsFunctionRefQualification) {
verifyFormat("auto Function(T) & -> void;", AlignLeft);
verifyFormat("void Fn(T const&) const&;", AlignLeft);
verifyFormat("void Fn(T const volatile&&) const volatile&&;", AlignLeft);
+ verifyFormat("void Fn(T const volatile&&) const volatile&& noexcept;",
+ AlignLeft);
+
+ FormatStyle AlignMiddle = getLLVMStyle();
+ AlignMiddle.PointerAlignment = FormatStyle::PAS_Middle;
+ verifyFormat("void A::b() && {}", AlignMiddle);
+ verifyFormat("void A::b() && noexcept {}", AlignMiddle);
+ verifyFormat("Deleted & operator=(const Deleted &) & = default;",
+ AlignMiddle);
+ verifyFormat("Deleted & operator=(const Deleted &) & noexcept = default;",
+ AlignMiddle);
+ verifyFormat("SomeType MemberFunction(const Deleted &) & = delete;",
+ AlignMiddle);
+ verifyFormat("Deleted & operator=(const Deleted &) &;", AlignMiddle);
+ verifyFormat("SomeType MemberFunction(const Deleted &) &;", AlignMiddle);
+ verifyFormat("auto Function(T t) & -> void {}", AlignMiddle);
+ verifyFormat("auto Function(T... t) & -> void {}", AlignMiddle);
+ verifyFormat("auto Function(T) & -> void {}", AlignMiddle);
+ verifyFormat("auto Function(T) & -> void;", AlignMiddle);
+ verifyFormat("void Fn(T const &) const &;", AlignMiddle);
+ verifyFormat("void Fn(T const volatile &&) const volatile &&;", AlignMiddle);
+ verifyFormat("void Fn(T const volatile &&) const volatile && noexcept;",
+ AlignMiddle);
FormatStyle Spaces = getLLVMStyle();
Spaces.SpacesInCStyleCastParentheses = true;
More information about the cfe-commits
mailing list