Skip to content

Conversation

@PiJoules
Copy link
Contributor

Reverts #164048

This led to a regression in clang-format where a space gets added in between the parameter type and &. For example, this

::test_anonymous::FunctionApplication& ::test_anonymous::FunctionApplication::operator=(const ::test_anonymous::FunctionApplication& other) noexcept {

becomes

::test_anonymous::FunctionApplication& ::test_anonymous::FunctionApplication::operator=(const ::test_anonymous::FunctionApplication & other) noexcept {

@llvmbot
Copy link
Member

llvmbot commented Oct 22, 2025

@llvm/pr-subscribers-clang-format

Author: None (PiJoules)

Changes

Reverts llvm/llvm-project#164048

This led to a regression in clang-format where a space gets added in between the parameter type and &. For example, this

::test_anonymous::FunctionApplication& ::test_anonymous::FunctionApplication::operator=(const ::test_anonymous::FunctionApplication& other) noexcept {

becomes

::test_anonymous::FunctionApplication& ::test_anonymous::FunctionApplication::operator=(const ::test_anonymous::FunctionApplication & other) noexcept {

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

2 Files Affected:

  • (modified) clang/lib/Format/TokenAnnotator.cpp (+7-3)
  • (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (-5)
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index c97a9e81eb59e..25971d2497f97 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3791,12 +3791,18 @@ static bool isFunctionDeclarationName(const LangOptions &LangOpts,
   if (Current.is(TT_FunctionDeclarationName))
     return true;
 
-  if (Current.isNoneOf(tok::identifier, tok::kw_operator))
+  if (!Current.Tok.getIdentifierInfo())
     return false;
 
   const auto *Prev = Current.getPreviousNonComment();
   assert(Prev);
 
+  if (Prev->is(tok::coloncolon))
+    Prev = Prev->Previous;
+
+  if (!Prev)
+    return false;
+
   const auto &Previous = *Prev;
 
   if (const auto *PrevPrev = Previous.getPreviousNonComment();
@@ -3845,8 +3851,6 @@ static bool isFunctionDeclarationName(const LangOptions &LangOpts,
 
   // Find parentheses of parameter list.
   if (Current.is(tok::kw_operator)) {
-    if (Line.startsWith(tok::kw_friend))
-      return true;
     if (Previous.Tok.getIdentifierInfo() &&
         Previous.isNoneOf(tok::kw_return, tok::kw_co_return)) {
       return true;
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp
index ca99940890984..f3637383a0a65 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -1129,11 +1129,6 @@ TEST_F(TokenAnnotatorTest, UnderstandsOverloadedOperators) {
   ASSERT_EQ(Tokens.size(), 7u) << Tokens;
   // Not TT_FunctionDeclarationName.
   EXPECT_TOKEN(Tokens[3], tok::kw_operator, TT_Unknown);
-
-  Tokens = annotate("SomeAPI::operator()();");
-  ASSERT_EQ(Tokens.size(), 9u) << Tokens;
-  // Not TT_FunctionDeclarationName.
-  EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_Unknown);
 }
 
 TEST_F(TokenAnnotatorTest, OverloadedOperatorInTemplate) {

@github-actions
Copy link

⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
Please turn off Keep my email addresses private setting in your account.
See LLVM Developer Policy and LLVM Discourse for more information.

Copy link
Contributor

@frobtech frobtech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a clear regression. I hope we can get a regression test case added to catch it.

Copy link
Contributor

@frobtech frobtech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a clear regression. I hope we can get a regression test case added to catch it.

@PiJoules PiJoules enabled auto-merge (squash) October 22, 2025 17:39
@PiJoules PiJoules merged commit 99abda7 into main Oct 22, 2025
9 of 11 checks passed
@PiJoules PiJoules deleted the revert-164048-overload-operator branch October 22, 2025 18:00
@HazardyKnusperkeks
Copy link
Contributor

It was that urgent, that you couldn't wait for someone to handle it correctly?

@Prabhuk
Copy link
Contributor

Prabhuk commented Oct 22, 2025

It was that urgent, that you couldn't wait for someone to handle it correctly?

Please check the developer policy on patch reversion if you have not done so already: https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy

@owenca
Copy link
Contributor

owenca commented Oct 23, 2025

This is a clear regression. I hope we can get a regression test case added to catch it.

No, it's not. See #164048 (comment).

It was that urgent, that you couldn't wait for someone to handle it correctly?

Please check the developer policy on patch reversion if you have not done so already: https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy

The relevant parts of the policy that show why you shouldn't have reverted:

  • You should be sure that reverting the change improves the stability of tip of tree. Sometimes, reverting one change in a series can worsen things instead of improving them. We expect reasonable judgment to ensure that the proper patch or set of patches is being reverted.
  • Reverts should be reasonably timely. A change submitted two hours ago can be reverted without prior discussion. A change submitted two years ago should not be. Where exactly the transition point is is hard to say, but it’s probably in the handful of days in tree territory. If you are unsure, we encourage you to reply to the commit thread, give the author a bit to respond, and then proceed with the revert if the author doesn’t seem to be actively responding.

cc @mydeveloperday

owenca added a commit that referenced this pull request Oct 23, 2025
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Oct 23, 2025
@owenca
Copy link
Contributor

owenca commented Oct 23, 2025

@Prabhuk I've reverted your revert. Please open a GitHub issue for your use case, which also failed before #111115 was merged.

@PiJoules
Copy link
Contributor Author

I filed #164866 which includes a regression test.

@Prabhuk I've reverted your revert. Please open a GitHub issue for your use case, which also failed before #111115 was merged.

I think that's the wrong patch? We reverted #164048.

@owenca
Copy link
Contributor

owenca commented Oct 24, 2025

I filed #164866 which includes a regression test.

@Prabhuk I've reverted your revert. Please open a GitHub issue for your use case, which also failed before #111115 was merged.

I think that's the wrong patch? We reverted #164048.

#111115 (which "fixed" #164866 by chance) was effectively reverted by #164048 because of the regression #160513. Again, please see #164048 (comment).

@PiJoules
Copy link
Contributor Author

cc @llvm/clang-area-team we might need some guidance on how to handle this. It looks like the original change was meant for a cherry-pick on a release branch to fix an old regression (#160513) but it also led to a bug on ToT (#164866).

@efriedma-quic
Copy link
Collaborator

The recent activity here is #164048, then #164670, then a948f25?

Reverting a commit from the 18th on the 22nd is within the policy, although I'd usually prefer to give the author of the patch a little more time to respond before merging.

Every commit has a goal to fix something, but the point of the revert policy is to ensure stability for people closely tracking top of tree. Maintaining that stability is higher priority than a general bugfix, even if it's fixing an important bug. If you're causing immediate breakage, the right response is to back out, then reland when you have a handle on the regressions. The fact that the bugfix is fixing a regression from a year ago isn't really relevant; keeping stability is the highest priority.


Not sure what we want to do for the branch; we can maybe take a bit more time there to figure out the right approach, once we know what the fix for top-of-tree looks like.

@PiJoules
Copy link
Contributor Author

As per @efriedma-quic's comment I'll go ahead and revert the commit again to prevent the immediate breakage.

@owenca by no means do we want to keep your fix reverted, but we would like to keep ToT stable. If needed, we can help out with a reland that both fixes the old regression and prevents this new bug.

PiJoules added a commit to PiJoules/llvm-project that referenced this pull request Oct 24, 2025
… correctly" (llvm#164670)"

This reverts commit 50ca1f4.

Reverting because this leads to the bug on ToT described in
llvm#164866. The original fix
addresses an old regression which we'd still like to land eventually.
See the discussion in llvm#164670
for more context.
PiJoules added a commit that referenced this pull request Oct 24, 2025
#165038)

… correctly" (#164670)"

This reverts commit 50ca1f4.

Reverting because this leads to the bug on ToT described in
#164866. The original fix
addresses an old regression which we'd still like to land eventually.
See the discussion in #164670
for more context.
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Oct 24, 2025
…o::operator… (#165038)

… correctly" (#164670)"

This reverts commit 50ca1f4.

Reverting because this leads to the bug on ToT described in
llvm/llvm-project#164866. The original fix
addresses an old regression which we'd still like to land eventually.
See the discussion in llvm/llvm-project#164670
for more context.
@owenca
Copy link
Contributor

owenca commented Oct 25, 2025

As per @efriedma-quic's comment I'll go ahead and revert the commit again to prevent the immediate breakage.

@PiJoules, I don't know if @efriedma-quic's comment was an endorsement of your original hasty (and incomplete) revert, but it didn't address the first part of the policy I quoted above. Please stop forcing your incomplete revert in without first consulting the clang-format team @mydeveloperday, @HazardyKnusperkeks, etc. If we reach the consensus to fix #160513 by reverting instead of by fixing forward, you need to identify the proper "set of patches" to revert and open a pull request for approval by the clang-format team. That set must include both #111115 and #164048 and most likely one or more commits in between. cc @JohnC32

owenca added a commit that referenced this pull request Oct 25, 2025
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Oct 25, 2025
@efriedma-quic
Copy link
Collaborator

efriedma-quic commented Oct 26, 2025

The recent activity here is #164048, then #164670, then a948f25?

As far as I can tell, what happened is @owenca committed a patch on Oct 17, which broke a workflow for @PiJoules, which was reported on Oct 21. He asked for a immediate fix/revert, which did not happen, then he reverted on Oct 22. After that point, this turned into a revert war. Currently, the Oct 17 patch is in.

There's also some discussion of a patch which landed last year, but from my perspective it's not relevant.


I apologize for not being 100% explicit about what I expected to happen in my previous message.

In the interest of resolving the immediate breakage quickly without further devolving into revert wars, I'm going to be extremely explicit here:

@owenca You have 48 hours from now to resolve the issue @PiJoules reported against main. Either revert to the state before Oct 17, or fix the issue. If you don't solve it within 48 hours from this message (deadline is 10pm pdt Monday Oct 27), you're not allowed to touch any code related to this issue without getting approval from @PiJoules or me. Please acknowledge this as soon as you see it.

@PiJoules Don't do anything for 48 hours. After the deadline, you can revert to the state before Oct 17.


After this is resolved, let's have a Discourse discussion to figure out how we can avoid future revert wars.

dvbuka pushed a commit to dvbuka/llvm-project that referenced this pull request Oct 27, 2025
…y" (llvm#164670)

Reverts llvm#164048

This led to a regression in clang-format where a space gets added in
between the parameter type and `&`. For example, this

```
::test_anonymous::FunctionApplication& ::test_anonymous::FunctionApplication::operator=(const ::test_anonymous::FunctionApplication& other) noexcept {
```

becomes

```
::test_anonymous::FunctionApplication& ::test_anonymous::FunctionApplication::operator=(const ::test_anonymous::FunctionApplication & other) noexcept {
```
dvbuka pushed a commit to dvbuka/llvm-project that referenced this pull request Oct 27, 2025
dvbuka pushed a commit to dvbuka/llvm-project that referenced this pull request Oct 27, 2025
llvm#165038)

… correctly" (llvm#164670)"

This reverts commit 50ca1f4.

Reverting because this leads to the bug on ToT described in
llvm#164866. The original fix
addresses an old regression which we'd still like to land eventually.
See the discussion in llvm#164670
for more context.
dvbuka pushed a commit to dvbuka/llvm-project that referenced this pull request Oct 27, 2025
@owenca
Copy link
Contributor

owenca commented Oct 28, 2025

As far as I can tell, what happened is @owenca committed a patch on Oct 17, which broke a workflow for @PiJoules, which was reported on Oct 21.  He asked for a immediate fix/revert, which did not happen, then he reverted on Oct 22.  After that point, this turned into a revert war.  Currently, the Oct 17 patch is in.

Here is a recap of a more detailed timeline before @PiJoules escalated the issue to @llvm/clang-area-team:

  1. On Oct 17, I committed a patch to revert/rework a previous commit that caused a regression as reported in Subject: clang-format 21 regression when using "AlignConsecutiveDeclarations: Consecutive" #160513. The regression was important enough that the fix got backported to the 21.x branch on Oct 20 and released in clang-format 21.1.4 the next day.
  2. On Oct 21, @PiJoules reported a bug that appeared to be caused by my Oct 17 commit and asked for a fix or revert. No word "immediate" or similar was used in the request. (See [clang-format] Annotate ::operator and Foo::operator correctly #164048 (comment).)
  3. I responded about 9 hours later and pointed out that that commit was already backported to 21.1.4. I indicated that I would try to come up with a fix in a few days. In the same comment, I also notified the reviewer @HazardyKnusperkeks of the commit how we might want to proceed and got a positive reply right away.
  4. PiJoules reverted the commit about 9 hours later, which was questioned by HazardyKnusperkeks as to why the urgency.
  5. I reverted PiJoules's revert after my investigation which concluded that the bug @PiJoules reported was not caused by my Oct 17 commit, and asked PiJoules to file a bug report. (See clang-format adds a space between the parameter type and & under google style guide #164866.)

Lukacma pushed a commit to Lukacma/llvm-project that referenced this pull request Oct 29, 2025
…y" (llvm#164670)

Reverts llvm#164048

This led to a regression in clang-format where a space gets added in
between the parameter type and `&`. For example, this

```
::test_anonymous::FunctionApplication& ::test_anonymous::FunctionApplication::operator=(const ::test_anonymous::FunctionApplication& other) noexcept {
```

becomes

```
::test_anonymous::FunctionApplication& ::test_anonymous::FunctionApplication::operator=(const ::test_anonymous::FunctionApplication & other) noexcept {
```
Lukacma pushed a commit to Lukacma/llvm-project that referenced this pull request Oct 29, 2025
Lukacma pushed a commit to Lukacma/llvm-project that referenced this pull request Oct 29, 2025
llvm#165038)

… correctly" (llvm#164670)"

This reverts commit 50ca1f4.

Reverting because this leads to the bug on ToT described in
llvm#164866. The original fix
addresses an old regression which we'd still like to land eventually.
See the discussion in llvm#164670
for more context.
Lukacma pushed a commit to Lukacma/llvm-project that referenced this pull request Oct 29, 2025
aokblast pushed a commit to aokblast/llvm-project that referenced this pull request Oct 30, 2025
…y" (llvm#164670)

Reverts llvm#164048

This led to a regression in clang-format where a space gets added in
between the parameter type and `&`. For example, this

```
::test_anonymous::FunctionApplication& ::test_anonymous::FunctionApplication::operator=(const ::test_anonymous::FunctionApplication& other) noexcept {
```

becomes

```
::test_anonymous::FunctionApplication& ::test_anonymous::FunctionApplication::operator=(const ::test_anonymous::FunctionApplication & other) noexcept {
```
aokblast pushed a commit to aokblast/llvm-project that referenced this pull request Oct 30, 2025
aokblast pushed a commit to aokblast/llvm-project that referenced this pull request Oct 30, 2025
llvm#165038)

… correctly" (llvm#164670)"

This reverts commit 50ca1f4.

Reverting because this leads to the bug on ToT described in
llvm#164866. The original fix
addresses an old regression which we'd still like to land eventually.
See the discussion in llvm#164670
for more context.
aokblast pushed a commit to aokblast/llvm-project that referenced this pull request Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants