[clang] [clang-format] Fix a regression in `PointerAlignment: Left` (PR #124085)

2025-02-11 Thread via cfe-commits

llvmbot wrote:


Failed to cherry-pick: 6330f1e052dbec842e0d12e3d0cc44996e8663d2

https://github.com/llvm/llvm-project/actions/runs/13277229863

Please manually backport the fix and push it to your github fork.  Once this is 
done, please create a [pull 
request](https://github.com/llvm/llvm-project/compare)

https://github.com/llvm/llvm-project/pull/124085
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix a regression in `PointerAlignment: Left` (PR #124085)

2025-02-11 Thread Owen Pan via cfe-commits

owenca wrote:

/cherry-pick 6330f1e052dbec842e0d12e3d0cc44996e8663d2

https://github.com/llvm/llvm-project/pull/124085
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix a regression in `PointerAlignment: Left` (PR #124085)

2025-02-11 Thread Owen Pan via cfe-commits

https://github.com/owenca milestoned 
https://github.com/llvm/llvm-project/pull/124085
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix a regression in `PointerAlignment: Left` (PR #124085)

2025-01-23 Thread Owen Pan via cfe-commits

https://github.com/owenca closed 
https://github.com/llvm/llvm-project/pull/124085
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix a regression in `PointerAlignment: Left` (PR #124085)

2025-01-23 Thread Björn Schäpers via cfe-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/124085
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix a regression in `PointerAlignment: Left` (PR #124085)

2025-01-23 Thread Emilia Kond via cfe-commits

https://github.com/rymiel approved this pull request.


https://github.com/llvm/llvm-project/pull/124085
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix a regression in `PointerAlignment: Left` (PR #124085)

2025-01-23 Thread via cfe-commits

https://github.com/mydeveloperday approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/124085
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix a regression in `PointerAlignment: Left` (PR #124085)

2025-01-22 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: Owen Pan (owenca)


Changes

Don't insert a space between a type declaration r_paren and &/&&.

Fixes #124073.

---
Full diff: https://github.com/llvm/llvm-project/pull/124085.diff


2 Files Affected:

- (modified) clang/lib/Format/TokenAnnotator.cpp (+2-2) 
- (modified) clang/unittests/Format/FormatTest.cpp (+1-1) 


``diff
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index bf5ee281c43119..f36cf7b638e0d2 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -5488,8 +5488,8 @@ bool TokenAnnotator::spaceRequiredBefore(const 
AnnotatedLine &Line,
   }
   if ((Left.is(TT_TemplateOpener)) != (Right.is(TT_TemplateCloser)))
 return ShouldAddSpacesInAngles();
-  if (Left.is(tok::r_paren) && Right.is(TT_PointerOrReference) &&
-  Right.isOneOf(tok::amp, tok::ampamp)) {
+  if (Left.is(tok::r_paren) && Left.isNot(TT_TypeDeclarationParen) &&
+  Right.is(TT_PointerOrReference) && Right.isOneOf(tok::amp, tok::ampamp)) 
{
 return true;
   }
   // Space before TT_StructuredBindingLSquare.
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 61aa140dfdc9c0..265461561d2012 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -2084,7 +2084,6 @@ TEST_F(FormatTest, SeparatePointerReferenceAlignment) {
Style);
 
   Style.PointerAlignment = FormatStyle::PAS_Left;
-  Style.ReferenceAlignment = FormatStyle::RAS_Pointer;
   verifyFormat("int* f1(int* a, int& b, int&& c);", Style);
   verifyFormat("int& f2(int&& c, int* a, int& b);", Style);
   verifyFormat("int&& f3(int& b, int&& c, int* a);", Style);
@@ -2118,6 +2117,7 @@ TEST_F(FormatTest, SeparatePointerReferenceAlignment) {
   "function res1 = [](int& a) { return 0; },\n"
   "res2 = [](int& a) { return 0; };",
   Style);
+  verifyFormat("[](decltype(foo)& Bar) {}", Style);
 
   Style.AlignConsecutiveDeclarations.Enabled = true;
   Style.AlignConsecutiveDeclarations.AlignFunctionPointers = true;

``




https://github.com/llvm/llvm-project/pull/124085
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix a regression in `PointerAlignment: Left` (PR #124085)

2025-01-22 Thread Owen Pan via cfe-commits

https://github.com/owenca created 
https://github.com/llvm/llvm-project/pull/124085

Don't insert a space between a type declaration r_paren and &/&&.

Fixes #124073.

>From 4a6d68388874e9b59936870b5c2c7d680a6bddc2 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Wed, 22 Jan 2025 23:38:47 -0800
Subject: [PATCH] [clang-format] Fix a regression in `PointerAlignment: Left`

Don't insert a space between a type declaration r_paren and &/&&.

Fixes #124073.
---
 clang/lib/Format/TokenAnnotator.cpp   | 4 ++--
 clang/unittests/Format/FormatTest.cpp | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index bf5ee281c43119..f36cf7b638e0d2 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -5488,8 +5488,8 @@ bool TokenAnnotator::spaceRequiredBefore(const 
AnnotatedLine &Line,
   }
   if ((Left.is(TT_TemplateOpener)) != (Right.is(TT_TemplateCloser)))
 return ShouldAddSpacesInAngles();
-  if (Left.is(tok::r_paren) && Right.is(TT_PointerOrReference) &&
-  Right.isOneOf(tok::amp, tok::ampamp)) {
+  if (Left.is(tok::r_paren) && Left.isNot(TT_TypeDeclarationParen) &&
+  Right.is(TT_PointerOrReference) && Right.isOneOf(tok::amp, tok::ampamp)) 
{
 return true;
   }
   // Space before TT_StructuredBindingLSquare.
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 61aa140dfdc9c0..265461561d2012 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -2084,7 +2084,6 @@ TEST_F(FormatTest, SeparatePointerReferenceAlignment) {
Style);
 
   Style.PointerAlignment = FormatStyle::PAS_Left;
-  Style.ReferenceAlignment = FormatStyle::RAS_Pointer;
   verifyFormat("int* f1(int* a, int& b, int&& c);", Style);
   verifyFormat("int& f2(int&& c, int* a, int& b);", Style);
   verifyFormat("int&& f3(int& b, int&& c, int* a);", Style);
@@ -2118,6 +2117,7 @@ TEST_F(FormatTest, SeparatePointerReferenceAlignment) {
   "function res1 = [](int& a) { return 0; },\n"
   "res2 = [](int& a) { return 0; };",
   Style);
+  verifyFormat("[](decltype(foo)& Bar) {}", Style);
 
   Style.AlignConsecutiveDeclarations.Enabled = true;
   Style.AlignConsecutiveDeclarations.AlignFunctionPointers = true;

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits