This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6e77ba6c1e4d: [clang-format] Fix weird handling of
AfterColon (authored by HazardyKnusperkeks).
Changed prior to commit:
https://reviews.llvm.org/D158505?vs=552310&id=553004#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D158505/new/
https://reviews.llvm.org/D158505
Files:
clang/lib/Format/ContinuationIndenter.cpp
clang/unittests/Format/FormatTest.cpp
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7950,6 +7950,11 @@
verifyFormat("template <typename T>\n"
"Constructor() : Initializer(FitsOnTheLine) {}",
getStyleWithColumns(Style, 50));
+ verifyFormat(
+ "Class::Class(int some, int arguments, int loooooooooooooooooooong,\n"
+ " int mooooooooooooore) noexcept :\n"
+ " Super{some, arguments}, Member{5}, Member2{2} {}",
+ Style);
Style.PackConstructorInitializers = FormatStyle::PCIS_NextLine;
verifyFormat(
"SomeClass::Constructor() :\n"
@@ -7986,10 +7991,10 @@
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa),\n"
" aaaaaaaaaaaaaaa(aaaaaaaaaaaa) {}",
Style);
- verifyFormat("Constructor(aaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
- " aaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) :\n"
- " aaaaaaaaaa(aaaaaa) {}",
- Style);
+ verifyFormat(
+ "Ctor(aaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
+ " aaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) : aaaaaaaaaa(aaaaaa) {}",
+ Style);
verifyFormat("Constructor() :\n"
" aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa),\n"
Index: clang/lib/Format/ContinuationIndenter.cpp
===================================================================
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1492,6 +1492,8 @@
CurrentState.NestedBlockIndent = CurrentState.Indent;
if (Style.PackConstructorInitializers > FormatStyle::PCIS_BinPack)
CurrentState.AvoidBinPacking = true;
+ else
+ CurrentState.BreakBeforeParameter = false;
}
if (Current.is(TT_InheritanceColon)) {
CurrentState.Indent =
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7950,6 +7950,11 @@
verifyFormat("template <typename T>\n"
"Constructor() : Initializer(FitsOnTheLine) {}",
getStyleWithColumns(Style, 50));
+ verifyFormat(
+ "Class::Class(int some, int arguments, int loooooooooooooooooooong,\n"
+ " int mooooooooooooore) noexcept :\n"
+ " Super{some, arguments}, Member{5}, Member2{2} {}",
+ Style);
Style.PackConstructorInitializers = FormatStyle::PCIS_NextLine;
verifyFormat(
"SomeClass::Constructor() :\n"
@@ -7986,10 +7991,10 @@
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa),\n"
" aaaaaaaaaaaaaaa(aaaaaaaaaaaa) {}",
Style);
- verifyFormat("Constructor(aaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
- " aaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) :\n"
- " aaaaaaaaaa(aaaaaa) {}",
- Style);
+ verifyFormat(
+ "Ctor(aaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
+ " aaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) : aaaaaaaaaa(aaaaaa) {}",
+ Style);
verifyFormat("Constructor() :\n"
" aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa),\n"
Index: clang/lib/Format/ContinuationIndenter.cpp
===================================================================
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1492,6 +1492,8 @@
CurrentState.NestedBlockIndent = CurrentState.Indent;
if (Style.PackConstructorInitializers > FormatStyle::PCIS_BinPack)
CurrentState.AvoidBinPacking = true;
+ else
+ CurrentState.BreakBeforeParameter = false;
}
if (Current.is(TT_InheritanceColon)) {
CurrentState.Indent =
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits