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

Richard legalize at xmission.com
Mon May 25 11:36:54 PDT 2015


Hi sunfish, chandlerc, resistor, void, bkramer, dexonsmith, baldrick, nicholas,

Use clang-tidy to simplify boolean conditional return statements

http://reviews.llvm.org/D10001

Files:
  lib/Transforms/Utils/Local.cpp
  lib/Transforms/Utils/SimplifyCFG.cpp
  lib/Transforms/Utils/SimplifyIndVar.cpp

Index: lib/Transforms/Utils/Local.cpp
===================================================================
--- lib/Transforms/Utils/Local.cpp
+++ lib/Transforms/Utils/Local.cpp
@@ -288,14 +288,10 @@
   // We don't want debug info removed by anything this general, unless
   // debug info is empty.
   if (DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(I)) {
-    if (DDI->getAddress())
-      return false;
-    return true;
+    return !DDI->getAddress();
   }
   if (DbgValueInst *DVI = dyn_cast<DbgValueInst>(I)) {
-    if (DVI->getValue())
-      return false;
-    return true;
+    return !DVI->getValue();
   }
 
   if (!I->mayHaveSideEffects()) return true;
Index: lib/Transforms/Utils/SimplifyCFG.cpp
===================================================================
--- lib/Transforms/Utils/SimplifyCFG.cpp
+++ lib/Transforms/Utils/SimplifyCFG.cpp
@@ -3554,11 +3554,8 @@
   // is unreachable.
   DefaultResult =
       DefaultResults.size() == 1 ? DefaultResults.begin()->second : nullptr;
-  if ((!DefaultResult &&
-        !isa<UnreachableInst>(DefaultDest->getFirstNonPHIOrDbg())))
-    return false;
-
-  return true;
+  return DefaultResult ||
+         isa<UnreachableInst>(DefaultDest->getFirstNonPHIOrDbg());
 }
 
 // ConvertTwoCaseSwitch - Helper function that checks if it is possible to
Index: lib/Transforms/Utils/SimplifyIndVar.cpp
===================================================================
--- lib/Transforms/Utils/SimplifyIndVar.cpp
+++ lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -423,10 +423,7 @@
 
   // Only consider affine recurrences.
   const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(S);
-  if (AR && AR->getLoop() == L)
-    return true;
-
-  return false;
+  return AR && AR->getLoop() == L;
 }
 
 /// Iteratively perform simplification on a worklist of users

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10001.26466.patch
Type: text/x-patch
Size: 1808 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150525/f7cf7736/attachment.bin>


More information about the llvm-commits mailing list