=?utf-8?q?Tom=C3=A1=C5=A1?= Slanina ,
=?utf-8?q?Tom=C3=A1=C5=A1?= Slanina ,
=?utf-8?q?Tom=C3=A1=C5=A1?= Slanina ,
=?utf-8?q?Tom=C3=A1=C5=A1?= Slanina ,
=?utf-8?q?Tom=C3=A1=C5=A1?= Slanina ,
=?utf-8?q?Tom=C3=A1=C5=A1?= Slanina
Message-ID:
In-Reply-To:
brandb97 wrote:
> See #151428. Maybe there'
https://github.com/brandb97 updated
https://github.com/llvm/llvm-project/pull/151428
>From 3a0a246803cdf295c99765bfffd5905c2a94ab38 Mon Sep 17 00:00:00 2001
From: Lidong Yan
Date: Tue, 26 Aug 2025 19:40:05 +0800
Subject: [PATCH] [clang-format] allow short function body on a single line
When se
@@ -251,10 +251,15 @@ class LineJoiner {
: Limit - TheLine->Last->TotalLength;
if (TheLine->Last->is(TT_FunctionLBrace) &&
-TheLine->First == TheLine->Last &&
-!Style.BraceWrapping.SplitEmptyFunction &&
-NextLine.First->is(tok::r_bra
https://github.com/brandb97 updated
https://github.com/llvm/llvm-project/pull/151428
>From f024cf1ea515d3218c87300ca6563392fb74b8a2 Mon Sep 17 00:00:00 2001
From: Lidong Yan
Date: Tue, 26 Aug 2025 19:40:05 +0800
Subject: [PATCH] [clang-format] allow short function body on a single line
When se
brandb97 wrote:
@owenca That's totally fine, I will try to simplify my code.
https://github.com/llvm/llvm-project/pull/151428
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -510,27 +515,50 @@ class LineJoiner {
// Try to merge a function block with left brace wrapped.
if (NextLine.First->is(TT_FunctionLBrace) &&
-Style.BraceWrapping.AfterFunction) {
+(Style.BraceWrapping.AfterFunction ||
+ Style.AllowShortBlocks
https://github.com/brandb97 updated
https://github.com/llvm/llvm-project/pull/151428
>From 8df95ae522547ba1c4fdd61481bbfcbfa902eec6 Mon Sep 17 00:00:00 2001
From: Lidong Yan
Date: Mon, 25 Aug 2025 13:19:22 +0800
Subject: [PATCH] [clang-format] allow short function bodies on a single line
When
@@ -510,27 +515,50 @@ class LineJoiner {
// Try to merge a function block with left brace wrapped.
if (NextLine.First->is(TT_FunctionLBrace) &&
-Style.BraceWrapping.AfterFunction) {
+(Style.BraceWrapping.AfterFunction ||
+ Style.AllowShortBlocks
https://github.com/brandb97 updated
https://github.com/llvm/llvm-project/pull/151428
>From 8df95ae522547ba1c4fdd61481bbfcbfa902eec6 Mon Sep 17 00:00:00 2001
From: Lidong Yan
Date: Mon, 25 Aug 2025 13:19:22 +0800
Subject: [PATCH] [clang-format] allow short function bodies on a single line
When
https://github.com/brandb97 updated
https://github.com/llvm/llvm-project/pull/151428
>From 0c5bc1a66d35cda6f09c118652f3cf529c28c200 Mon Sep 17 00:00:00 2001
From: Lidong Yan
Date: Mon, 25 Aug 2025 13:19:22 +0800
Subject: [PATCH] [clang-format] allow short function bodies on a single line
When
@@ -510,27 +515,50 @@ class LineJoiner {
// Try to merge a function block with left brace wrapped.
if (NextLine.First->is(TT_FunctionLBrace) &&
-Style.BraceWrapping.AfterFunction) {
+(Style.BraceWrapping.AfterFunction ||
+ Style.AllowShortBlocks
https://github.com/brandb97 updated
https://github.com/llvm/llvm-project/pull/151428
>From 7cdbee9b9e2cc75e3f3260edefc62b717e42d734 Mon Sep 17 00:00:00 2001
From: Lidong Yan
Date: Mon, 25 Aug 2025 13:19:22 +0800
Subject: [PATCH] [clang-format] allow short function bodies on a single line
When
https://github.com/brandb97 updated
https://github.com/llvm/llvm-project/pull/151428
>From e5a880be235eaac041252d6b48600198bfaed7ca Mon Sep 17 00:00:00 2001
From: Lidong Yan
Date: Fri, 22 Aug 2025 23:31:28 +0800
Subject: [PATCH] [clang-format] allow short function bodies on a single line
When
brandb97 wrote:
@owenca Can you help review my code? Thank you very much.
https://github.com/llvm/llvm-project/pull/151428
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/brandb97 updated
https://github.com/llvm/llvm-project/pull/151428
>From 04cd330ab306e6718cf96ff3d29b446d35424a5e Mon Sep 17 00:00:00 2001
From: Lidong Yan
Date: Fri, 22 Aug 2025 23:31:28 +0800
Subject: [PATCH] [clang-format] allow short function bodies on a single line
When
brandb97 wrote:
I see, I’ll rewrite this part of the code.
https://github.com/llvm/llvm-project/pull/151428
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
brandb97 wrote:
@owenca I actually think adding a new option would be better. The reason is
that when users want to specify putting function bodies on a single line,
without a new option, they would have to set
AllowShortFunctionsOnASingleLine: Never
AllowShortBlocksOnASingleLine: Always
Bu
brandb97 wrote:
I can just fix the bug by moving `PutShortFunctionBodiesOnASingleLine` to
private area in FormatStyle and set `PutShortFunctionBodiesOnASingleLine` to
`Always` if and only if `AllowShortFunctionsOnASingleLine` is `Never` and
`AllowShortBlocksOnASingleLine` is `Always`. Is that
brandb97 wrote:
Sorry, I promised to add enum PutShortFunctionBodiesOnASingleLine option, but I
haven’t touched this code in quite a while (due to summer vacation). It seems
the requirements have changed since then, so maybe it was a good thing I didn’t
write it after all? ;-)
https://github.
@@ -3829,6 +3829,23 @@ struct FormatStyle {
/// \version 13
int PPIndentWidth;
+ /// Dependent on the value, function body can be put on a single line.
+ /// Automatically enabled when
+ /// `AllowShortFunctionsOnASingleLine` is set to `None` and
+ /// `AllowShortBlock
@@ -3829,6 +3829,23 @@ struct FormatStyle {
/// \version 13
int PPIndentWidth;
+ /// Dependent on the value, function body can be put on a single line.
+ /// Automatically enabled when
+ /// `AllowShortFunctionsOnASingleLine` is set to `None` and
+ /// `AllowShortBlock
@@ -242,13 +242,13 @@ class LineJoiner {
if (Style.ColumnLimit > 0 && Indent > Style.ColumnLimit)
return 0;
-unsigned Limit =
+unsigned LimitStripIndent =
brandb97 wrote:
Of course, will update soon.
https://github.com/llvm/llvm-project/pul
brandb97 wrote:
ping
https://github.com/llvm/llvm-project/pull/151428
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/brandb97 updated
https://github.com/llvm/llvm-project/pull/151428
>From 25d45a4ffce718a6a4086d3cd5802d8ff7972164 Mon Sep 17 00:00:00 2001
From: Lidong Yan
Date: Tue, 5 Aug 2025 15:49:41 +0800
Subject: [PATCH] [clang-format] allow short function body on a single line
clang-fo
@@ -1921,6 +1921,10 @@ void UnwrappedLineParser::parseStructuralElement(
}
} else if (Style.BraceWrapping.AfterFunction) {
addUnwrappedLine();
+} else if (Style.AllowShortFunctionBodiesOnASingleLine) {
+ // Wrap the left brace here;
@@ -1921,6 +1921,10 @@ void UnwrappedLineParser::parseStructuralElement(
}
} else if (Style.BraceWrapping.AfterFunction) {
addUnwrappedLine();
+} else if (Style.AllowShortFunctionBodiesOnASingleLine) {
+ // Wrap the left brace here;
@@ -532,6 +538,20 @@ class LineJoiner {
}
return MergedLines;
}
+
+// Previously, UnwrappedLineParser would move the left brace to a new line
+// when AllowShortFunctionBodiesOnASingleLine is enabled. However, if the
+// function body cannot fit on a
@@ -532,6 +538,20 @@ class LineJoiner {
}
return MergedLines;
}
+
+// Previously, UnwrappedLineParser would move the left brace to a new line
brandb97 wrote:
Thank you for kindly explaining how to write proper comment, I will change it
in
@@ -878,6 +878,12 @@ struct FormatStyle {
/// \version 3.5
ShortFunctionStyle AllowShortFunctionsOnASingleLine;
+ /// Dependent on the value, function body like ``{ return 0; }`` can be
+ /// put on a single line. Only when AllowShortFunctionsOnASingleLine = None
+ ///
@@ -878,6 +878,12 @@ struct FormatStyle {
/// \version 3.5
ShortFunctionStyle AllowShortFunctionsOnASingleLine;
+ /// Dependent on the value, function body like ``{ return 0; }`` can be
+ /// put on a single line. Only when AllowShortFunctionsOnASingleLine = None
+ ///
30 matches
Mail list logo