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
This commit is contained in:
Dan Gohman 2007-10-03 19:26:29 +00:00
parent 2bb7d0647e
commit cb406c2597
17 changed files with 36 additions and 38 deletions

View File

@ -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 << ", ";

View File

@ -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));
}

View File

@ -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) {

View File

@ -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);

View File

@ -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)

View File

@ -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) {

View File

@ -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<std::string>::iterator i = GVNonLazyPtrs.begin(),
e = GVNonLazyPtrs.end(); i != e; ++i) {

View File

@ -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';
}

View File

@ -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<std::string>::iterator I = GVStubs.begin(),
E = GVStubs.end(); I != E; ++I) {

View File

@ -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';
}

View File

@ -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<std::string>::iterator i = GVStubs.begin(), e = GVStubs.end();

View File

@ -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";
}

View File

@ -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

View File

@ -154,7 +154,7 @@ bool RaiseAllocations::runOnModule(Module &M) {
if (Instruction *I = dyn_cast<Instruction>(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<Instruction>(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())) {

View File

@ -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;

View File

@ -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<PHINode>(Succ->begin()))
if (!Succ->empty() && isa<PHINode>(Succ->begin()))
TI->getSuccessor(i)->removePredecessor(BB);
}
if (!TI->use_empty())

View File

@ -47,14 +47,14 @@ Value::~Value() {
// still being referenced. The value in question should be printed as
// a <badref>
//
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.