llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-format Author: Owen Pan (owenca) <details> <summary>Changes</summary> Fix #<!-- -->138097 --- Full diff: https://github.com/llvm/llvm-project/pull/138230.diff 2 Files Affected: - (modified) clang/lib/Format/UnwrappedLineParser.cpp (+2-2) - (modified) clang/unittests/Format/FormatTest.cpp (+2) ``````````diff diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 837146f0c6483..863df987ab230 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -1834,8 +1834,8 @@ void UnwrappedLineParser::parseStructuralElement( nextToken(); if (FormatTok->is(tok::l_paren)) { parseParens(); - assert(FormatTok->Previous); - if (FormatTok->Previous->endsSequence(tok::r_paren, tok::kw_auto, + if (FormatTok->Previous && + FormatTok->Previous->endsSequence(tok::r_paren, tok::kw_auto, tok::l_paren)) { Line->SeenDecltypeAuto = true; } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index c4fcc5506d152..5605777c20ae2 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -14259,6 +14259,8 @@ TEST_F(FormatTest, IncorrectCodeUnbalancedBraces) { verifyNoCrash("struct Foo {\n" " operator foo(bar\n" "};"); + verifyNoCrash("decltype( {\n" + " {"); } TEST_F(FormatTest, IncorrectUnbalancedBracesInMacrosWithUnicode) { `````````` </details> https://github.com/llvm/llvm-project/pull/138230 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits