[clang] [NFC] Fix Parens on assertion from 147514 (PR #158635)

2025-09-15 Thread Bruno De Fraine via cfe-commits


@@ -2142,9 +2142,9 @@ Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr 
*E) {
   bool Ignore = TestAndClearIgnoreResultAssign();
   (void)Ignore;
   unsigned NumInitElements = E->getNumInits();
-  assert(Ignore == false ||
- (NumInitElements == 0 && E->getType()->isVoidType()) &&
- "init list ignored");
+  assert((Ignore == false ||
+  (NumInitElements == 0 && E->getType()->isVoidType())) &&
+ "init list ignored");

brunodf-snps wrote:

OK, good to me. The extra parentheses solve the GCC warning.

https://github.com/llvm/llvm-project/pull/158635
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC] Fix Parens on assertion from 147514 (PR #158635)

2025-09-15 Thread Erich Keane via cfe-commits


@@ -2142,9 +2142,9 @@ Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr 
*E) {
   bool Ignore = TestAndClearIgnoreResultAssign();
   (void)Ignore;
   unsigned NumInitElements = E->getNumInits();
-  assert(Ignore == false ||
- (NumInitElements == 0 && E->getType()->isVoidType()) &&
- "init list ignored");
+  assert((Ignore == false ||
+  (NumInitElements == 0 && E->getType()->isVoidType())) &&
+ "init list ignored");

erichkeane wrote:

That version ends up having a weird dead branch in non-asserts builds, and is 
problematic as `assert` is a macro.  I don't see the losing the cast as worth 
the additional risk/breaking up the purpose of the assert here, so I'm going to 
leave it.

https://github.com/llvm/llvm-project/pull/158635
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC] Fix Parens on assertion from 147514 (PR #158635)

2025-09-15 Thread Bruno De Fraine via cfe-commits

brunodf-snps wrote:

Thanks for picking this up!

https://github.com/llvm/llvm-project/pull/158635
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC] Fix Parens on assertion from 147514 (PR #158635)

2025-09-15 Thread Bruno De Fraine via cfe-commits


@@ -2142,9 +2142,9 @@ Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr 
*E) {
   bool Ignore = TestAndClearIgnoreResultAssign();
   (void)Ignore;
   unsigned NumInitElements = E->getNumInits();
-  assert(Ignore == false ||
- (NumInitElements == 0 && E->getType()->isVoidType()) &&
- "init list ignored");
+  assert((Ignore == false ||
+  (NumInitElements == 0 && E->getType()->isVoidType())) &&
+ "init list ignored");

brunodf-snps wrote:

The following alternative is perhaps more clear, and allows to remove the 
`(void)Ignore` line from just above.

```suggestion
  if (Ignore)
assert(NumInitElements == 0 && E->getType()->isVoidType()
   && "only ignore irrelevant init list");
```

https://github.com/llvm/llvm-project/pull/158635
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC] Fix Parens on assertion from 147514 (PR #158635)

2025-09-15 Thread Erich Keane via cfe-commits

https://github.com/erichkeane edited 
https://github.com/llvm/llvm-project/pull/158635
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC] Fix Parens on assertion from 147514 (PR #158635)

2025-09-15 Thread Erich Keane via cfe-commits

https://github.com/erichkeane closed 
https://github.com/llvm/llvm-project/pull/158635
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits