https://github.com/HazardyKnusperkeks created https://github.com/llvm/llvm-project/pull/173433
None From 3da91f4114bf7459812579fb823239aeca5201b9 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 | 4 ++++ 2 files changed, 6 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..068bd22efcf99 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -29053,6 +29053,10 @@ 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
