Use empty() instead of comparing size() with zero.

llvm-svn: 46514
This commit is contained in:
Dan Gohman 2008-01-29 13:02:09 +00:00
parent cf8827a282
commit 70de4cb1cd
17 changed files with 22 additions and 22 deletions

View File

@ -588,7 +588,7 @@ Archive::findModulesDefiningSymbols(std::set<std::string>& symbols,
bool Archive::isBitcodeArchive() { bool Archive::isBitcodeArchive() {
// Make sure the symTab has been loaded. In most cases this should have been // Make sure the symTab has been loaded. In most cases this should have been
// done when the archive was constructed, but still, this is just in case. // done when the archive was constructed, but still, this is just in case.
if (!symTab.size()) if (symTab.empty())
if (!loadSymbolTable(0)) if (!loadSymbolTable(0))
return false; return false;

View File

@ -1327,7 +1327,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
} }
case bitc::FUNC_CODE_INST_RET: // RET: [opty,opval<optional>] case bitc::FUNC_CODE_INST_RET: // RET: [opty,opval<optional>]
if (Record.size() == 0) { if (Record.empty()) {
I = new ReturnInst(); I = new ReturnInst();
break; break;
} else { } else {

View File

@ -115,7 +115,7 @@ void Deserializer::ReadRecord() {
if (Stream.AtEndOfStream()) if (Stream.AtEndOfStream())
return; return;
assert (Record.size() == 0); assert (Record.empty());
assert (AbbrevNo >= bitc::UNABBREV_RECORD); assert (AbbrevNo >= bitc::UNABBREV_RECORD);
RecordCode = Stream.ReadRecord(AbbrevNo,Record); RecordCode = Stream.ReadRecord(AbbrevNo,Record);
assert (Record.size() > 0); assert (Record.size() > 0);

View File

@ -646,7 +646,7 @@ bool BranchFolder::TailMergeBlocks(MachineFunction &MF) {
} else if (FBB) { } else if (FBB) {
if (TBB!=IBB && FBB!=IBB) // cbr then ubr if (TBB!=IBB && FBB!=IBB) // cbr then ubr
continue; continue;
} else if (Cond.size() == 0) { } else if (Cond.empty()) {
if (TBB!=IBB) // ubr if (TBB!=IBB) // ubr
continue; continue;
} else { } else {

View File

@ -237,7 +237,7 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
// Look for root nodes, i.e. blocks without successors. // Look for root nodes, i.e. blocks without successors.
for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I)
if (I->succ_size() == 0) if (I->succ_empty())
Roots.push_back(I); Roots.push_back(I);
std::vector<IfcvtToken*> Tokens; std::vector<IfcvtToken*> Tokens;
@ -428,7 +428,7 @@ bool IfConverter::ValidTriangle(BBInfo &TrueBBI, BBInfo &FalseBBI,
unsigned Size = TrueBBI.NonPredSize; unsigned Size = TrueBBI.NonPredSize;
if (TrueBBI.IsBrAnalyzable) { if (TrueBBI.IsBrAnalyzable) {
if (TrueBBI.TrueBB && TrueBBI.BrCond.size() == 0) if (TrueBBI.TrueBB && TrueBBI.BrCond.empty())
// End with an unconditional branch. It will be removed. // End with an unconditional branch. It will be removed.
--Size; --Size;
else { else {
@ -646,7 +646,7 @@ IfConverter::BBInfo &IfConverter::AnalyzeBlock(MachineBasicBlock *BB,
ScanInstructions(BBI); ScanInstructions(BBI);
// Unanalyable or ends with fallthrough or unconditional branch. // Unanalyable or ends with fallthrough or unconditional branch.
if (!BBI.IsBrAnalyzable || BBI.BrCond.size() == 0) { if (!BBI.IsBrAnalyzable || BBI.BrCond.empty()) {
BBI.IsBeingAnalyzed = false; BBI.IsBeingAnalyzed = false;
BBI.IsAnalyzed = true; BBI.IsAnalyzed = true;
return BBI; return BBI;

View File

@ -1784,7 +1784,7 @@ void MachineModuleInfo::TidyLandingPads() {
} }
// Remove landing pads with no try-ranges. // Remove landing pads with no try-ranges.
if (!LandingPads[i].BeginLabels.size()) { if (LandingPads[i].BeginLabels.empty()) {
LandingPads.erase(LandingPads.begin() + i); LandingPads.erase(LandingPads.begin() + i);
continue; continue;
} }

View File

@ -801,7 +801,7 @@ SDOperand DAGCombiner::visitTokenFactor(SDNode *N) {
// If we've change things around then replace token factor. // If we've change things around then replace token factor.
if (Changed) { if (Changed) {
if (Ops.size() == 0) { if (Ops.empty()) {
// The entry token is the only possible outcome. // The entry token is the only possible outcome.
Result = DAG.getEntryNode(); Result = DAG.getEntryNode();
} else { } else {

View File

@ -230,7 +230,7 @@ void ScheduleDAG::ComputeLatency(SUnit *SU) {
void ScheduleDAG::CalculateDepths() { void ScheduleDAG::CalculateDepths() {
std::vector<std::pair<SUnit*, unsigned> > WorkList; std::vector<std::pair<SUnit*, unsigned> > WorkList;
for (unsigned i = 0, e = SUnits.size(); i != e; ++i) for (unsigned i = 0, e = SUnits.size(); i != e; ++i)
if (SUnits[i].Preds.size() == 0) if (SUnits[i].Preds.empty())
WorkList.push_back(std::make_pair(&SUnits[i], 0U)); WorkList.push_back(std::make_pair(&SUnits[i], 0U));
while (!WorkList.empty()) { while (!WorkList.empty()) {

View File

@ -169,7 +169,7 @@ void ScheduleDAGList::ListScheduleTopDown() {
// All leaves to Available queue. // All leaves to Available queue.
for (unsigned i = 0, e = SUnits.size(); i != e; ++i) { for (unsigned i = 0, e = SUnits.size(); i != e; ++i) {
// It is available if it has no predecessors. // It is available if it has no predecessors.
if (SUnits[i].Preds.size() == 0 && &SUnits[i] != Entry) { if (SUnits[i].Preds.empty() && &SUnits[i] != Entry) {
AvailableQueue->push(&SUnits[i]); AvailableQueue->push(&SUnits[i]);
SUnits[i].isAvailable = SUnits[i].isPending = true; SUnits[i].isAvailable = SUnits[i].isPending = true;
} }
@ -477,7 +477,7 @@ void LatencyPriorityQueue::CalculatePriorities() {
std::vector<std::pair<const SUnit*, unsigned> > WorkList; std::vector<std::pair<const SUnit*, unsigned> > WorkList;
for (unsigned i = 0, e = SUnits->size(); i != e; ++i) { for (unsigned i = 0, e = SUnits->size(); i != e; ++i) {
const SUnit *SU = &(*SUnits)[i]; const SUnit *SU = &(*SUnits)[i];
if (SU->Succs.size() == 0) if (SU->Succs.empty())
WorkList.push_back(std::make_pair(SU, 0U)); WorkList.push_back(std::make_pair(SU, 0U));
} }

View File

@ -898,7 +898,7 @@ void ScheduleDAGRRList::ListScheduleTopDown() {
// All leaves to Available queue. // All leaves to Available queue.
for (unsigned i = 0, e = SUnits.size(); i != e; ++i) { for (unsigned i = 0, e = SUnits.size(); i != e; ++i) {
// It is available if it has no predecessors. // It is available if it has no predecessors.
if (SUnits[i].Preds.size() == 0 && &SUnits[i] != Entry) { if (SUnits[i].Preds.empty() && &SUnits[i] != Entry) {
AvailableQueue->push(&SUnits[i]); AvailableQueue->push(&SUnits[i]);
SUnits[i].isAvailable = true; SUnits[i].isAvailable = true;
} }

View File

@ -3497,7 +3497,7 @@ bool SDNode::hasNUsesOfValue(unsigned NUses, unsigned Value) const {
bool SDNode::hasAnyUseOfValue(unsigned Value) const { bool SDNode::hasAnyUseOfValue(unsigned Value) const {
assert(Value < getNumValues() && "Bad value!"); assert(Value < getNumValues() && "Bad value!");
if (use_size() == 0) return false; if (use_empty()) return false;
SDOperand TheValue(const_cast<SDNode *>(this), Value); SDOperand TheValue(const_cast<SDNode *>(this), Value);

View File

@ -257,7 +257,7 @@ GenericValue lle_X_floor(FunctionType *FT, const vector<GenericValue> &Args) {
// double drand48() // double drand48()
GenericValue lle_X_drand48(FunctionType *FT, const vector<GenericValue> &Args) { GenericValue lle_X_drand48(FunctionType *FT, const vector<GenericValue> &Args) {
assert(Args.size() == 0); assert(Args.empty());
GenericValue GV; GenericValue GV;
GV.DoubleVal = drand48(); GV.DoubleVal = drand48();
return GV; return GV;
@ -265,7 +265,7 @@ GenericValue lle_X_drand48(FunctionType *FT, const vector<GenericValue> &Args) {
// long lrand48() // long lrand48()
GenericValue lle_X_lrand48(FunctionType *FT, const vector<GenericValue> &Args) { GenericValue lle_X_lrand48(FunctionType *FT, const vector<GenericValue> &Args) {
assert(Args.size() == 0); assert(Args.empty());
GenericValue GV; GenericValue GV;
GV.IntVal = APInt(32, lrand48()); GV.IntVal = APInt(32, lrand48());
return GV; return GV;
@ -282,7 +282,7 @@ GenericValue lle_X_srand48(FunctionType *FT, const vector<GenericValue> &Args) {
// int rand() // int rand()
GenericValue lle_X_rand(FunctionType *FT, const vector<GenericValue> &Args) { GenericValue lle_X_rand(FunctionType *FT, const vector<GenericValue> &Args) {
assert(Args.size() == 0); assert(Args.empty());
GenericValue GV; GenericValue GV;
GV.IntVal = APInt(32, rand()); GV.IntVal = APInt(32, rand());
return GV; return GV;

View File

@ -418,7 +418,7 @@ Path::getDirectoryContents(std::set<Path>& result, std::string* ErrMsg) const {
bool bool
Path::set(const std::string& a_path) { Path::set(const std::string& a_path) {
if (a_path.size() == 0) if (a_path.empty())
return false; return false;
std::string save(path); std::string save(path);
path = a_path; path = a_path;

View File

@ -740,7 +740,7 @@ public:
// If the constant string's length is zero we can optimize this by just // If the constant string's length is zero we can optimize this by just
// doing a store of 0 at the first byte of the destination // doing a store of 0 at the first byte of the destination
if (SrcStr.size() == 0) { if (SrcStr.empty()) {
new StoreInst(ConstantInt::get(Type::Int8Ty, 0), Dst, CI); new StoreInst(ConstantInt::get(Type::Int8Ty, 0), Dst, CI);
return ReplaceCallWith(CI, Dst); return ReplaceCallWith(CI, Dst);
} }

View File

@ -476,7 +476,7 @@ void LICM::sink(Instruction &I) {
while (isa<PHINode>(InsertPt)) ++InsertPt; while (isa<PHINode>(InsertPt)) ++InsertPt;
ExitBlocks[0]->getInstList().insert(InsertPt, &I); ExitBlocks[0]->getInstList().insert(InsertPt, &I);
} }
} else if (ExitBlocks.size() == 0) { } else if (ExitBlocks.empty()) {
// The instruction is actually dead if there ARE NO exit blocks. // The instruction is actually dead if there ARE NO exit blocks.
CurAST->deleteValue(&I); CurAST->deleteValue(&I);
if (!I.use_empty()) // If I has users in unreachable blocks, eliminate. if (!I.use_empty()) // If I has users in unreachable blocks, eliminate.

View File

@ -1214,7 +1214,7 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(const SCEVHandle &Stride,
Loop *L, Loop *L,
bool isOnlyStride) { bool isOnlyStride) {
// If all the users are moved to another stride, then there is nothing to do. // If all the users are moved to another stride, then there is nothing to do.
if (Uses.Users.size() == 0) if (Uses.Users.empty())
return; return;
// Keep track if every use in UsersToProcess is an address. If they all are, // Keep track if every use in UsersToProcess is an address. If they all are,

View File

@ -722,7 +722,7 @@ Value *Reassociate::OptimizeExpression(BinaryOperator *I,
++NumFactor; ++NumFactor;
if (Ops.size() == 0) if (Ops.empty())
return V2; return V2;
// Add the new value to the list of things being added. // Add the new value to the list of things being added.