https://github.com/owenca updated 
https://github.com/llvm/llvm-project/pull/173456

>From 0e5d0850b2a098df349d3b03efd556c41ff70040 Mon Sep 17 00:00:00 2001
From: Owen Pan <[email protected]>
Date: Wed, 24 Dec 2025 23:46:16 -0800
Subject: [PATCH] [clang-format] Fix a crash in formatting unbalanced angle
 brackets

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

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 1123ae98c02ca..2b554e609fa3a 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3037,10 +3037,8 @@ class AnnotatingParser {
     auto *NextToken = Tok.getNextNonComment();
     if (!NextToken)
       return TT_PointerOrReference;
-    if (NextToken->is(tok::greater)) {
-      NextToken->setFinalizedType(TT_TemplateCloser);
+    if (NextToken->is(tok::greater))
       return TT_PointerOrReference;
-    }
 
     if (InTemplateArgument && NextToken->is(tok::kw_noexcept))
       return TT_BinaryOperator;
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index f5f23388453ec..3ee7ce38578aa 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -29053,7 +29053,12 @@ TEST_F(FormatTest, KeywordedFunctionLikeMacros) {
                Style);
 }
 
-TEST_F(FormatTest, UnbalancedAngleBrackets) { verifyFormat("template <"); }
+TEST_F(FormatTest, UnbalancedAngleBrackets) {
+  verifyFormat("template <");
+
+  verifyNoCrash("typename foo<bar>::value, const String &>::type f();",
+                getLLVMStyleWithColumns(50));
+}
 
 } // namespace
 } // namespace test

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

Reply via email to