[PATCH] Refactor: Simplify boolean expressions in lib/Parse

Richard legalize at xmission.com
Sun Mar 22 13:35:45 PDT 2015


Hi alexfh, doug.gregor, rsmith, akyrtzi, rjmccall, CornedBee,

Simplify boolean expressions using `true` and `false` with `clang-tidy`

http://reviews.llvm.org/D8530

Files:
  lib/Parse/ParseDecl.cpp

Index: lib/Parse/ParseDecl.cpp
===================================================================
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -5187,18 +5187,15 @@
     // If this can't be an abstract-declarator, this *must* be a grouping
     // paren, because we haven't seen the identifier yet.
     isGrouping = true;
-  } else if (Tok.is(tok::r_paren) ||           // 'int()' is a function.
-             (getLangOpts().CPlusPlus && Tok.is(tok::ellipsis) &&
-              NextToken().is(tok::r_paren)) || // C++ int(...)
-             isDeclarationSpecifier() ||       // 'int(int)' is a function.
-             isCXX11AttributeSpecifier()) {    // 'int([[]]int)' is a function.
+  } else
     // This handles C99 6.7.5.3p11: in "typedef int X; void foo(X)", X is
     // considered to be a type, not a K&R identifier-list.
-    isGrouping = false;
-  } else {
     // Otherwise, this is a grouping paren, e.g. 'int (*X)' or 'int(X)'.
-    isGrouping = true;
-  }
+    isGrouping = !(Tok.is(tok::r_paren) || // 'int()' is a function.
+                   (getLangOpts().CPlusPlus && Tok.is(tok::ellipsis) &&
+                    NextToken().is(tok::r_paren)) || // C++ int(...)
+                   isDeclarationSpecifier() || // 'int(int)' is a function.
+                   isCXX11AttributeSpecifier());
 
   // If this is a grouping paren, handle:
   // direct-declarator: '(' declarator ')'

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8530.22440.patch
Type: text/x-patch
Size: 1414 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150322/66f56af3/attachment.bin>


More information about the cfe-commits mailing list