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/
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,
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to