[clang] [clang-format] Fix crash involving array designators (PR #77045)

2024-01-10 Thread via cfe-commits
XDeme wrote: > > While I was trying to find a minimal reproducer to the bug, I accidentally > > found that this patch fix another crash, and doesn't fix the linked issue. > > Can you open another pull request to > [fix](https://github.com/llvm/llvm-project/pull/77045#discussion_r1442578220)

[clang] [clang-format] Fix crash involving array designators (PR #77045)

2024-01-10 Thread Owen Pan via cfe-commits
https://github.com/owenca closed https://github.com/llvm/llvm-project/pull/77045 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Fix crash involving array designators (PR #77045)

2024-01-10 Thread Owen Pan via cfe-commits
owenca wrote: > While I was trying to find a minimal reproducer to the bug, I accidentally > found that this patch fix another crash, and doesn't fix the linked issue. Can you open another pull request to [fix](https://github.com/llvm/llvm-project/pull/77045#discussion_r1442578220) the other

[clang] [clang-format] Fix crash involving array designators (PR #77045)

2024-01-09 Thread Owen Pan via cfe-commits
https://github.com/owenca approved this pull request. https://github.com/llvm/llvm-project/pull/77045 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Fix crash involving array designators (PR #77045)

2024-01-09 Thread Emilia Kond via cfe-commits
https://github.com/rymiel approved this pull request. https://github.com/llvm/llvm-project/pull/77045 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Fix crash involving array designators (PR #77045)

2024-01-09 Thread via cfe-commits
https://github.com/XDeme updated https://github.com/llvm/llvm-project/pull/77045 >From d9cbbe48b96d27bff3fc926b60d039ed05f00489 Mon Sep 17 00:00:00 2001 From: XDeme Date: Fri, 5 Jan 2024 01:23:16 -0300 Subject: [PATCH 1/9] [clang-format] Fix crash involving array designators and dangling comma

[clang] [clang-format] Fix crash involving array designators (PR #77045)

2024-01-09 Thread Owen Pan via cfe-commits
@@ -2315,6 +2315,8 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() { if (Next->is(tok::greater)) return false; } + if (tok::isLiteral(FormatTok->Tok.getKind())) +return false; owenca wrote: You are right! Then how about the

[clang] [clang-format] Fix crash involving array designators (PR #77045)

2024-01-09 Thread via cfe-commits
https://github.com/XDeme edited https://github.com/llvm/llvm-project/pull/77045 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Fix crash involving array designators (PR #77045)

2024-01-09 Thread via cfe-commits
https://github.com/XDeme updated https://github.com/llvm/llvm-project/pull/77045 >From d9cbbe48b96d27bff3fc926b60d039ed05f00489 Mon Sep 17 00:00:00 2001 From: XDeme Date: Fri, 5 Jan 2024 01:23:16 -0300 Subject: [PATCH 1/8] [clang-format] Fix crash involving array designators and dangling comma

[clang] [clang-format] Fix crash involving array designators (PR #77045)

2024-01-09 Thread via cfe-commits
@@ -2315,6 +2315,8 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() { if (Next->is(tok::greater)) return false; } + if (tok::isLiteral(FormatTok->Tok.getKind())) +return false; XDeme wrote: With this change, a code like this will

[clang] [clang-format] Fix crash involving array designators (PR #77045)

2024-01-09 Thread via cfe-commits
https://github.com/XDeme deleted https://github.com/llvm/llvm-project/pull/77045 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Fix crash involving array designators (PR #77045)

2024-01-09 Thread via cfe-commits
@@ -2315,6 +2315,8 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() { if (Next->is(tok::greater)) return false; } + if (tok::isLiteral(FormatTok->Tok.getKind())) +return false; XDeme wrote: With this change this code will crash:

[clang] [clang-format] Fix crash involving array designators (PR #77045)

2024-01-09 Thread Owen Pan via cfe-commits
owenca wrote: Please add an assertion in `WhitespaceManager.h`: ``` --- a/clang/lib/Format/WhitespaceManager.h +++ b/clang/lib/Format/WhitespaceManager.h @@ -282,6 +282,7 @@ private: for (auto PrevIter = Start; PrevIter != End; ++PrevIter) { // If we broke the line the initial spaces

[clang] [clang-format] Fix crash involving array designators (PR #77045)

2024-01-09 Thread Owen Pan via cfe-commits
@@ -2315,6 +2315,8 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() { if (Next->is(tok::greater)) return false; } + if (tok::isLiteral(FormatTok->Tok.getKind())) +return false; owenca wrote: ```suggestion ``` Instead, I would change

[clang] [clang-format] Fix crash involving array designators (PR #77045)

2024-01-09 Thread via cfe-commits
https://github.com/XDeme updated https://github.com/llvm/llvm-project/pull/77045 >From d9cbbe48b96d27bff3fc926b60d039ed05f00489 Mon Sep 17 00:00:00 2001 From: XDeme Date: Fri, 5 Jan 2024 01:23:16 -0300 Subject: [PATCH 1/7] [clang-format] Fix crash involving array designators and dangling comma

[clang] [clang-format] Fix crash involving array designators (PR #77045)

2024-01-09 Thread Björn Schäpers via cfe-commits
@@ -2315,6 +2315,10 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() { if (Next->is(tok::greater)) return false; } + if (const auto Kind = FormatTok->Tok.getKind(); + tok::isLiteral(Kind) && !tok::isStringLiteral(Kind)) {

[clang] [clang-format] Fix crash involving array designators (PR #77045)

2024-01-09 Thread Björn Schäpers via cfe-commits
@@ -1444,6 +1444,7 @@ WhitespaceManager::CellDescriptions WhitespaceManager::getCells(unsigned Start, } else if (C.Tok->is(tok::comma)) { if (!Cells.empty()) Cells.back().EndIndex = i; + HazardyKnusperkeks wrote: Unrelated (and

[clang] [clang-format] Fix crash involving array designators (PR #77045)

2024-01-09 Thread via cfe-commits
https://github.com/XDeme edited https://github.com/llvm/llvm-project/pull/77045 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Fix crash involving array designators (PR #77045)

2024-01-09 Thread via cfe-commits
https://github.com/XDeme edited https://github.com/llvm/llvm-project/pull/77045 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits