[PATCH] D157179: [clang-format] Currectly handle PCIS_CurrentLine with no column limit

2023-08-06 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa0b1c235afab: [clang-format] Currectly handle 
PCIS_CurrentLine with no column limit (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157179/new/

https://reviews.llvm.org/D157179

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
@@ -7758,6 +7758,13 @@
"(a),\n"
"b(b) {}",
Style);
+
+  Style = getLLVMStyleWithColumns(0);
+  Style.PackConstructorInitializers = FormatStyle::PCIS_CurrentLine;
+  verifyFormat("Foo(Bar bar, Baz baz) : bar(bar), baz(baz) {}", Style);
+  verifyNoChange("Foo(Bar bar, Baz baz)\n"
+ ": bar(bar), baz(baz) {}",
+ Style);
 }
 
 TEST_F(FormatTest, AllowAllArgumentsOnNextLine) {
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1437,6 +1437,7 @@
 if (Style.PackConstructorInitializers > FormatStyle::PCIS_BinPack) {
   CurrentState.AvoidBinPacking = true;
   CurrentState.BreakBeforeParameter =
+  Style.ColumnLimit > 0 &&
   Style.PackConstructorInitializers != FormatStyle::PCIS_NextLine &&
   Style.PackConstructorInitializers != FormatStyle::PCIS_NextLineOnly;
 } else {


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7758,6 +7758,13 @@
"(a),\n"
"b(b) {}",
Style);
+
+  Style = getLLVMStyleWithColumns(0);
+  Style.PackConstructorInitializers = FormatStyle::PCIS_CurrentLine;
+  verifyFormat("Foo(Bar bar, Baz baz) : bar(bar), baz(baz) {}", Style);
+  verifyNoChange("Foo(Bar bar, Baz baz)\n"
+ ": bar(bar), baz(baz) {}",
+ Style);
 }
 
 TEST_F(FormatTest, AllowAllArgumentsOnNextLine) {
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1437,6 +1437,7 @@
 if (Style.PackConstructorInitializers > FormatStyle::PCIS_BinPack) {
   CurrentState.AvoidBinPacking = true;
   CurrentState.BreakBeforeParameter =
+  Style.ColumnLimit > 0 &&
   Style.PackConstructorInitializers != FormatStyle::PCIS_NextLine &&
   Style.PackConstructorInitializers != FormatStyle::PCIS_NextLineOnly;
 } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157179: [clang-format] Currectly handle PCIS_CurrentLine with no column limit

2023-08-05 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
Herald added projects: All, clang, clang-format.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, HazardyKnusperkeks, MyDeveloperDay.
owenpan requested review of this revision.

Fixes https://github.com/llvm/llvm-project/issues/63519.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157179

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
@@ -7758,6 +7758,13 @@
"(a),\n"
"b(b) {}",
Style);
+
+  Style = getLLVMStyleWithColumns(0);
+  Style.PackConstructorInitializers = FormatStyle::PCIS_CurrentLine;
+  verifyFormat("Foo(Bar bar, Baz baz) : bar(bar), baz(baz) {}", Style);
+  verifyNoChange("Foo(Bar bar, Baz baz)\n"
+ ": bar(bar), baz(baz) {}",
+ Style);
 }
 
 TEST_F(FormatTest, AllowAllArgumentsOnNextLine) {
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1437,6 +1437,7 @@
 if (Style.PackConstructorInitializers > FormatStyle::PCIS_BinPack) {
   CurrentState.AvoidBinPacking = true;
   CurrentState.BreakBeforeParameter =
+  Style.ColumnLimit > 0 &&
   Style.PackConstructorInitializers != FormatStyle::PCIS_NextLine &&
   Style.PackConstructorInitializers != FormatStyle::PCIS_NextLineOnly;
 } else {


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7758,6 +7758,13 @@
"(a),\n"
"b(b) {}",
Style);
+
+  Style = getLLVMStyleWithColumns(0);
+  Style.PackConstructorInitializers = FormatStyle::PCIS_CurrentLine;
+  verifyFormat("Foo(Bar bar, Baz baz) : bar(bar), baz(baz) {}", Style);
+  verifyNoChange("Foo(Bar bar, Baz baz)\n"
+ ": bar(bar), baz(baz) {}",
+ Style);
 }
 
 TEST_F(FormatTest, AllowAllArgumentsOnNextLine) {
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1437,6 +1437,7 @@
 if (Style.PackConstructorInitializers > FormatStyle::PCIS_BinPack) {
   CurrentState.AvoidBinPacking = true;
   CurrentState.BreakBeforeParameter =
+  Style.ColumnLimit > 0 &&
   Style.PackConstructorInitializers != FormatStyle::PCIS_NextLine &&
   Style.PackConstructorInitializers != FormatStyle::PCIS_NextLineOnly;
 } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits