[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:31:08 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeae445f65d07: [clang-format] PR50326 AlignAfterOpenBracket AlwaysBreak does not keep to theā¦ (authored by MyDeveloperDay).
Repository:
rG LLVM Github Monorepo
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,17 @@
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;
+ Spaces.IndentWidth = 4;
+ Spaces.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+ verifyFormat("void foo( ) {\n"
+ " size_t foo = (*(function))(\n"
+ " Foooo, Barrrrr, Foooo, Barrrr, FoooooooooLooooong, "
+ "BarrrrrrrrrrrrLong,\n"
+ " FoooooooooLooooong);\n"
+ "}",
+ Spaces);
Spaces.SpaceAfterCStyleCast = false;
verifyFormat("size_t idx = (size_t)(ptr - ((char *)file));", Spaces);
verifyFormat("size_t idx = (size_t)a;", Spaces);
@@ -13305,6 +13316,15 @@
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("void foo( ) {\n"
+ " size_t foo = (*(function))(\n"
+ " Foooo, Barrrrr, Foooo, Barrrr, FoooooooooLooooong, "
+ "BarrrrrrrrrrrrLong,\n"
+ " FoooooooooLooooong);\n"
+ "}",
+ 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.345621.patch
Type: text/x-patch
Size: 2534 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210515/c6cd4eb8/attachment-0001.bin>
More information about the cfe-commits
mailing list