[llvm] r231617 - Simplify expressions involving boolean constants with clang-tidy
David Blaikie
dblaikie at gmail.com
Sun Mar 8 18:57:13 PDT 2015
Author: dblaikie
Date: Sun Mar 8 20:57:13 2015
New Revision: 231617
URL: http://llvm.org/viewvc/llvm-project?rev=231617&view=rev
Log:
Simplify expressions involving boolean constants with clang-tidy
Patch by Richard (legalize at xmission dot com).
Differential Revision: http://reviews.llvm.org/D8154
Modified:
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp
llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
llvm/trunk/lib/CodeGen/IfConversion.cpp
llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
llvm/trunk/lib/IR/DiagnosticInfo.cpp
llvm/trunk/lib/IR/InlineAsm.cpp
llvm/trunk/lib/IR/Verifier.cpp
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp
llvm/trunk/lib/Support/APFloat.cpp
llvm/trunk/lib/Support/CommandLine.cpp
llvm/trunk/lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp
llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=231617&r1=231616&r2=231617&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Sun Mar 8 20:57:13 2015
@@ -6198,7 +6198,7 @@ ScalarEvolution::HowFarToZero(const SCEV
dyn_cast<ConstantInt>(ConstantExpr::getICmp(CmpInst::ICMP_ULT,
R1->getValue(),
R2->getValue()))) {
- if (CB->getZExtValue() == false)
+ if (!CB->getZExtValue())
std::swap(R1, R2); // R1 is the minimum root now.
// We can only use this value if the chrec ends up with an exact zero
@@ -7521,7 +7521,7 @@ const SCEV *SCEVAddRecExpr::getNumIterat
if (ConstantInt *CB =
dyn_cast<ConstantInt>(ConstantExpr::getICmp(ICmpInst::ICMP_ULT,
R1->getValue(), R2->getValue()))) {
- if (CB->getZExtValue() == false)
+ if (!CB->getZExtValue())
std::swap(R1, R2); // R1 is the minimum root now.
// Make sure the root is not off by one. The returned iteration should
Modified: llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp?rev=231617&r1=231616&r2=231617&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp Sun Mar 8 20:57:13 2015
@@ -245,7 +245,7 @@ void BitstreamCursor::ReadAbbrevRecord()
BitCodeAbbrev *Abbv = new BitCodeAbbrev();
unsigned NumOpInfo = ReadVBR(5);
for (unsigned i = 0; i != NumOpInfo; ++i) {
- bool IsLiteral = Read(1) ? true : false;
+ bool IsLiteral = Read(1);
if (IsLiteral) {
Abbv->Add(BitCodeAbbrevOp(ReadVBR64(8)));
continue;
Modified: llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp?rev=231617&r1=231616&r2=231617&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp Sun Mar 8 20:57:13 2015
@@ -4466,8 +4466,7 @@ static void scaleWeights(uint64_t &NewTr
/// FIXME: Remove the (equivalent?) implementation in SelectionDAG.
///
bool CodeGenPrepare::splitBranchCondition(Function &F) {
- if (!TM || TM->Options.EnableFastISel != true ||
- !TLI || TLI->isJumpExpensive())
+ if (!TM || !TM->Options.EnableFastISel || !TLI || TLI->isJumpExpensive())
return false;
bool MadeChange = false;
Modified: llvm/trunk/lib/CodeGen/IfConversion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IfConversion.cpp?rev=231617&r1=231616&r2=231617&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/IfConversion.cpp (original)
+++ llvm/trunk/lib/CodeGen/IfConversion.cpp Sun Mar 8 20:57:13 2015
@@ -247,7 +247,7 @@ namespace {
return true;
else if (Incr1 == Incr2) {
// Favors subsumption.
- if (C1->NeedSubsumption == false && C2->NeedSubsumption == true)
+ if (!C1->NeedSubsumption && C2->NeedSubsumption)
return true;
else if (C1->NeedSubsumption == C2->NeedSubsumption) {
// Favors diamond over triangle, etc.
Modified: llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp?rev=231617&r1=231616&r2=231617&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp (original)
+++ llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp Sun Mar 8 20:57:13 2015
@@ -915,7 +915,7 @@ bool PeepholeOptimizer::optimizeCoalesca
// => v0 = COPY v1
// Currently we haven't seen motivating example for that and we
// want to avoid untested code.
- NumRewrittenCopies += Changed == true;
+ NumRewrittenCopies += Changed;
return Changed;
}
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp?rev=231617&r1=231616&r2=231617&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp Sun Mar 8 20:57:13 2015
@@ -1128,7 +1128,7 @@ relocation_iterator RuntimeDyldELF::proc
RangeOverflow = true;
}
}
- if (SymType == SymbolRef::ST_Unknown || RangeOverflow == true) {
+ if (SymType == SymbolRef::ST_Unknown || RangeOverflow) {
// It is an external symbol (SymbolRef::ST_Unknown) or within a range
// larger than 24-bits.
StubMap::const_iterator i = Stubs.find(Value);
Modified: llvm/trunk/lib/IR/DiagnosticInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DiagnosticInfo.cpp?rev=231617&r1=231616&r2=231617&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DiagnosticInfo.cpp (original)
+++ llvm/trunk/lib/IR/DiagnosticInfo.cpp Sun Mar 8 20:57:13 2015
@@ -129,7 +129,7 @@ void DiagnosticInfoSampleProfile::print(
}
bool DiagnosticInfoOptimizationBase::isLocationAvailable() const {
- return getDebugLoc().isUnknown() == false;
+ return !getDebugLoc().isUnknown();
}
void DiagnosticInfoOptimizationBase::getLocation(StringRef *Filename,
Modified: llvm/trunk/lib/IR/InlineAsm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/InlineAsm.cpp?rev=231617&r1=231616&r2=231617&view=diff
==============================================================================
--- llvm/trunk/lib/IR/InlineAsm.cpp (original)
+++ llvm/trunk/lib/IR/InlineAsm.cpp Sun Mar 8 20:57:13 2015
@@ -75,7 +75,7 @@ bool InlineAsm::ConstraintInfo::Parse(St
ConstraintCodeVector *pCodes = &Codes;
// Initialize
- isMultipleAlternative = (multipleAlternativeCount > 1 ? true : false);
+ isMultipleAlternative = multipleAlternativeCount > 1;
if (isMultipleAlternative) {
multipleAlternatives.resize(multipleAlternativeCount);
pCodes = &multipleAlternatives[0].Codes;
Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=231617&r1=231616&r2=231617&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Sun Mar 8 20:57:13 2015
@@ -2709,7 +2709,7 @@ Verifier::VerifyIntrinsicIsVarArg(bool i
// If there are no descriptors left, then it can't be a vararg.
if (Infos.empty())
- return isVarArg ? true : false;
+ return isVarArg;
// There should be only one descriptor remaining at this point.
if (Infos.size() != 1)
@@ -2719,7 +2719,7 @@ Verifier::VerifyIntrinsicIsVarArg(bool i
IITDescriptor D = Infos.front();
Infos = Infos.slice(1);
if (D.Kind == IITDescriptor::VarArg)
- return isVarArg ? false : true;
+ return !isVarArg;
return true;
}
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=231617&r1=231616&r2=231617&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Sun Mar 8 20:57:13 2015
@@ -2791,7 +2791,7 @@ bool AsmParser::parseDirectiveFile(SMLoc
if (FileNumber == -1)
getStreamer().EmitFileDirective(Filename);
else {
- if (getContext().getGenDwarfForAssembly() == true)
+ if (getContext().getGenDwarfForAssembly())
Error(DirectiveLoc,
"input can't have .file dwarf directives when -g is "
"used to generate dwarf debug info for assembly code");
Modified: llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp?rev=231617&r1=231616&r2=231617&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp Sun Mar 8 20:57:13 2015
@@ -626,7 +626,7 @@ bool DarwinAsmParser::parseDirectiveSecu
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.secure_log_unique' directive");
- if (getContext().getSecureLogUsed() != false)
+ if (getContext().getSecureLogUsed())
return Error(IDLoc, ".secure_log_unique specified multiple times");
// Get the secure log path.
Modified: llvm/trunk/lib/Support/APFloat.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APFloat.cpp?rev=231617&r1=231616&r2=231617&view=diff
==============================================================================
--- llvm/trunk/lib/Support/APFloat.cpp (original)
+++ llvm/trunk/lib/Support/APFloat.cpp Sun Mar 8 20:57:13 2015
@@ -1248,10 +1248,10 @@ APFloat::roundAwayFromZero(roundingMode
return false;
case rmTowardPositive:
- return sign == false;
+ return !sign;
case rmTowardNegative:
- return sign == true;
+ return sign;
}
llvm_unreachable("Invalid rounding mode found");
}
Modified: llvm/trunk/lib/Support/CommandLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=231617&r1=231616&r2=231617&view=diff
==============================================================================
--- llvm/trunk/lib/Support/CommandLine.cpp (original)
+++ llvm/trunk/lib/Support/CommandLine.cpp Sun Mar 8 20:57:13 2015
@@ -1516,7 +1516,7 @@ public:
// Invoke the printer.
void operator=(bool Value) {
- if (Value == false)
+ if (!Value)
return;
StrOptionPairVector Opts;
@@ -1716,7 +1716,7 @@ static cl::opt<bool> PrintAllOptions(
cl::init(false), cl::cat(GenericCategory));
void HelpPrinterWrapper::operator=(bool Value) {
- if (Value == false)
+ if (!Value)
return;
// Decide which printer to invoke. If more than one option category is
Modified: llvm/trunk/lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp?rev=231617&r1=231616&r2=231617&view=diff
==============================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp (original)
+++ llvm/trunk/lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp Sun Mar 8 20:57:13 2015
@@ -120,7 +120,7 @@ bool NVPTXLowerAggrCopies::runOnFunction
++II) {
if (LoadInst *load = dyn_cast<LoadInst>(II)) {
- if (load->hasOneUse() == false)
+ if (!load->hasOneUse())
continue;
if (DL.getTypeStoreSize(load->getType()) < MaxAggrCopySize)
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp?rev=231617&r1=231616&r2=231617&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp Sun Mar 8 20:57:13 2015
@@ -927,7 +927,7 @@ Instruction *InstCombiner::visitSelectIn
return BinaryOperator::CreateAnd(NotCond, FalseVal);
}
if (ConstantInt *C = dyn_cast<ConstantInt>(FalseVal)) {
- if (C->getZExtValue() == false) {
+ if (!C->getZExtValue()) {
// Change: A = select B, C, false --> A = and B, C
return BinaryOperator::CreateAnd(CondVal, TrueVal);
}
More information about the llvm-commits
mailing list