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

Richard legalize at xmission.com
Mon May 25 13:23:50 PDT 2015


Hi djasper, klimek, alexfh, thakis, craig.topper, bkramer,

Use clang-tidy to simplify boolean conditional return statements

http://reviews.llvm.org/D10015

Files:
  lib/Format/ContinuationIndenter.cpp
  lib/Format/TokenAnnotator.cpp

Index: lib/Format/ContinuationIndenter.cpp
===================================================================
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -237,11 +237,8 @@
       Previous.is(tok::l_brace) && !Current.isOneOf(tok::r_brace, tok::comment))
     return true;
 
-  if (Current.is(tok::lessless) && Previous.is(tok::identifier) &&
-      Previous.TokenText == "endl")
-    return true;
-
-  return false;
+  return Current.is(tok::lessless) && Previous.is(tok::identifier) &&
+         Previous.TokenText == "endl";
 }
 
 unsigned ContinuationIndenter::addTokenToState(LineState &State, bool Newline,
Index: lib/Format/TokenAnnotator.cpp
===================================================================
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1850,9 +1850,7 @@
       Left.MatchingParen->Previous->is(tok::period))
     // A.<B>DoSomething();
     return false;
-  if (Left.is(TT_TemplateCloser) && Right.is(tok::l_square))
-    return false;
-  return true;
+  return !Left.is(TT_TemplateCloser) || !Right.is(tok::l_square);
 }
 
 bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,

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


More information about the cfe-commits mailing list