https://github.com/abhijeetsharma200 updated 
https://github.com/llvm/llvm-project/pull/184621

>From 3ced31f27094baa45cdb664549f6d7ddc7b70279 Mon Sep 17 00:00:00 2001
From: Abhijeet Sharma <[email protected]>
Date: Wed, 4 Mar 2026 15:12:24 +0100
Subject: [PATCH 1/3] [clang] Fix alias declaration fix-it location for
 token-split '>>', fixes #184425

---
 clang/lib/Lex/Lexer.cpp          | 13 ++++++++++++-
 clang/test/Parser/cxx0x-decl.cpp |  2 --
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index cbf0c77232db7..6bec96601c9cf 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -862,7 +862,18 @@ SourceLocation Lexer::getLocForEndOfToken(SourceLocation 
Loc, unsigned Offset,
     return {};
 
   if (Loc.isMacroID()) {
-    if (Offset > 0 || !isAtEndOfMacroExpansion(Loc, SM, LangOpts, &Loc))
+    if (Offset > 0)
+      return {};
+
+    // Token-split expansions (e.g., '>>' split into '>') use a char range
+    // whose end is already the correct insertion point; skip 
MeasureTokenLength.
+    CharSourceRange ExpRange = SM.getImmediateExpansionRange(Loc);
+    if (!ExpRange.isTokenRange()) {
+      SourceLocation End = ExpRange.getEnd();
+      return End.isFileID() ? End : SourceLocation{};
+    }
+
+    if (!isAtEndOfMacroExpansion(Loc, SM, LangOpts, &Loc))
       return {}; // Points inside the macro expansion.
   }
 
diff --git a/clang/test/Parser/cxx0x-decl.cpp b/clang/test/Parser/cxx0x-decl.cpp
index 69a8d8a46557d..14643d7812641 100644
--- a/clang/test/Parser/cxx0x-decl.cpp
+++ b/clang/test/Parser/cxx0x-decl.cpp
@@ -190,8 +190,6 @@ namespace AliasDeclEndLocation {
     ;
   using D = AliasDeclEndLocation::A<int
     > // expected-error {{expected ';' after alias declaration}}
-  // FIXME: After splitting this >> into two > tokens, we incorrectly determine
-  // the end of the template-id to be after the *second* '>'.
   using E = AliasDeclEndLocation::A<int>>;
 #define GGG >>>
   using F = AliasDeclEndLocation::A<int GGG;

>From dc9850eaf4a68ce3f6488172b40e8ab16cd1f6da Mon Sep 17 00:00:00 2001
From: Abhijeet Sharma <[email protected]>
Date: Wed, 4 Mar 2026 15:24:52 +0100
Subject: [PATCH 2/3] Added test file

---
 clang/test/Parser/cxx11-alias-decl-split-token-fixit.cpp | 6 ++++++
 1 file changed, 6 insertions(+)
 create mode 100644 clang/test/Parser/cxx11-alias-decl-split-token-fixit.cpp

diff --git a/clang/test/Parser/cxx11-alias-decl-split-token-fixit.cpp 
b/clang/test/Parser/cxx11-alias-decl-split-token-fixit.cpp
new file mode 100644
index 0000000000000..f57025e1337eb
--- /dev/null
+++ b/clang/test/Parser/cxx11-alias-decl-split-token-fixit.cpp
@@ -0,0 +1,6 @@
+// RUN: not %clang_cc1 -fsyntax-only -std=c++11 -fdiagnostics-parseable-fixits 
%s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+template <typename> struct X {};
+using A = X<int>>; // expected-error {{expected ';' after alias declaration}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:17-[[@LINE-1]]:17}:";"

>From 59cff000d4e82da0e28a1f3db3a014cf14ff708c Mon Sep 17 00:00:00 2001
From: Abhijeet Sharma <[email protected]>
Date: Wed, 4 Mar 2026 15:32:00 +0100
Subject: [PATCH 3/3] fixed linter issues

---
 clang/lib/Lex/Lexer.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index 6bec96601c9cf..74880f4448f3c 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -866,7 +866,8 @@ SourceLocation Lexer::getLocForEndOfToken(SourceLocation 
Loc, unsigned Offset,
       return {};
 
     // Token-split expansions (e.g., '>>' split into '>') use a char range
-    // whose end is already the correct insertion point; skip 
MeasureTokenLength.
+    // whose end is already the correct insertion point; skip
+    // MeasureTokenLength.
     CharSourceRange ExpRange = SM.getImmediateExpansionRange(Loc);
     if (!ExpRange.isTokenRange()) {
       SourceLocation End = ExpRange.getEnd();

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to