[clang] [Clang] omit parentheses in fold expressions with a single expansion (PR #110761)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 4 15:00:59 PDT 2024
================
@@ -15609,6 +15609,14 @@ TreeTransform<Derived>::TransformCXXFoldExpr(CXXFoldExpr *E) {
return true;
}
+ // When there's only one expansion, the parentheses can be safely eliminated
+ // to avoid any extra redundancy that may result in incorrect checks.
+ // For example, transforming (((args == 0) || ...)) into (args == 0)
+ // allows the omission of parentheses while ensuring precise representation
+ // and avoiding warnings regarding redundant parentheses.
+ if (*NumExpansions == 1 && !E->isTypeDependent())
----------------
erichkeane wrote:
I like doing enums, only because they are more descriptive, so I'd suggest one of those, but of size `uint8_t` on `ParenExpr`. If we decide to add a different 'origin' later, that might be useful.
https://github.com/llvm/llvm-project/pull/110761
More information about the cfe-commits
mailing list