Author: owenca Date: 2026-03-14T13:12:42-07:00 New Revision: 6af0466e7733e723607f31bd3186231d03183670
URL: https://github.com/llvm/llvm-project/commit/6af0466e7733e723607f31bd3186231d03183670 DIFF: https://github.com/llvm/llvm-project/commit/6af0466e7733e723607f31bd3186231d03183670.diff LOG: [clang-format] Fix a crash on fuzzer-generated invalid C++ code (#186566) Fixes #185421 Added: Modified: clang/lib/Format/ContinuationIndenter.cpp clang/unittests/Format/FormatTest.cpp Removed: ################################################################################ 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 a18d21914501f..5ffe68a421880 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -29414,6 +29414,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)); } TEST_F(FormatTest, LambdaArrowAsTrailingReturnArrow) { _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
