[PATCH] D102392: [clang-format] PR50326 AlignAfterOpenBracket AlwaysBreak does not keep to the ColumnLimit
MyDeveloperDay via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat May 15 03:15:22 PDT 2021
MyDeveloperDay updated this revision to Diff 345619.
MyDeveloperDay added a comment.
Add a test that shows it no longer impacts function ptrs
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102392/new/
https://reviews.llvm.org/D102392
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
@@ -13298,6 +13298,13 @@
verifyFormat("size_t idx = (a->*foo)(a - 1);", Spaces);
verifyFormat("size_t idx = (a->foo)(a - 1);", Spaces);
verifyFormat("size_t idx = (*foo)(a - 1);", Spaces);
+ verifyFormat("size_t idx = (*(foo))(a - 1);", Spaces);
+ Spaces.ColumnLimit = 80;
+ verifyFormat(
+ "size_t foo = (*(function))(Foooo, Barrrrr, Foooo, Barrrr, "
+ "FoooooooooLooooong,\n"
+ " BarrrrrrrrrrrrLong, FoooooooooLooooong);",
+ Spaces);
Spaces.SpaceAfterCStyleCast = false;
verifyFormat("size_t idx = (size_t)(ptr - ((char *)file));", Spaces);
verifyFormat("size_t idx = (size_t)a;", Spaces);
@@ -13305,6 +13312,13 @@
verifyFormat("size_t idx = (a->*foo)(a - 1);", Spaces);
verifyFormat("size_t idx = (a->foo)(a - 1);", Spaces);
verifyFormat("size_t idx = (*foo)(a - 1);", Spaces);
+ verifyFormat("size_t idx = (*(foo))(a - 1);", Spaces);
+
+ verifyFormat(
+ "size_t foo = (*(function))(Foooo, Barrrrr, Foooo, Barrrr, "
+ "FoooooooooLooooong,\n"
+ " BarrrrrrrrrrrrLong, FoooooooooLooooong);",
+ Spaces);
}
TEST_F(FormatTest, ConfigurableSpacesInSquareBrackets) {
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1907,12 +1907,12 @@
if (Tok.Next->isOneOf(tok::identifier, tok::kw_this))
return true;
- if (Tok.Next->is(tok::l_paren) &&
- !(Tok.Previous && Tok.Previous->is(tok::identifier) &&
- Tok.Previous->Previous &&
- Tok.Previous->Previous->isOneOf(tok::arrowstar, tok::arrow,
- tok::star)))
- return true;
+ // Look for a cast `( x ) (`.
+ if (Tok.Next->is(tok::l_paren) && Tok.Previous && Tok.Previous->Previous) {
+ if (Tok.Previous->is(tok::identifier) &&
+ Tok.Previous->Previous->is(tok::l_paren))
+ return true;
+ }
if (!Tok.Next->Next)
return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102392.345619.patch
Type: text/x-patch
Size: 2265 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210515/edff5274/attachment.bin>
More information about the cfe-commits
mailing list