Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[clang-format] Fix a regression of annotating PointerOrReference#149039

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
owenca merged 2 commits intollvm:mainfromowenca:149010
Jul 18, 2025

Conversation

owenca
Copy link
Contributor

@owencaowenca commentedJul 16, 2025
edited
Loading

Fixes#149010

@llvmbot
Copy link
Member

@llvm/pr-subscribers-clang-format

Author: Owen Pan (owenca)

Changes

Fixes #149010


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

2 Files Affected:

  • (modified) clang/lib/Format/TokenAnnotator.cpp (+4-1)
  • (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (+4)
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cppindex 739209a5681f8..176c9c278b18c 100644--- a/clang/lib/Format/TokenAnnotator.cpp+++ b/clang/lib/Format/TokenAnnotator.cpp@@ -3112,7 +3112,7 @@ class AnnotatingParser {      // It's more likely that & represents operator& than an uninitialized     // reference.-    if (Tok.is(tok::amp) && PrevToken && PrevToken->Tok.isAnyIdentifier() &&+    if (Tok.is(tok::amp) && PrevToken->Tok.isAnyIdentifier() &&         IsChainedOperatorAmpOrMember(PrevToken->getPreviousNonComment()) &&         NextToken && NextToken->Tok.isAnyIdentifier()) {       if (auto NextNext = NextToken->getNextNonComment();@@ -3122,6 +3122,9 @@ class AnnotatingParser {       }     }+    if (PrevToken->isTypeName(LangOpts))+      return TT_PointerOrReference;+     if (Line.Type == LT_SimpleRequirement ||         (!Scopes.empty() && Scopes.back() == ST_CompoundRequirement)) {       return TT_BinaryOperator;diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cppindex e281a4945a862..30942c461427a 100644--- a/clang/unittests/Format/TokenAnnotatorTest.cpp+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp@@ -390,6 +390,10 @@ TEST_F(TokenAnnotatorTest, UnderstandsUsesOfStarAndAmp) {   EXPECT_TOKEN(Tokens[20], tok::l_brace, TT_CompoundRequirementLBrace);   EXPECT_TOKEN(Tokens[22], tok::star, TT_BinaryOperator);+  Tokens = annotate("bool foo = requires { static_cast<int &&>(1); };");+  ASSERT_EQ(Tokens.size(), 17u) << Tokens;+  EXPECT_TOKEN(Tokens[8], tok::ampamp, TT_PointerOrReference);+   Tokens = annotate("return s.operator int *();");   ASSERT_EQ(Tokens.size(), 10u) << Tokens;   // Not TT_FunctionDeclarationName.

@owencaowenca added this to theLLVM 21.x Release milestoneJul 17, 2025
@trutru moved this fromNeeds Triage toNeeds Backport PR inLLVM Release StatusJul 17, 2025
@github-project-automationgithub-project-automationbot moved this fromNeeds Backport PR toNeeds Merge inLLVM Release StatusJul 17, 2025
@trutru moved this fromNeeds Merge toDone inLLVM Release StatusJul 17, 2025
@owencaowenca merged commita8f5e9e intollvm:mainJul 18, 2025
9 checks passed
@owencaowenca deleted the 149010 branchJuly 18, 2025 04:43
@owenca
Copy link
ContributorAuthor

/cherry-picka8f5e9e

@llvmbot
Copy link
Member

/pull-request#149451

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@HazardyKnusperkeksHazardyKnusperkeksHazardyKnusperkeks approved these changes

Assignees
No one assigned
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

clang-format 20 ignores reference alignment in requires clause
3 participants
@owenca@llvmbot@HazardyKnusperkeks

[8]ページ先頭

©2009-2025 Movatter.jp