[PATCH] D140767: [clang-format] Require space before noexcept qualifier
Emilia Dreamer via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 5 19:08:59 PST 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG54fab18cedac: [clang-format] Require space before noexcept qualifier (authored by rymiel).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140767/new/
https://reviews.llvm.org/D140767
Files:
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10566,10 +10566,10 @@
TEST_F(FormatTest, UnderstandsFunctionRefQualification) {
verifyFormat("void A::b() && {}");
- verifyFormat("void A::b() &&noexcept {}");
+ 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("Deleted &operator=(const Deleted &) & noexcept = default;");
verifyFormat("SomeType MemberFunction(const Deleted &) & = delete;");
verifyFormat("SomeType MemberFunction(const Deleted &) && = delete;");
verifyFormat("Deleted &operator=(const Deleted &) &;");
@@ -10579,16 +10579,16 @@
verifyFormat("SomeType MemberFunction(const Deleted &) && {}");
verifyFormat("SomeType MemberFunction(const Deleted &) && final {}");
verifyFormat("SomeType MemberFunction(const Deleted &) && override {}");
- verifyFormat("SomeType MemberFunction(const Deleted &) &&noexcept {}");
+ 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("void Fn(T const volatile &&) const volatile && noexcept;");
verifyFormat("template <typename T>\n"
"void F(T) && = delete;",
getGoogleStyle());
verifyFormat("template <typename T> void operator=(T) &;");
verifyFormat("template <typename T> void operator=(T) const &;");
- verifyFormat("template <typename T> void operator=(T) &noexcept;");
+ verifyFormat("template <typename T> void operator=(T) & noexcept;");
verifyFormat("template <typename T> void operator=(T) & = default;");
verifyFormat("template <typename T> void operator=(T) &&;");
verifyFormat("template <typename T> void operator=(T) && = delete;");
@@ -10678,31 +10678,31 @@
verifyFormat("struct f {\n"
" template <class T>\n"
- " int &foo(const std::string &str) &noexcept {}\n"
+ " int &foo(const std::string &str) & noexcept {}\n"
"};",
BreakTemplate);
verifyFormat("struct f {\n"
" template <class T>\n"
- " int &foo(const std::string &str) &&noexcept {}\n"
+ " int &foo(const std::string &str) && noexcept {}\n"
"};",
BreakTemplate);
verifyFormat("struct f {\n"
" template <class T>\n"
- " int &foo(const std::string &str) const &noexcept {}\n"
+ " int &foo(const std::string &str) const & noexcept {}\n"
"};",
BreakTemplate);
verifyFormat("struct f {\n"
" template <class T>\n"
- " int &foo(const std::string &str) const &noexcept {}\n"
+ " int &foo(const std::string &str) const & noexcept {}\n"
"};",
BreakTemplate);
verifyFormat("struct f {\n"
" template <class T>\n"
- " auto foo(const std::string &str) &&noexcept -> int & {}\n"
+ " auto foo(const std::string &str) && noexcept -> int & {}\n"
"};",
BreakTemplate);
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3530,7 +3530,8 @@
if (Right.is(TT_BlockComment))
return true;
// foo() -> const Bar * override/final
- if (Right.isOneOf(Keywords.kw_override, Keywords.kw_final) &&
+ if (Right.isOneOf(Keywords.kw_override, Keywords.kw_final,
+ tok::kw_noexcept) &&
!Right.is(TT_StartOfName)) {
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140767.486731.patch
Type: text/x-patch
Size: 4132 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230106/f3ba007d/attachment.bin>
More information about the cfe-commits
mailing list