[PATCH] Refactor: Simplify boolean conditional return statements in llvm/lib/IR
Richard
legalize at xmission.com
Mon May 25 00:02:12 PDT 2015
Hi dexonsmith, dblaikie, void, rafael, chandlerc, manmanren, bkramer, majnemer, echristo, aprantl, arsenm, rnk, craig.topper, reames,
Use clang-tidy to simplify boolean conditional return statements
http://reviews.llvm.org/D9974
Files:
lib/IR/ConstantFold.cpp
lib/IR/InlineAsm.cpp
lib/IR/Instructions.cpp
lib/IR/Verifier.cpp
Index: lib/IR/ConstantFold.cpp
===================================================================
--- lib/IR/ConstantFold.cpp
+++ lib/IR/ConstantFold.cpp
@@ -2020,11 +2020,7 @@
// A negative index or an index past the end of our sequential type is
// considered out-of-range.
int64_t IndexVal = CI->getSExtValue();
- if (IndexVal < 0 || (NumElements > 0 && (uint64_t)IndexVal >= NumElements))
- return false;
-
- // Otherwise, it is in-range.
- return true;
+ return !(IndexVal < 0 || (NumElements > 0 && (uint64_t)IndexVal >= NumElements));
}
template<typename IndexTy>
Index: lib/IR/InlineAsm.cpp
===================================================================
--- lib/IR/InlineAsm.cpp
+++ lib/IR/InlineAsm.cpp
@@ -288,7 +288,6 @@
break;
}
- if (Ty->getNumParams() != NumInputs) return false;
- return true;
+ return Ty->getNumParams() == NumInputs;
}
Index: lib/IR/Instructions.cpp
===================================================================
--- lib/IR/Instructions.cpp
+++ lib/IR/Instructions.cpp
@@ -1372,9 +1372,7 @@
bool ExtractElementInst::isValidOperands(const Value *Val, const Value *Index) {
- if (!Val->getType()->isVectorTy() || !Index->getType()->isIntegerTy())
- return false;
- return true;
+ return !(!Val->getType()->isVectorTy() || !Index->getType()->isIntegerTy());
}
@@ -2602,10 +2600,7 @@
if (SrcBits != DestBits)
return false;
- if (DestTy->isX86_MMXTy() || SrcTy->isX86_MMXTy())
- return false;
-
- return true;
+ return !(DestTy->isX86_MMXTy() || SrcTy->isX86_MMXTy());
}
bool CastInst::isBitOrNoopPointerCastable(Type *SrcTy, Type *DestTy,
Index: lib/IR/Verifier.cpp
===================================================================
--- lib/IR/Verifier.cpp
+++ lib/IR/Verifier.cpp
@@ -1510,12 +1510,9 @@
unsigned LastSlot = Attrs.getNumSlots() - 1;
unsigned LastIndex = Attrs.getSlotIndex(LastSlot);
- if (LastIndex <= Params
+ return LastIndex <= Params
|| (LastIndex == AttributeSet::FunctionIndex
- && (LastSlot == 0 || Attrs.getSlotIndex(LastSlot - 1) <= Params)))
- return true;
-
- return false;
+ && (LastSlot == 0 || Attrs.getSlotIndex(LastSlot - 1) <= Params));
}
/// \brief Verify that statepoint intrinsic is well formed.
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9974.26400.patch
Type: text/x-patch
Size: 2298 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150525/ab52bf2e/attachment.bin>
More information about the llvm-commits
mailing list