Use clang-tidy to simplify boolean conditional return statements

http://reviews.llvm.org/D10022

Files:
  lib/StaticAnalyzer/Core/CallEvent.cpp
  lib/StaticAnalyzer/Core/CheckerContext.cpp
  lib/StaticAnalyzer/Core/CheckerRegistry.cpp
  lib/StaticAnalyzer/Core/ExplodedGraph.cpp
  lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  lib/StaticAnalyzer/Core/SValBuilder.cpp
  lib/StaticAnalyzer/Core/SymbolManager.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===================================================================
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -116,9 +116,7 @@
     return false;
   if (!PointeeTy.isConstQualified())
     return false;
-  if (PointeeTy->isAnyPointerType())
-    return false;
-  return true;
+  return !PointeeTy->isAnyPointerType();
 }
 
 // Try to retrieve the function declaration and find the function parameter
Index: lib/StaticAnalyzer/Core/CheckerContext.cpp
===================================================================
--- lib/StaticAnalyzer/Core/CheckerContext.cpp
+++ lib/StaticAnalyzer/Core/CheckerContext.cpp
@@ -81,11 +81,8 @@
   if (FName.startswith("__inline") && (FName.find(Name) != StringRef::npos))
     return true;
 
-  if (FName.startswith("__") && FName.endswith("_chk") &&
-      FName.find(Name) != StringRef::npos)
-    return true;
-
-  return false;
+  return FName.startswith("__") && FName.endswith("_chk") &&
+         FName.find(Name) != StringRef::npos;
 }
 
 StringRef CheckerContext::getMacroNameOrSpelling(SourceLocation &Loc) {
Index: lib/StaticAnalyzer/Core/CheckerRegistry.cpp
===================================================================
--- lib/StaticAnalyzer/Core/CheckerRegistry.cpp
+++ lib/StaticAnalyzer/Core/CheckerRegistry.cpp
@@ -35,10 +35,7 @@
     return true;
 
   // Is the checker in the package (or a subpackage)?
-  if (checker.FullName[packageName.size()] == PackageSeparator)
-    return true;
-
-  return false;
+  return checker.FullName[packageName.size()] == PackageSeparator;
 }
 
 static void collectCheckers(const CheckerRegistry::CheckerInfoList &checkers,
Index: lib/StaticAnalyzer/Core/ExplodedGraph.cpp
===================================================================
--- lib/StaticAnalyzer/Core/ExplodedGraph.cpp
+++ lib/StaticAnalyzer/Core/ExplodedGraph.cpp
@@ -155,10 +155,7 @@
       return false;
 
   // Condition 10, continuation.
-  if (SuccLoc.getAs<CallEnter>() || SuccLoc.getAs<PreImplicitCall>())
-    return false;
-
-  return true;
+  return !SuccLoc.getAs<CallEnter>() && !SuccLoc.getAs<PreImplicitCall>();
 }
 
 void ExplodedGraph::collectNode(ExplodedNode *node) {
Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===================================================================
--- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -690,12 +690,8 @@
     return true;
 
   CXXBasePaths Paths(false, false, false);
-  if (RD->lookupInBases(&CXXRecordDecl::FindOrdinaryMember,
-                        DeclName.getAsOpaquePtr(),
-                        Paths))
-    return true;
-
-  return false;
+  return RD->lookupInBases(&CXXRecordDecl::FindOrdinaryMember,
+                           DeclName.getAsOpaquePtr(), Paths);
 }
 
 /// Returns true if the given C++ class is a container or iterator.
@@ -791,10 +787,7 @@
 
   // It is possible that the live variables analysis cannot be
   // run.  If so, bail out.
-  if (!CalleeADC->getAnalysis<RelaxedLiveVariables>())
-    return false;
-
-  return true;
+  return CalleeADC->getAnalysis<RelaxedLiveVariables>();
 }
 
 bool ExprEngine::shouldInlineCall(const CallEvent &Call, const Decl *D,
Index: lib/StaticAnalyzer/Core/SValBuilder.cpp
===================================================================
--- lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -389,10 +389,7 @@
   if (ToTy->isVoidType())
     return true;
 
-  if (ToTy != FromTy)
-    return false;
-
-  return true;
+  return ToTy == FromTy;
 }
 
 // FIXME: should rewrite according to the cast kind.
Index: lib/StaticAnalyzer/Core/SymbolManager.cpp
===================================================================
--- lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -338,10 +338,7 @@
   if (T->isIntegralOrEnumerationType())
     return true;
 
-  if (T->isRecordType() && !T->isUnionType())
-    return true;
-
-  return false;
+  return T->isRecordType() && !T->isUnionType();
 }
 
 void SymbolManager::addSymbolDependency(const SymbolRef Primary,
@@ -431,10 +428,7 @@
   if (isa<MemSpaceRegion>(MR))
     return true;
 
-  if (isa<CodeTextRegion>(MR))
-    return true;
-
-  return false;
+  return isa<CodeTextRegion>(MR);
 }
 
 bool SymbolReaper::isLive(SymbolRef sym) {
@@ -493,9 +487,7 @@
   if (LCtx != ELCtx) {
     // If the reaper's location context is a parent of the expression's
     // location context, then the expression value is now "out of scope".
-    if (LCtx->isParentOf(ELCtx))
-      return false;
-    return true;
+    return !LCtx->isParentOf(ELCtx);
   }
 
   // If no statement is provided, everything is this and parent contexts is live.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to