https://github.com/owenca created https://github.com/llvm/llvm-project/pull/186566
Fixes #185421 >From e8ca4a051ae8d9186e8f884e842a59a79072e7f5 Mon Sep 17 00:00:00 2001 From: Owen Pan <[email protected]> Date: Fri, 13 Mar 2026 23:54:58 -0700 Subject: [PATCH] [clang-format] Fix a crash on fuzzer-generated invalid C++ code Fixes #185421 --- clang/lib/Format/ContinuationIndenter.cpp | 3 ++- clang/unittests/Format/FormatTest.cpp | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 1eb17592a89e6..a388b74920e0b 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -710,7 +710,8 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { return false; if (Tok->is(TT_TemplateCloser)) { Tok = Tok->MatchingParen; - assert(Tok); + if (!Tok) + return false; } if (Tok->FirstAfterPPLine) return false; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 33af71de398be..df351489262f4 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -29243,6 +29243,14 @@ TEST_F(FormatTest, UnbalancedAngleBrackets) { verifyNoCrash("typename foo<bar>::value, const String &>::type f();", getLLVMStyleWithColumns(50)); + + verifyNoCrash( + ">\n" + " f({\n" + " {}inner> () __attribute __attribute__((foo())) int foo(void)\n" + " {};\n" + " }, );", + getLLVMStyleWithColumns(70)); } } // namespace _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
