RE: [clang] 73b62f8 - Fix parsing of comma fold-expressions as the operand of a C-style cast.

2022-08-04 Thread Yaghmour, Shafik via cfe-commits
Richard, it looks like this will also fix: 
https://github.com/llvm/llvm-project/issues/56864


-Original Message-
From: cfe-commits  On Behalf Of Richard 
Smith via cfe-commits
Sent: Thursday, August 4, 2022 5:08 PM
To: cfe-commits@lists.llvm.org
Subject: [clang] 73b62f8 - Fix parsing of comma fold-expressions as the operand 
of a C-style cast.


Author: Richard Smith
Date: 2022-08-04T17:08:08-07:00
New Revision: 73b62f813550b602f189afc3a60b0b39ae89f16d

URL: 
https://github.com/llvm/llvm-project/commit/73b62f813550b602f189afc3a60b0b39ae89f16d
DIFF: 
https://github.com/llvm/llvm-project/commit/73b62f813550b602f189afc3a60b0b39ae89f16d.diff

LOG: Fix parsing of comma fold-expressions as the operand of a C-style cast.

Added: 


Modified: 
clang/lib/Parse/ParseExpr.cpp
clang/test/Parser/cxx1z-fold-expressions.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp 
index a6a946d7f31b1..52d4938b1ecfc 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -3469,7 +3469,9 @@ Parser::ParseSimpleExpressionList(SmallVectorImpl 
&Exprs,
 
 Exprs.push_back(Expr.get());
 
-if (Tok.isNot(tok::comma))
+// We might be parsing the LHS of a fold-expression. If we reached the fold
+// operator, stop.
+if (Tok.isNot(tok::comma) || NextToken().is(tok::ellipsis))
   return false;
 
 // Move to the next argument, remember where the comma was.

diff  --git a/clang/test/Parser/cxx1z-fold-expressions.cpp 
b/clang/test/Parser/cxx1z-fold-expressions.cpp
index 93ee6f20ffc6d..ac27111697737 100644
--- a/clang/test/Parser/cxx1z-fold-expressions.cpp
+++ b/clang/test/Parser/cxx1z-fold-expressions.cpp
@@ -41,7 +41,13 @@ template void as_operand_of_cast(int a, T 
...t) {
 (int)(t + ... + undeclared_junk) + // expected-error {{undeclared}}
 (int)(... + undeclared_junk) + // expected-error {{undeclared}} 
expected-error {{does not contain any unexpanded}}
 (int)(undeclared_junk + ...) + // expected-error {{undeclared}}
-(int)(a + ...); // expected-error {{does not contain any unexpanded}}
+(int)(a + ...) + // expected-error {{does not contain any unexpanded}}
+(int)(a, ...) + // expected-error {{does not contain any unexpanded}}
+(int)(..., a) + // expected-error {{does not contain any unexpanded}}
+(int)(a, ..., undeclared_junk) + // expected-error {{undeclared}} 
expected-error {{does not contain any unexpanded}}
+(int)(t, ...) +
+(int)(..., t) +
+(int)(t, ..., a);
 }
 
 // fold-operator can be '>' or '>>'.



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: [clang] 398cddf - [clang-format] Fix assertion that doesn't hold under fuzzing.

2023-02-27 Thread Yaghmour, Shafik via cfe-commits
Should that have been an "else if" and not just an "if" otherwise clang-format 
should be applied. 

-Original Message-
From: cfe-commits  On Behalf Of Manuel 
Klimek via cfe-commits
Sent: Monday, February 27, 2023 2:51 AM
To: cfe-commits@lists.llvm.org
Subject: [clang] 398cddf - [clang-format] Fix assertion that doesn't hold under 
fuzzing.


Author: Manuel Klimek
Date: 2023-02-27T10:50:42Z
New Revision: 398cddf6acecfb12b5997c2d639ee3cf31b787ad

URL: 
https://github.com/llvm/llvm-project/commit/398cddf6acecfb12b5997c2d639ee3cf31b787ad
DIFF: 
https://github.com/llvm/llvm-project/commit/398cddf6acecfb12b5997c2d639ee3cf31b787ad.diff

LOG: [clang-format] Fix assertion that doesn't hold under fuzzing.

Added: 


Modified: 
clang/lib/Format/UnwrappedLineFormatter.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index b0314d6cfa75f..c789f2907dac9 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -511,12 +511,11 @@ class LineJoiner {
 ShouldMerge = !Style.BraceWrapping.AfterClass ||
   (NextLine.First->is(tok::r_brace) &&
!Style.BraceWrapping.SplitEmptyRecord);
-  } else {
+  } if(TheLine->InPPDirective ||
+   !TheLine->First->isOneOf(tok::kw_class, tok::kw_enum,
+tok::kw_struct)) {
 // Try to merge a block with left brace unwrapped that wasn't yet
 // covered.
-assert(TheLine->InPPDirective ||
-   !TheLine->First->isOneOf(tok::kw_class, tok::kw_enum,
-tok::kw_struct));
 ShouldMerge = !Style.BraceWrapping.AfterFunction ||
   (NextLine.First->is(tok::r_brace) &&
!Style.BraceWrapping.SplitEmptyFunction);



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits