[llvm-branch-commits] [clang] release/20.x: [clang-format] Fix a crash on formatting missing r_pare… (PR #139345)
github-actions[bot] wrote: @owenca (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. https://github.com/llvm/llvm-project/pull/139345 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] release/20.x: [clang-format] Fix a crash on formatting missing r_pare… (PR #139345)
https://github.com/tstellar closed https://github.com/llvm/llvm-project/pull/139345 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] release/20.x: [clang-format] Fix a crash on formatting missing r_pare… (PR #139345)
https://github.com/tstellar updated https://github.com/llvm/llvm-project/pull/139345 >From 2d079b96a5fb2d1da62cfddbafa6632058b22e76 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Fri, 9 May 2025 17:55:48 -0700 Subject: [PATCH] release/20.x: [clang-format] Fix a crash on formatting missing r_paren/r_brace (#138230) Backport 79210feb2993ff9a79ef11f8a7016a527d4fcf22 --- clang/lib/Format/UnwrappedLineParser.cpp | 4 ++-- clang/unittests/Format/FormatTest.cpp| 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index c3ffabce15ec8..673b3e6c4b8c2 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -1837,8 +1837,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 49e1fde1d9ccf..90a79230e9f4c 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -13962,6 +13962,8 @@ TEST_F(FormatTest, IncorrectCodeUnbalancedBraces) { verifyNoCrash("struct Foo {\n" " operator foo(bar\n" "};"); + verifyNoCrash("decltype( {\n" +" {"); } TEST_F(FormatTest, IncorrectUnbalancedBracesInMacrosWithUnicode) { ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] release/20.x: [clang-format] Fix a crash on formatting missing r_pare… (PR #139345)
https://github.com/mydeveloperday approved this pull request. https://github.com/llvm/llvm-project/pull/139345 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] release/20.x: [clang-format] Fix a crash on formatting missing r_pare… (PR #139345)
https://github.com/nikic milestoned https://github.com/llvm/llvm-project/pull/139345 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] release/20.x: [clang-format] Fix a crash on formatting missing r_pare… (PR #139345)
llvmbot wrote: @llvm/pr-subscribers-clang-format Author: Owen Pan (owenca) Changes …n/r_brace (#138230) Backport 79210feb2993ff9a79ef11f8a7016a527d4fcf22 --- Full diff: https://github.com/llvm/llvm-project/pull/139345.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 c3ffabce15ec8..673b3e6c4b8c2 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -1837,8 +1837,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 49e1fde1d9ccf..90a79230e9f4c 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -13962,6 +13962,8 @@ TEST_F(FormatTest, IncorrectCodeUnbalancedBraces) { verifyNoCrash("struct Foo {\n" " operator foo(bar\n" "};"); + verifyNoCrash("decltype( {\n" +" {"); } TEST_F(FormatTest, IncorrectUnbalancedBracesInMacrosWithUnicode) { `` https://github.com/llvm/llvm-project/pull/139345 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] release/20.x: [clang-format] Fix a crash on formatting missing r_pare… (PR #139345)
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/139345 …n/r_brace (#138230) Backport 79210feb2993ff9a79ef11f8a7016a527d4fcf22 >From 6b27319fcf50dbb0d682cb240049d93022d456af Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Fri, 9 May 2025 17:55:48 -0700 Subject: [PATCH] release/20.x: [clang-format] Fix a crash on formatting missing r_paren/r_brace (#138230) Backport 79210feb2993ff9a79ef11f8a7016a527d4fcf22 --- clang/lib/Format/UnwrappedLineParser.cpp | 4 ++-- clang/unittests/Format/FormatTest.cpp| 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index c3ffabce15ec8..673b3e6c4b8c2 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -1837,8 +1837,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 49e1fde1d9ccf..90a79230e9f4c 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -13962,6 +13962,8 @@ TEST_F(FormatTest, IncorrectCodeUnbalancedBraces) { verifyNoCrash("struct Foo {\n" " operator foo(bar\n" "};"); + verifyNoCrash("decltype( {\n" +" {"); } TEST_F(FormatTest, IncorrectUnbalancedBracesInMacrosWithUnicode) { ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits