[PATCH] Refactor: Simplify boolean conditional return statements in lib/Lex

Richard legalize at xmission.com
Mon May 25 14:02:39 PDT 2015


Use clang-tidy to simplify boolean conditional return statements

http://reviews.llvm.org/D10017

Files:
  lib/Lex/PPDirectives.cpp
  lib/Lex/PPMacroExpansion.cpp

Index: lib/Lex/PPDirectives.cpp
===================================================================
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -2012,13 +2012,9 @@
   }
 
   // #define inline
-  if ((MacroName.is(tok::kw_extern) || MacroName.is(tok::kw_inline) ||
-       MacroName.is(tok::kw_static) || MacroName.is(tok::kw_const)) &&
-      MI->getNumTokens() == 0) {
-    return true;
-  }
-
-  return false;
+  return (MacroName.is(tok::kw_extern) || MacroName.is(tok::kw_inline) ||
+          MacroName.is(tok::kw_static) || MacroName.is(tok::kw_const)) &&
+         MI->getNumTokens() == 0;
 }
 
 /// HandleDefineDirective - Implements \#define.  This consumes the entire macro
Index: lib/Lex/PPMacroExpansion.cpp
===================================================================
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -597,9 +597,7 @@
       Brackets.pop_back();
     }
   }
-  if (!Brackets.empty())
-    return false;
-  return true;
+  return Brackets.empty();
 }
 
 /// GenerateNewArgTokens - Returns true if OldTokens can be converted to a new

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10017.26489.patch
Type: text/x-patch
Size: 1105 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150525/8c23a79b/attachment.bin>


More information about the cfe-commits mailing list