Use empty() instead of comparing size() with zero.
authorDan Gohman <gohman@apple.com>
Tue, 29 Jan 2008 13:02:09 +0000 (13:02 +0000)
committerDan Gohman <gohman@apple.com>
Tue, 29 Jan 2008 13:02:09 +0000 (13:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46514 91177308-0d34-0410-b5e6-96231b3b80d8

17 files changed:
lib/Archive/ArchiveReader.cpp
lib/Bitcode/Reader/BitcodeReader.cpp
lib/Bitcode/Reader/Deserialize.cpp
lib/CodeGen/BranchFolding.cpp
lib/CodeGen/IfConversion.cpp
lib/CodeGen/MachineModuleInfo.cpp
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
lib/CodeGen/SelectionDAG/ScheduleDAGList.cpp
lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
lib/System/Win32/Path.inc
lib/Transforms/IPO/SimplifyLibCalls.cpp
lib/Transforms/Scalar/LICM.cpp
lib/Transforms/Scalar/LoopStrengthReduce.cpp
lib/Transforms/Scalar/Reassociate.cpp

index 13a92a95ca20961d3ba79f85277502cd79542f4a..368bd323a6ccd09fa0d77630ca5635dbc3d0251d 100644 (file)
@@ -588,7 +588,7 @@ Archive::findModulesDefiningSymbols(std::set<std::string>& symbols,
 bool Archive::isBitcodeArchive() {
   // 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.
-  if (!symTab.size())
+  if (symTab.empty())
     if (!loadSymbolTable(0))
       return false;
 
index 2d16230bb9138a9dd7792bd6b2a3694546f17daa..ec71ba4e9c6822329bd951964d2664be3abf6676 100644 (file)
@@ -1327,7 +1327,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
     }
     
     case bitc::FUNC_CODE_INST_RET: // RET: [opty,opval<optional>]
-      if (Record.size() == 0) {
+      if (Record.empty()) {
         I = new ReturnInst();
         break;
       } else {
index 3496d24e513c71df13ce2b75d7c7563275aea649..8455d0e630f5ec9eb425af13666824280f9106f2 100644 (file)
@@ -115,7 +115,7 @@ void Deserializer::ReadRecord() {
   if (Stream.AtEndOfStream())
     return;
   
-  assert (Record.size() == 0);
+  assert (Record.empty());
   assert (AbbrevNo >= bitc::UNABBREV_RECORD);
   RecordCode = Stream.ReadRecord(AbbrevNo,Record);
   assert (Record.size() > 0);
index 0ca10b3ceca681ee3a84a0312be45369f9d69c7e..16f9b89cabe6ff0c09cbd2ec2684294c5c8af6b8 100644 (file)
@@ -646,7 +646,7 @@ bool BranchFolder::TailMergeBlocks(MachineFunction &MF) {
             } else if (FBB) {
               if (TBB!=IBB && FBB!=IBB)   // cbr then ubr
                 continue;
-            } else if (Cond.size() == 0) {
+            } else if (Cond.empty()) {
               if (TBB!=IBB)               // ubr
                 continue;
             } else {
index 2b3bdc2c983cbf143774a432b9745e04614db023..fb53377b98ba0959468d0a9fca07bb1f77f003c0 100644 (file)
@@ -237,7 +237,7 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
 
   // Look for root nodes, i.e. blocks without successors.
   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);
 
   std::vector<IfcvtToken*> Tokens;
@@ -428,7 +428,7 @@ bool IfConverter::ValidTriangle(BBInfo &TrueBBI, BBInfo &FalseBBI,
 
     unsigned Size = TrueBBI.NonPredSize;
     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.
         --Size;
       else {
@@ -646,7 +646,7 @@ IfConverter::BBInfo &IfConverter::AnalyzeBlock(MachineBasicBlock *BB,
   ScanInstructions(BBI);
 
   // 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.IsAnalyzed = true;
     return BBI;
index 5e6d4cb4961f451f0f2b07d4c4d60f627ba99b8c..8aa4c4456ac612c0515eaa8dad209e1665930977 100644 (file)
@@ -1784,7 +1784,7 @@ void MachineModuleInfo::TidyLandingPads() {
     }
 
     // Remove landing pads with no try-ranges.
-    if (!LandingPads[i].BeginLabels.size()) {
+    if (LandingPads[i].BeginLabels.empty()) {
       LandingPads.erase(LandingPads.begin() + i);
       continue;
     }
index 4e835b82a6730237b952578f9932aaa68fac745b..5a1bf93fd8c3f8cecf0ab7355b1128c75f0a80db 100644 (file)
@@ -801,7 +801,7 @@ SDOperand DAGCombiner::visitTokenFactor(SDNode *N) {
 
   // If we've change things around then replace token factor.
   if (Changed) {
-    if (Ops.size() == 0) {
+    if (Ops.empty()) {
       // The entry token is the only possible outcome.
       Result = DAG.getEntryNode();
     } else {
index 250298e2d6095e5430747d11a7d5f67cd1fb2b52..293d023381184b118528f7fb3e780696f58638a0 100644 (file)
@@ -230,7 +230,7 @@ void ScheduleDAG::ComputeLatency(SUnit *SU) {
 void ScheduleDAG::CalculateDepths() {
   std::vector<std::pair<SUnit*, unsigned> > WorkList;
   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));
 
   while (!WorkList.empty()) {
index 5c7422c97a20b979019bad547be247301fa98ec3..42d54f6622b5693fe755a3ec262a0eef88d1ffc7 100644 (file)
@@ -169,7 +169,7 @@ void ScheduleDAGList::ListScheduleTopDown() {
   // All leaves to Available queue.
   for (unsigned i = 0, e = SUnits.size(); i != e; ++i) {
     // 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]);
       SUnits[i].isAvailable = SUnits[i].isPending = true;
     }
@@ -477,7 +477,7 @@ void LatencyPriorityQueue::CalculatePriorities() {
   std::vector<std::pair<const SUnit*, unsigned> > WorkList;
   for (unsigned i = 0, e = SUnits->size(); i != e; ++i) {
     const SUnit *SU = &(*SUnits)[i];
-    if (SU->Succs.size() == 0)
+    if (SU->Succs.empty())
       WorkList.push_back(std::make_pair(SU, 0U));
   }
 
index 48bc3cd115b56692033b99ea35ba844d1c7f8781..86818440058cc6502741fadd0d985ad05d0924a2 100644 (file)
@@ -898,7 +898,7 @@ void ScheduleDAGRRList::ListScheduleTopDown() {
   // All leaves to Available queue.
   for (unsigned i = 0, e = SUnits.size(); i != e; ++i) {
     // 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]);
       SUnits[i].isAvailable = true;
     }
index ad6cd1ba3db7414c9136eee5d663862432f620f9..a61bd81b1ab3af92fe39841028341e9232310d4b 100644 (file)
@@ -3497,7 +3497,7 @@ bool SDNode::hasNUsesOfValue(unsigned NUses, unsigned Value) const {
 bool SDNode::hasAnyUseOfValue(unsigned Value) const {
   assert(Value < getNumValues() && "Bad value!");
 
-  if (use_size() == 0) return false;
+  if (use_empty()) return false;
 
   SDOperand TheValue(const_cast<SDNode *>(this), Value);
 
index bebbf8364ee5894fb3845e2010ff9a1aa75c28f8..b5f623d49be7a6258723c5182945b831bd29c2c4 100644 (file)
@@ -257,7 +257,7 @@ GenericValue lle_X_floor(FunctionType *FT, const vector<GenericValue> &Args) {
 
 // double drand48()
 GenericValue lle_X_drand48(FunctionType *FT, const vector<GenericValue> &Args) {
-  assert(Args.size() == 0);
+  assert(Args.empty());
   GenericValue GV;
   GV.DoubleVal = drand48();
   return GV;
@@ -265,7 +265,7 @@ GenericValue lle_X_drand48(FunctionType *FT, const vector<GenericValue> &Args) {
 
 // long lrand48()
 GenericValue lle_X_lrand48(FunctionType *FT, const vector<GenericValue> &Args) {
-  assert(Args.size() == 0);
+  assert(Args.empty());
   GenericValue GV;
   GV.IntVal = APInt(32, lrand48());
   return GV;
@@ -282,7 +282,7 @@ GenericValue lle_X_srand48(FunctionType *FT, const vector<GenericValue> &Args) {
 
 // int rand()
 GenericValue lle_X_rand(FunctionType *FT, const vector<GenericValue> &Args) {
-  assert(Args.size() == 0);
+  assert(Args.empty());
   GenericValue GV;
   GV.IntVal = APInt(32, rand());
   return GV;
index 8c6f3a8894476f60785b9cf707291839e30cc2db..ff5cc0a840f4951a12d64c475db74c5f84d353a7 100644 (file)
@@ -418,7 +418,7 @@ Path::getDirectoryContents(std::set<Path>& result, std::string* ErrMsg) const {
 
 bool
 Path::set(const std::string& a_path) {
-  if (a_path.size() == 0)
+  if (a_path.empty())
     return false;
   std::string save(path);
   path = a_path;
index 1f2a1b0fba58bb45a48fe70d0aa51649cee9338c..f5252a02f1bb958fbfda193304e91bdf3072342b 100644 (file)
@@ -740,7 +740,7 @@ public:
     
     // 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
-    if (SrcStr.size() == 0) {
+    if (SrcStr.empty()) {
       new StoreInst(ConstantInt::get(Type::Int8Ty, 0), Dst, CI);
       return ReplaceCallWith(CI, Dst);
     }
index 1521c5f60dee6896c74f4e0b4cbbc435ccd00246..33bfbf0a7ac58b1d7e7c37afe82f89a84fce6ac0 100644 (file)
@@ -476,7 +476,7 @@ void LICM::sink(Instruction &I) {
       while (isa<PHINode>(InsertPt)) ++InsertPt;
       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.
     CurAST->deleteValue(&I);
     if (!I.use_empty())  // If I has users in unreachable blocks, eliminate.
index 7ce4711cbee8798c244eb87217ebd90fafbd236d..5d80b75a274ae1d02a8974a57150dbaa73272b24 100644 (file)
@@ -1214,7 +1214,7 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(const SCEVHandle &Stride,
                                                       Loop *L,
                                                       bool isOnlyStride) {
   // 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;
 
   // Keep track if every use in UsersToProcess is an address. If they all are,
index 9bc10184a3b87272a2fc895a8e00528d231c4e0e..b0fd3d6f259f05ae313b81fa16745ab05180d9c3 100644 (file)
@@ -722,7 +722,7 @@ Value *Reassociate::OptimizeExpression(BinaryOperator *I,
       
       ++NumFactor;
       
-      if (Ops.size() == 0)
+      if (Ops.empty())
         return V2;
 
       // Add the new value to the list of things being added.