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

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


diff -U9999


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,21 +1831,16 @@
     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
 getAArch64ArchFeaturesFromMcpu(const Driver &D, StringRef Mcpu,
                                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.26482.patch
Type: text/x-patch
Size: 2503 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150525/17c8ab9e/attachment.bin>


More information about the cfe-commits mailing list