https://github.com/HazardyKnusperkeks updated https://github.com/llvm/llvm-project/pull/173433
From f923cdca9e3a85cdacc11dcc5f0a7a0462f6c76b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Sch=C3=A4pers?= <[email protected]> Date: Wed, 24 Dec 2025 01:12:59 +0100 Subject: [PATCH] [clang-format] Don't crash on incomplete template declaration --- clang/lib/Format/TokenAnnotator.cpp | 2 ++ clang/unittests/Format/FormatTest.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index f6341ff0305a9..376afa52cab20 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -3743,6 +3743,8 @@ static FormatToken *getFunctionName(const AnnotatedLine &Line, return nullptr; Tok = Tok->MatchingParen; + if (!Tok) + break; continue; } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 5cdac66d1dcbd..11ed5beabb3da 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -29053,6 +29053,8 @@ TEST_F(FormatTest, KeywordedFunctionLikeMacros) { Style); } +TEST_F(FormatTest, DoesNotCrashIncompleteCode) { verifyNoCrash("template <"); } + } // namespace } // namespace test } // namespace format _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
