https://github.com/luoliwoshang updated 
https://github.com/llvm/llvm-project/pull/184555

From 13312f0cd5defe71ebd3bf8659a5d3a72c81afef Mon Sep 17 00:00:00 2001
From: luoliwoshang <[email protected]>
Date: Wed, 4 Mar 2026 15:01:37 +0800
Subject: [PATCH 1/2] [clang] Fix alias-decl fix-it location with token-split
 expansion

---
 clang/lib/Lex/Lexer.cpp                                | 9 +++++++++
 clang/test/Parser/cxx-alias-decl-split-angle-fixit.cpp | 7 +++++++
 2 files changed, 16 insertions(+)
 create mode 100644 clang/test/Parser/cxx-alias-decl-split-angle-fixit.cpp

diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index cbf0c77232db7..f9f9a57330ac3 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -862,8 +862,17 @@ SourceLocation Lexer::getLocForEndOfToken(SourceLocation 
Loc, unsigned Offset,
     return {};
 
   if (Loc.isMacroID()) {
+    // Token-split expansion ranges (for example, when splitting '>>' into two
+    // '>' tokens while parsing templates) are character ranges, so the
+    // expansion end location already points just past the split token.
+    const bool IsTokenSplitRange =
+        !SM.getSLocEntry(SM.getFileID(Loc))
+             .getExpansion()
+             .isExpansionTokenRange();
     if (Offset > 0 || !isAtEndOfMacroExpansion(Loc, SM, LangOpts, &Loc))
       return {}; // Points inside the macro expansion.
+    if (IsTokenSplitRange)
+      return Loc;
   }
 
   unsigned Len = Lexer::MeasureTokenLength(Loc, SM, LangOpts);
diff --git a/clang/test/Parser/cxx-alias-decl-split-angle-fixit.cpp 
b/clang/test/Parser/cxx-alias-decl-split-angle-fixit.cpp
new file mode 100644
index 0000000000000..fc683431a958a
--- /dev/null
+++ b/clang/test/Parser/cxx-alias-decl-split-angle-fixit.cpp
@@ -0,0 +1,7 @@
+// RUN: not %clang_cc1 -fsyntax-only -std=c++11 -fdiagnostics-parseable-fixits 
%s 2>&1 | FileCheck %s
+
+template <typename> struct X {};
+using A = X<int>>;
+
+// CHECK: error: expected ';' after alias declaration
+// CHECK: fix-it:"{{.*}}":{4:17-4:17}:";"

From 6567092cb3a6e6fbbb459ac99dd447249a4ed27a Mon Sep 17 00:00:00 2001
From: luoliwoshang <[email protected]>
Date: Wed, 4 Mar 2026 22:23:04 +0800
Subject: [PATCH 2/2] [clang] Narrow token-split check scope in
 getLocForEndOfToken

---
 clang/lib/Lex/Lexer.cpp | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index f9f9a57330ac3..c77f7f42b729d 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -865,13 +865,10 @@ SourceLocation Lexer::getLocForEndOfToken(SourceLocation 
Loc, unsigned Offset,
     // Token-split expansion ranges (for example, when splitting '>>' into two
     // '>' tokens while parsing templates) are character ranges, so the
     // expansion end location already points just past the split token.
-    const bool IsTokenSplitRange =
-        !SM.getSLocEntry(SM.getFileID(Loc))
-             .getExpansion()
-             .isExpansionTokenRange();
+    const FileID LocFileID = SM.getFileID(Loc);
     if (Offset > 0 || !isAtEndOfMacroExpansion(Loc, SM, LangOpts, &Loc))
       return {}; // Points inside the macro expansion.
-    if (IsTokenSplitRange)
+    if (!SM.getSLocEntry(LocFileID).getExpansion().isExpansionTokenRange())
       return Loc;
   }
 

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

Reply via email to