llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-format Author: Björn Schäpers (HazardyKnusperkeks) <details> <summary>Changes</summary> --- Full diff: https://github.com/llvm/llvm-project/pull/173433.diff 2 Files Affected: - (modified) clang/lib/Format/TokenAnnotator.cpp (+2) - (modified) clang/unittests/Format/FormatTest.cpp (+4) ``````````diff 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 `````````` </details> https://github.com/llvm/llvm-project/pull/173433 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
