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

Richard legalize at xmission.com
Mon May 25 13:11:57 PDT 2015


Hi ddunbar, rafael, chandlerc, mcrosier, hans, bob.wilson, doug.gregor, krememek, bkramer,

Use clang-tidy to simplify boolean conditional return statements

http://reviews.llvm.org/D10013

Files:
  lib/Driver/Driver.cpp
  lib/Driver/Multilib.cpp
  lib/Driver/Tools.cpp

Index: lib/Driver/Driver.cpp
===================================================================
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1385,10 +1385,7 @@
   if (TC.getSanitizerArgs().needsLTO())
     return true;
 
-  if (Args.hasFlag(options::OPT_flto, options::OPT_fno_lto, false))
-    return true;
-
-  return false;
+  return Args.hasFlag(options::OPT_flto, options::OPT_fno_lto, false);
 }
 
 void Driver::BuildJobs(Compilation &C) const {
@@ -2134,11 +2131,8 @@
     return false;
 
   // Otherwise make sure this is an action clang understands.
-  if (!isa<PreprocessJobAction>(JA) && !isa<PrecompileJobAction>(JA) &&
-      !isa<CompileJobAction>(JA) && !isa<BackendJobAction>(JA))
-    return false;
-
-  return true;
+  return isa<PreprocessJobAction>(JA) || isa<PrecompileJobAction>(JA) ||
+         isa<CompileJobAction>(JA) || isa<BackendJobAction>(JA);
 }
 
 /// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and return the
Index: lib/Driver/Multilib.cpp
===================================================================
--- lib/Driver/Multilib.cpp
+++ lib/Driver/Multilib.cpp
@@ -129,10 +129,7 @@
   if (gccSuffix() != Other.gccSuffix())
     return false;
 
-  if (includeSuffix() != Other.includeSuffix())
-    return false;
-
-  return true;
+  return includeSuffix() == Other.includeSuffix();
 }
 
 raw_ostream &clang::driver::operator<<(raw_ostream &OS, const Multilib &M) {
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -1810,10 +1810,8 @@
     return false;
   }
 
-  if (Split.second.size() && !DecodeAArch64Features(D, Split.second, Features))
-    return false;
-
-  return true;
+  return !Split.second.size() ||
+         DecodeAArch64Features(D, Split.second, Features);
 }
 
 static bool
@@ -1833,10 +1831,8 @@
     return false;
   }
 
-  if (Split.second.size() && !DecodeAArch64Features(D, Split.second, Features))
-    return false;
-
-  return true;
+  return !Split.second.size() ||
+         DecodeAArch64Features(D, Split.second, Features);
 }
 
 static bool
@@ -1844,10 +1840,7 @@
                                const ArgList &Args,
                                std::vector<const char *> &Features) {
   StringRef CPU;
-  if (!DecodeAArch64Mcpu(D, Mcpu, CPU, Features))
-    return false;
-
-  return true;
+  return DecodeAArch64Mcpu(D, Mcpu, CPU, Features);
 }
 
 static bool

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


More information about the cfe-commits mailing list