From cb406c25973b4e88a6c10ad839ef1beeb3664715 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 3 Oct 2007 19:26:29 +0000 Subject: [PATCH] Use empty() member functions when that's what's being tested for instead of comparing begin() and end(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42585 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/AliasSetTracker.cpp | 2 +- lib/Analysis/LoopPass.cpp | 4 ++-- lib/CodeGen/LiveIntervalAnalysis.cpp | 20 +++++++++----------- lib/CodeGen/MachineBasicBlock.cpp | 2 +- lib/CodeGen/MachineFunction.cpp | 4 ++-- lib/CodeGen/SelectionDAG/ScheduleDAG.cpp | 2 +- lib/Target/ARM/ARMAsmPrinter.cpp | 2 +- lib/Target/IA64/IA64AsmPrinter.cpp | 2 +- lib/Target/PowerPC/PPCAsmPrinter.cpp | 2 +- lib/Target/X86/X86ATTAsmPrinter.cpp | 2 +- lib/Target/X86/X86AsmPrinter.cpp | 6 +++--- lib/Target/X86/X86IntelAsmPrinter.cpp | 10 +++++----- lib/Transforms/IPO/Inliner.cpp | 4 ++-- lib/Transforms/IPO/RaiseAllocations.cpp | 4 ++-- lib/Transforms/Scalar/LICM.cpp | 2 +- lib/Transforms/Scalar/SCCP.cpp | 2 +- lib/VMCore/Value.cpp | 4 ++-- 17 files changed, 36 insertions(+), 38 deletions(-) diff --git a/lib/Analysis/AliasSetTracker.cpp b/lib/Analysis/AliasSetTracker.cpp index 0397af7e979..366909c0ebe 100644 --- a/lib/Analysis/AliasSetTracker.cpp +++ b/lib/Analysis/AliasSetTracker.cpp @@ -520,7 +520,7 @@ void AliasSet::print(std::ostream &OS) const { OS << " forwarding to " << (void*)Forward; - if (begin() != end()) { + if (!empty()) { OS << "Pointers: "; for (iterator I = begin(), E = end(); I != E; ++I) { if (I != begin()) OS << ", "; diff --git a/lib/Analysis/LoopPass.cpp b/lib/Analysis/LoopPass.cpp index 414769bff74..c53d85f1fdf 100644 --- a/lib/Analysis/LoopPass.cpp +++ b/lib/Analysis/LoopPass.cpp @@ -54,7 +54,7 @@ void LPPassManager::deleteLoopFromQueue(Loop *L) { } // Move all subloops into the parent loop. - while (L->begin() != L->end()) + while (!L->empty()) ParentLoop->addChildLoop(L->removeChildLoop(L->end()-1)); } else { // Reparent all of the blocks in this loop. Since BBLoop had no parent, @@ -78,7 +78,7 @@ void LPPassManager::deleteLoopFromQueue(Loop *L) { } // Move all of the subloops to the top-level. - while (L->begin() != L->end()) + while (!L->empty()) LI->addTopLevelLoop(L->removeChildLoop(L->end()-1)); } diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp index e7abd47f536..88eeff7605a 100644 --- a/lib/CodeGen/LiveIntervalAnalysis.cpp +++ b/lib/CodeGen/LiveIntervalAnalysis.cpp @@ -817,17 +817,15 @@ void LiveIntervals::computeIntervals() { MachineBasicBlock::iterator MI = MBB->begin(), miEnd = MBB->end(); - if (MBB->livein_begin() != MBB->livein_end()) { - // Create intervals for live-ins to this BB first. - for (MachineBasicBlock::const_livein_iterator LI = MBB->livein_begin(), - LE = MBB->livein_end(); LI != LE; ++LI) { - handleLiveInRegister(MBB, MIIndex, getOrCreateInterval(*LI)); - // Multiple live-ins can alias the same register. - for (const unsigned* AS = mri_->getSubRegisters(*LI); *AS; ++AS) - if (!hasInterval(*AS)) - handleLiveInRegister(MBB, MIIndex, getOrCreateInterval(*AS), - true); - } + // Create intervals for live-ins to this BB first. + for (MachineBasicBlock::const_livein_iterator LI = MBB->livein_begin(), + LE = MBB->livein_end(); LI != LE; ++LI) { + handleLiveInRegister(MBB, MIIndex, getOrCreateInterval(*LI)); + // Multiple live-ins can alias the same register. + for (const unsigned* AS = mri_->getSubRegisters(*LI); *AS; ++AS) + if (!hasInterval(*AS)) + handleLiveInRegister(MBB, MIIndex, getOrCreateInterval(*AS), + true); } for (; MI != miEnd; ++MI) { diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp index 134d2767861..6a8b083be83 100644 --- a/lib/CodeGen/MachineBasicBlock.cpp +++ b/lib/CodeGen/MachineBasicBlock.cpp @@ -119,7 +119,7 @@ void MachineBasicBlock::print(std::ostream &OS) const { OS << ":\n"; const MRegisterInfo *MRI = MF->getTarget().getRegisterInfo(); - if (livein_begin() != livein_end()) { + if (!livein_empty()) { OS << "Live Ins:"; for (const_livein_iterator I = livein_begin(),E = livein_end(); I != E; ++I) OutputReg(OS, *I, MRI); diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp index c762ae567c8..ca7468476ad 100644 --- a/lib/CodeGen/MachineFunction.cpp +++ b/lib/CodeGen/MachineFunction.cpp @@ -208,7 +208,7 @@ void MachineFunction::print(std::ostream &OS) const { const MRegisterInfo *MRI = getTarget().getRegisterInfo(); - if (livein_begin() != livein_end()) { + if (!livein_empty()) { OS << "Live Ins:"; for (livein_iterator I = livein_begin(), E = livein_end(); I != E; ++I) { if (MRI) @@ -221,7 +221,7 @@ void MachineFunction::print(std::ostream &OS) const { } OS << "\n"; } - if (liveout_begin() != liveout_end()) { + if (!liveout_empty()) { OS << "Live Outs:"; for (liveout_iterator I = liveout_begin(), E = liveout_end(); I != E; ++I) if (MRI) diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp index d90accda627..bd5c5983327 100644 --- a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp +++ b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp @@ -866,7 +866,7 @@ void ScheduleDAG::EmitSchedule() { // that need to be copied into vregs, emit the copies into the top of the // block before emitting the code for the block. MachineFunction &MF = DAG.getMachineFunction(); - if (&MF.front() == BB && MF.livein_begin() != MF.livein_end()) { + if (&MF.front() == BB) { for (MachineFunction::livein_iterator LI = MF.livein_begin(), E = MF.livein_end(); LI != E; ++LI) if (LI->second) { diff --git a/lib/Target/ARM/ARMAsmPrinter.cpp b/lib/Target/ARM/ARMAsmPrinter.cpp index 38183c6f12f..9435cc1174f 100644 --- a/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/ARMAsmPrinter.cpp @@ -1001,7 +1001,7 @@ bool ARMAsmPrinter::doFinalization(Module &M) { O << "\n"; // Output non-lazy-pointers for external and common global variables. - if (GVNonLazyPtrs.begin() != GVNonLazyPtrs.end()) + if (!GVNonLazyPtrs.empty()) SwitchToDataSection(".non_lazy_symbol_pointer", 0); for (std::set::iterator i = GVNonLazyPtrs.begin(), e = GVNonLazyPtrs.end(); i != e; ++i) { diff --git a/lib/Target/IA64/IA64AsmPrinter.cpp b/lib/Target/IA64/IA64AsmPrinter.cpp index cb2cf620afc..08a27d48ca2 100644 --- a/lib/Target/IA64/IA64AsmPrinter.cpp +++ b/lib/Target/IA64/IA64AsmPrinter.cpp @@ -147,7 +147,7 @@ bool IA64AsmPrinter::runOnMachineFunction(MachineFunction &MF) { for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); I != E; ++I) { // Print a label for the basic block if there are any predecessors. - if (I->pred_begin() != I->pred_end()) { + if (!I->pred_empty()) { printBasicBlockLabel(I, true); O << '\n'; } diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp index b561c043da7..9ff41cab90c 100644 --- a/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -1053,7 +1053,7 @@ bool DarwinAsmPrinter::doFinalization(Module &M) { O << "\n"; // Output stubs for external and common global variables. - if (GVStubs.begin() != GVStubs.end()) { + if (!GVStubs.empty()) { SwitchToDataSection(".non_lazy_symbol_pointer"); for (std::set::iterator I = GVStubs.begin(), E = GVStubs.end(); I != E; ++I) { diff --git a/lib/Target/X86/X86ATTAsmPrinter.cpp b/lib/Target/X86/X86ATTAsmPrinter.cpp index e53edff65d8..8e52e00f47a 100644 --- a/lib/Target/X86/X86ATTAsmPrinter.cpp +++ b/lib/Target/X86/X86ATTAsmPrinter.cpp @@ -168,7 +168,7 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) { for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); I != E; ++I) { // Print a label for the basic block. - if (I->pred_begin() != I->pred_end()) { + if (!I->pred_empty()) { printBasicBlockLabel(I, true); O << '\n'; } diff --git a/lib/Target/X86/X86AsmPrinter.cpp b/lib/Target/X86/X86AsmPrinter.cpp index c4d5958bfca..7855e50e43d 100644 --- a/lib/Target/X86/X86AsmPrinter.cpp +++ b/lib/Target/X86/X86AsmPrinter.cpp @@ -316,7 +316,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) { } // Output linker support code for dllexported globals - if (DLLExportedGVs.begin() != DLLExportedGVs.end()) { + if (!DLLExportedGVs.empty()) { SwitchToDataSection(".section .drectve"); } @@ -326,7 +326,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) { O << "\t.ascii \" -export:" << *i << ",data\"\n"; } - if (DLLExportedFns.begin() != DLLExportedFns.end()) { + if (!DLLExportedFns.empty()) { SwitchToDataSection(".section .drectve"); } @@ -362,7 +362,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) { } // Output stubs for external and common global variables. - if (GVStubs.begin() != GVStubs.end()) + if (!GVStubs.empty()) SwitchToDataSection( ".section __IMPORT,__pointers,non_lazy_symbol_pointers"); for (std::set::iterator i = GVStubs.begin(), e = GVStubs.end(); diff --git a/lib/Target/X86/X86IntelAsmPrinter.cpp b/lib/Target/X86/X86IntelAsmPrinter.cpp index 72ba1b098bc..bd8886cd86a 100644 --- a/lib/Target/X86/X86IntelAsmPrinter.cpp +++ b/lib/Target/X86/X86IntelAsmPrinter.cpp @@ -77,7 +77,7 @@ bool X86IntelAsmPrinter::runOnMachineFunction(MachineFunction &MF) { for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); I != E; ++I) { // Print a label for the basic block if there are any predecessors. - if (I->pred_begin() != I->pred_end()) { + if (!I->pred_empty()) { printBasicBlockLabel(I, true); O << '\n'; } @@ -412,8 +412,8 @@ bool X86IntelAsmPrinter::doFinalization(Module &M) { } // Output linker support code for dllexported globals - if ((DLLExportedGVs.begin() != DLLExportedGVs.end()) || - (DLLExportedFns.begin() != DLLExportedFns.end())) { + if (!DLLExportedGVs.empty() || + !DLLExportedFns.empty()) { SwitchToDataSection(""); O << "; WARNING: The following code is valid only with MASM v8.x and (possible) higher\n" << "; This version of MASM is usually shipped with Microsoft Visual Studio 2005\n" @@ -434,8 +434,8 @@ bool X86IntelAsmPrinter::doFinalization(Module &M) { O << "\t db ' /EXPORT:" << *i << "'\n"; } - if ((DLLExportedGVs.begin() != DLLExportedGVs.end()) || - (DLLExportedFns.begin() != DLLExportedFns.end())) { + if (!DLLExportedGVs.empty() || + !DLLExportedFns.empty()) { O << "_drectve\t ends\n"; } diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp index 85893d706fe..13739a5ea28 100644 --- a/lib/Transforms/IPO/Inliner.cpp +++ b/lib/Transforms/IPO/Inliner.cpp @@ -63,7 +63,7 @@ static bool InlineCallIfPossible(CallSite CS, CallGraph &CG, // Remove any call graph edges from the callee to its callees. CallGraphNode *CalleeNode = CG[Callee]; - while (CalleeNode->begin() != CalleeNode->end()) + while (!CalleeNode->empty()) CalleeNode->removeCallEdgeTo((CalleeNode->end()-1)->second); // Removing the node for callee from the call graph and delete it. @@ -188,7 +188,7 @@ bool Inliner::doFinalization(CallGraph &CG) { F->use_empty()) { // Remove any call graph edges from the function to its callees. - while (CGN->begin() != CGN->end()) + while (!CGN->empty()) CGN->removeCallEdgeTo((CGN->end()-1)->second); // Remove any edges from the external node to the function's call graph diff --git a/lib/Transforms/IPO/RaiseAllocations.cpp b/lib/Transforms/IPO/RaiseAllocations.cpp index ed4a3769dbe..44702bc8179 100644 --- a/lib/Transforms/IPO/RaiseAllocations.cpp +++ b/lib/Transforms/IPO/RaiseAllocations.cpp @@ -154,7 +154,7 @@ bool RaiseAllocations::runOnModule(Module &M) { if (Instruction *I = dyn_cast(U)) { CallSite CS = CallSite::get(I); - if (CS.getInstruction() && CS.arg_begin() != CS.arg_end() && + if (CS.getInstruction() && !CS.arg_empty() && (CS.getCalledFunction() == MallocFunc || std::find(EqPointers.begin(), EqPointers.end(), CS.getCalledValue()) != EqPointers.end())) { @@ -205,7 +205,7 @@ bool RaiseAllocations::runOnModule(Module &M) { if (Instruction *I = dyn_cast(U)) { CallSite CS = CallSite::get(I); - if (CS.getInstruction() && CS.arg_begin() != CS.arg_end() && + if (CS.getInstruction() && !CS.arg_empty() && (CS.getCalledFunction() == FreeFunc || std::find(EqPointers.begin(), EqPointers.end(), CS.getCalledValue()) != EqPointers.end())) { diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp index e795aa9c0c5..8a094aa9678 100644 --- a/lib/Transforms/Scalar/LICM.cpp +++ b/lib/Transforms/Scalar/LICM.cpp @@ -786,7 +786,7 @@ void LICM::FindPromotableValuesInLoop( // volatile loads or stores. if (!AS.isForwardingAliasSet() && AS.isMod() && AS.isMustAlias() && !AS.isVolatile() && CurLoop->isLoopInvariant(AS.begin()->first)) { - assert(AS.begin() != AS.end() && + assert(!AS.empty() && "Must alias set should have at least one pointer element in it!"); Value *V = AS.begin()->first; diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index dacaad01a3b..d236039332e 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -1574,7 +1574,7 @@ bool IPSCCP::runOnModule(Module &M) { for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i) { BasicBlock *Succ = TI->getSuccessor(i); - if (Succ->begin() != Succ->end() && isa(Succ->begin())) + if (!Succ->empty() && isa(Succ->begin())) TI->getSuccessor(i)->removePredecessor(BB); } if (!TI->use_empty()) diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index 0150c7e6e96..de6c16b5214 100644 --- a/lib/VMCore/Value.cpp +++ b/lib/VMCore/Value.cpp @@ -47,14 +47,14 @@ Value::~Value() { // still being referenced. The value in question should be printed as // a // - if (use_begin() != use_end()) { + if (!use_empty()) { DOUT << "While deleting: " << *Ty << " %" << Name << "\n"; for (use_iterator I = use_begin(), E = use_end(); I != E; ++I) DOUT << "Use still stuck around after Def is destroyed:" << **I << "\n"; } #endif - assert(use_begin() == use_end() && "Uses remain when a value is destroyed!"); + assert(use_empty() && "Uses remain when a value is destroyed!"); // If this value is named, destroy the name. This should not be in a symtab // at this point.