[PATCH] D79401: [clang-format] [PR45639] clang-format splits up the brackets of C++17 attribute [[ ]] when used with the first parameter
MyDeveloperDay via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu May 7 14:09:58 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5a4ddbd69db2: [clang-format] [PR45639] clang-format splits up the brackets of C++17 attributeā¦ (authored by MyDeveloperDay).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79401/new/
https://reviews.llvm.org/D79401
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
@@ -7672,6 +7672,19 @@
MultiLineFunctions);
}
+TEST_F(FormatTest, AttributePenaltyBreaking) {
+ FormatStyle Style = getLLVMStyle();
+ verifyFormat("void ABCDEFGH::ABCDEFGHIJKLMN(\n"
+ " [[maybe_unused]] const shared_ptr<ALongTypeName> &C d) {}",
+ Style);
+ verifyFormat("void ABCDEFGH::ABCDEFGHIJK(\n"
+ " [[maybe_unused]] const shared_ptr<ALongTypeName> &C d) {}",
+ Style);
+ verifyFormat("void ABCDEFGH::ABCDEFGH([[maybe_unused]] const "
+ "shared_ptr<ALongTypeName> &C d) {\n}",
+ Style);
+}
+
TEST_F(FormatTest, UnderstandsEllipsis) {
verifyFormat("int printf(const char *fmt, ...);");
verifyFormat("template <class... Ts> void Foo(Ts... ts) { Foo(ts...); }");
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3888,7 +3888,7 @@
if (Right.is(tok::kw___attribute) ||
(Right.is(tok::l_square) && Right.is(TT_AttributeSquare)))
- return true;
+ return !Left.is(TT_AttributeSquare);
if (Left.is(tok::identifier) && Right.is(tok::string_literal))
return true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79401.262761.patch
Type: text/x-patch
Size: 1451 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200507/14d305ee/attachment.bin>
More information about the cfe-commits
mailing list