]> granicus.if.org Git - clang/commitdiff
Use pop_back_val() instead of both back() and pop_back().
authorRobert Wilhelm <robert.wilhelm@gmx.net>
Fri, 23 Aug 2013 16:11:15 +0000 (16:11 +0000)
committerRobert Wilhelm <robert.wilhelm@gmx.net>
Fri, 23 Aug 2013 16:11:15 +0000 (16:11 +0000)
No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189112 91177308-0d34-0410-b5e6-96231b3b80d8

30 files changed:
include/clang/AST/ASTUnresolvedSet.h
include/clang/AST/CommentParser.h
include/clang/AST/UnresolvedSet.h
include/clang/Analysis/FlowSensitive/DataflowSolver.h
include/clang/Lex/PreprocessorLexer.h
lib/AST/CXXInheritance.cpp
lib/AST/CommentSema.cpp
lib/AST/NestedNameSpecifier.cpp
lib/Analysis/CFGReachabilityAnalysis.cpp
lib/Analysis/LiveVariables.cpp
lib/Analysis/UninitializedValues.cpp
lib/CodeGen/CodeGenModule.cpp
lib/Lex/TokenLexer.cpp
lib/Sema/Sema.cpp
lib/Sema/SemaAccess.cpp
lib/Sema/SemaChecking.cpp
lib/Sema/SemaCodeComplete.cpp
lib/Sema/SemaDeclCXX.cpp
lib/Sema/SemaLookup.cpp
lib/Sema/SemaTemplate.cpp
lib/Sema/SemaTemplateDeduction.cpp
lib/Serialization/ASTReader.cpp
lib/Serialization/ModuleManager.cpp
lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
lib/StaticAnalyzer/Core/BugReporter.cpp
lib/StaticAnalyzer/Core/ExplodedGraph.cpp
lib/StaticAnalyzer/Core/PathDiagnostic.cpp
lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
lib/StaticAnalyzer/Core/SymbolManager.cpp
tools/libclang/CIndex.cpp

index 5a56b4d2b46d43f830553bf7f0e0750251eebd08..f9f4306bfa12649b40c9ff9a535cef73d5553f04 100644 (file)
@@ -58,10 +58,7 @@ public:
     return false;
   }
 
-  void erase(unsigned I) {
-    Decls[I] = Decls.back();
-    Decls.pop_back();
-  }
+  void erase(unsigned I) { Decls[I] = Decls.pop_back_val(); }
 
   void clear() { Decls.clear(); }
 
index d6a1072786ed7a7e7010d56b197d48567ed77b44..7e008131d205a92ed34b51652d7650e83bdbe142 100644 (file)
@@ -61,10 +61,8 @@ class Parser {
   void consumeToken() {
     if (MoreLATokens.empty())
       L.lex(Tok);
-    else {
-      Tok = MoreLATokens.back();
-      MoreLATokens.pop_back();
-    }
+    else
+      Tok = MoreLATokens.pop_back_val();
   }
 
   void putBack(const Token &OldTok) {
index d0456c0b45144121b68711173071250dde1fe17d..c33474906a6783f6d83cf2ab3e64c3323e1d086d 100644 (file)
@@ -139,15 +139,9 @@ public:
     I.ir->set(New, AS);
   }
 
-  void erase(unsigned I) {
-    decls()[I] = decls().back();
-    decls().pop_back();
-  }
+  void erase(unsigned I) { decls()[I] = decls().pop_back_val(); }
 
-  void erase(iterator I) {
-    *I.ir = decls().back();
-    decls().pop_back();
-  }
+  void erase(iterator I) { *I.ir = decls().pop_back_val(); }
 
   void setAccess(iterator I, AccessSpecifier AS) {
     I.ir->setAccess(AS);
index 0f5e7bf246e894ab7c1ab822b3a91e05d666097d..c611ea2397ec5bdb395c534c507dd8219664ee10 100644 (file)
@@ -45,8 +45,7 @@ public:
   /// dequeue - Remove a block from the worklist.
   const CFGBlock *dequeue() {
     assert(!BlockQueue.empty());
-    const CFGBlock *B = BlockQueue.back();
-    BlockQueue.pop_back();
+    const CFGBlock *B = BlockQueue.pop_back_val();
     BlockSet[B] = 0;
     return B;
   }
index 20fb8a0c48041199fee26c6f28bf9621f7a3c46a..27a8df43a2741448ba35f9787de2a055a6e456cc 100644 (file)
@@ -111,9 +111,9 @@ protected:
   /// stack, returning information about it.  If the conditional stack is empty,
   /// this returns true and does not fill in the arguments.
   bool popConditionalLevel(PPConditionalInfo &CI) {
-    if (ConditionalStack.empty()) return true;
-    CI = ConditionalStack.back();
-    ConditionalStack.pop_back();
+    if (ConditionalStack.empty())
+      return true;
+    CI = ConditionalStack.pop_back_val();
     return false;
   }
 
index 6195a7dc68ed008b638338d15d4db9272e07b17b..b51014b7428f48e67d62d6fce0b75bddc8de2d2d 100644 (file)
@@ -168,9 +168,9 @@ bool CXXRecordDecl::forallBases(ForallBasesCallback *BaseMatches,
       }
     }
 
-    if (Queue.empty()) break;
-    Record = Queue.back(); // not actually a queue.
-    Queue.pop_back();
+    if (Queue.empty())
+      break;
+    Record = Queue.pop_back_val(); // not actually a queue.
   }
 
   return AllMatches;
index c0dc647ca4536e0a5857b1503c3bf460b6fb9d5f..db30fb6aa39f4a81ad0c5c449c8ef78439bcdd61 100644 (file)
@@ -515,8 +515,7 @@ HTMLEndTagComment *Sema::actOnHTMLEndTag(SourceLocation LocBegin,
   }
 
   while (!HTMLOpenTags.empty()) {
-    const HTMLStartTagComment *HST = HTMLOpenTags.back();
-    HTMLOpenTags.pop_back();
+    const HTMLStartTagComment *HST = HTMLOpenTags.pop_back_val();
     StringRef LastNotClosedTagName = HST->getTagName();
     if (LastNotClosedTagName == TagName)
       break;
index 79cc21a062c89f6506c42082614c0619ebb89831..b03c4e09fa46fa72a2585f1b80387e01405da4d1 100644 (file)
@@ -566,8 +566,7 @@ void NestedNameSpecifierLocBuilder::MakeTrivial(ASTContext &Context,
   for (NestedNameSpecifier *NNS = Qualifier; NNS; NNS = NNS->getPrefix())
     Stack.push_back(NNS);
   while (!Stack.empty()) {
-    NestedNameSpecifier *NNS = Stack.back();
-    Stack.pop_back();
+    NestedNameSpecifier *NNS = Stack.pop_back_val();
     switch (NNS->getKind()) {
       case NestedNameSpecifier::Identifier:
       case NestedNameSpecifier::Namespace:
index e77e72fa9fb10e38a610bd041509f289e5e48879..492e66fe8172ce2579f49447307e6841643d5a9d 100644 (file)
@@ -50,11 +50,10 @@ void CFGReverseBlockReachabilityAnalysis::mapReachability(const CFGBlock *Dst) {
   // multiple queries relating to a destination node.
   worklist.push_back(Dst);
   bool firstRun = true;
-  
-  while (!worklist.empty()) {    
-    const CFGBlock *block = worklist.back();
-    worklist.pop_back();
-    
+
+  while (!worklist.empty()) {
+    const CFGBlock *block = worklist.pop_back_val();
+
     if (visited[block->getBlockID()])
       continue;
     visited[block->getBlockID()] = true;
index 1583fcb3de0d2db5ad0266805993db0db5106b81..38db72a150b3183d5ea39c62f010e146aa47ff5e 100644 (file)
@@ -87,8 +87,7 @@ void DataflowWorklist::sortWorklist() {
 const CFGBlock *DataflowWorklist::dequeue() {
   if (worklist.empty())
     return 0;
-  const CFGBlock *b = worklist.back();
-  worklist.pop_back();
+  const CFGBlock *b = worklist.pop_back_val();
   enqueuedBlocks[b->getBlockID()] = false;
   return b;
 }
index 3d155c8174adce4e8932631e702a7c04db1cc5ab..6c6804fe9eb81f8dda1597531942aa51ffa746e7 100644 (file)
@@ -240,10 +240,9 @@ const CFGBlock *DataflowWorklist::dequeue() {
 
   // First dequeue from the worklist.  This can represent
   // updates along backedges that we want propagated as quickly as possible.
-  if (!worklist.empty()) {
-    B = worklist.back();
-    worklist.pop_back();
-  }
+  if (!worklist.empty())
+    B = worklist.pop_back_val();
+
   // Next dequeue from the initial reverse post order.  This is the
   // theoretical ideal in the presence of no back edges.
   else if (PO_I != PO_E) {
@@ -527,8 +526,7 @@ public:
     // of marking it as not being a candidate element of the frontier.
     SuccsVisited[block->getBlockID()] = block->succ_size();
     while (!Queue.empty()) {
-      const CFGBlock *B = Queue.back();
-      Queue.pop_back();
+      const CFGBlock *B = Queue.pop_back_val();
       for (CFGBlock::const_pred_iterator I = B->pred_begin(), E = B->pred_end();
            I != E; ++I) {
         const CFGBlock *Pred = *I;
index 2ef3f39ea5104a23efa60b7dd546dfa016a3d704..1eb5a0964f50006a7f9e64c13c2f0892b8a795a5 100644 (file)
@@ -863,8 +863,7 @@ void CodeGenModule::EmitModuleLinkOptions() {
   // Find all of the modules to import, making a little effort to prune
   // non-leaf modules.
   while (!Stack.empty()) {
-    clang::Module *Mod = Stack.back();
-    Stack.pop_back();
+    clang::Module *Mod = Stack.pop_back_val();
 
     bool AnyChildren = false;
 
index ded2b561a2873546962542f8c5f66675168cab34..b83e76639d014a38f1f514fdca0cda133217415b 100644 (file)
@@ -329,8 +329,7 @@ void TokenLexer::ExpandFunctionArguments() {
           (unsigned)ArgNo == Macro->getNumArgs()-1 &&
           Macro->isVariadic()) {
         // Remove the paste operator, report use of the extension.
-        PP.Diag(ResultToks.back().getLocation(), diag::ext_paste_comma);
-        ResultToks.pop_back();
+        PP.Diag(ResultToks.pop_back_val().getLocation(), diag::ext_paste_comma);
       }
 
       ResultToks.append(ArgToks, ArgToks+NumToks);
@@ -386,8 +385,7 @@ void TokenLexer::ExpandFunctionArguments() {
     assert(PasteBefore);
     if (NonEmptyPasteBefore) {
       assert(ResultToks.back().is(tok::hashhash));
-      NextTokGetsSpace |= ResultToks.back().hasLeadingSpace();
-      ResultToks.pop_back();
+      NextTokGetsSpace |= ResultToks.pop_back_val().hasLeadingSpace();
     }
 
     // If this is the __VA_ARGS__ token, and if the argument wasn't provided,
index 6cc596cec1b8d6fbedba65830f2aecb0557fa6b7..a3b1bfa1c22cf48b94fe009763db25e9e9711c48 100644 (file)
@@ -630,8 +630,7 @@ void Sema::ActOnEndOfTranslationUnit() {
       SmallVector<Module *, 2> Stack;
       Stack.push_back(CurrentModule);
       while (!Stack.empty()) {
-        Module *Mod = Stack.back();
-        Stack.pop_back();
+        Module *Mod = Stack.pop_back_val();
 
         // Resolve the exported declarations and conflicts.
         // FIXME: Actually complain, once we figure out how to teach the
index 020787b39a7a31f5fd7e3679fed3069563f00eb5..bd8d3e95a8079089fe82c4d1b26443578c7d850c 100644 (file)
@@ -315,8 +315,7 @@ static AccessResult IsDerivedFromInclusive(const CXXRecordDecl *Derived,
 
     if (Queue.empty()) break;
 
-    Derived = Queue.back();
-    Queue.pop_back();
+    Derived = Queue.pop_back_val();
   }
 
   return OnFailure;
index 5e0acc078755c9853e050ec8a803fb4f5948aef3..79782921808c8952d19b329763c35ca06451d9c8 100644 (file)
@@ -6031,8 +6031,7 @@ void Sema::CheckUnsequencedOperations(Expr *E) {
   SmallVector<Expr *, 8> WorkList;
   WorkList.push_back(E);
   while (!WorkList.empty()) {
-    Expr *Item = WorkList.back();
-    WorkList.pop_back();
+    Expr *Item = WorkList.pop_back_val();
     SequenceChecker(*this, Item, WorkList);
   }
 }
index b415993170fe0e56e1af7abd2288656cdedefd04..aa60a284238fe384e8e8561828262c7fe17f764a 100644 (file)
@@ -464,9 +464,8 @@ getRequiredQualification(ASTContext &Context,
   
   NestedNameSpecifier *Result = 0;
   while (!TargetParents.empty()) {
-    const DeclContext *Parent = TargetParents.back();
-    TargetParents.pop_back();
-    
+    const DeclContext *Parent = TargetParents.pop_back_val();
+
     if (const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Parent)) {
       if (!Namespace->getIdentifier())
         continue;
index 6ebfb57974e7f39c20c8dd849cd58b744b062734..53b866852ae624a08049dfc2ae40f3baad924a13 100644 (file)
@@ -1249,8 +1249,7 @@ static bool findCircularInheritance(const CXXRecordDecl *Class,
     if (Queue.empty())
       return false;
 
-    Current = Queue.back();
-    Queue.pop_back();
+    Current = Queue.pop_back_val();
   }
 
   return false;
index 727f49b5fa4ba1152a8e6f1f5ac3f8bb1e1ea9ff..a17a903a5f4e28910446bbd93507c35472c1845a 100644 (file)
@@ -167,8 +167,7 @@ namespace {
         if (queue.empty())
           return;
 
-        DC = queue.back();
-        queue.pop_back();
+        DC = queue.pop_back_val();
       }
     }
 
@@ -1446,8 +1445,7 @@ static bool LookupQualifiedNameInUsingDirectives(Sema &S, LookupResult &R,
 
   bool Found = false;
   while (!Queue.empty()) {
-    NamespaceDecl *ND = Queue.back();
-    Queue.pop_back();
+    NamespaceDecl *ND = Queue.pop_back_val();
 
     // We go through some convolutions here to avoid copying results
     // between LookupResults.
@@ -2039,8 +2037,7 @@ addAssociatedClassesAndNamespaces(AssociatedLookup &Result,
   Bases.push_back(Class);
   while (!Bases.empty()) {
     // Pop this class off the stack.
-    Class = Bases.back();
-    Bases.pop_back();
+    Class = Bases.pop_back_val();
 
     // Visit the base classes.
     for (CXXRecordDecl::base_class_iterator Base = Class->bases_begin(),
@@ -2224,9 +2221,9 @@ addAssociatedClassesAndNamespaces(AssociatedLookup &Result, QualType Ty) {
       continue;
     }
 
-    if (Queue.empty()) break;
-    T = Queue.back();
-    Queue.pop_back();
+    if (Queue.empty())
+      break;
+    T = Queue.pop_back_val();
   }
 }
 
index a6a1ea4698e475d546a266c60c23789129cad8aa..096d938ea072b2db19959a4a46b7747f80178e18 100644 (file)
@@ -3527,8 +3527,7 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template,
         // deduced argument and place it on the argument pack. Note that we
         // stay on the same template parameter so that we can deduce more
         // arguments.
-        ArgumentPack.push_back(Converted.back());
-        Converted.pop_back();
+        ArgumentPack.push_back(Converted.pop_back_val());
       } else {
         // Move to the next template parameter.
         ++Param;
index c8669ae7b821465a8c59a98b70888d0e18db5ef6..a5878bcb36405f92e59f528b83f4b0a410cee437 100644 (file)
@@ -1431,8 +1431,7 @@ DeduceTemplateArgumentsByTypeMatch(Sema &S,
                                                               Deduced.end());
           while (!ToVisit.empty()) {
             // Retrieve the next class in the inheritance hierarchy.
-            const RecordType *NextT = ToVisit.back();
-            ToVisit.pop_back();
+            const RecordType *NextT = ToVisit.pop_back_val();
 
             // If we have already seen this type, skip it.
             if (!Visited.insert(NextT))
@@ -2091,8 +2090,7 @@ ConvertDeducedTemplateArgument(Sema &S, NamedDecl *Param,
         return true;
 
       // Move the converted template argument into our argument pack.
-      PackedArgsBuilder.push_back(Output.back());
-      Output.pop_back();
+      PackedArgsBuilder.push_back(Output.pop_back_val());
     }
 
     // Create the resulting argument pack.
index 462c2d3db97a67092328e9efee55e39dfe6d8e20..6a2db82c4369fbbc843b20b772103914818399ef 100644 (file)
@@ -2819,13 +2819,12 @@ void ASTReader::makeModuleVisible(Module *Mod,
                                   bool Complain) {
   llvm::SmallPtrSet<Module *, 4> Visited;
   SmallVector<Module *, 4> Stack;
-  Stack.push_back(Mod);  
+  Stack.push_back(Mod);
   while (!Stack.empty()) {
-    Mod = Stack.back();
-    Stack.pop_back();
+    Mod = Stack.pop_back_val();
 
     if (NameVisibility <= Mod->NameVisibility) {
-      // This module already has this level of visibility (or greater), so 
+      // This module already has this level of visibility (or greater), so
       // there is nothing more to do.
       continue;
     }
index 1fc82dd87698d63e8a78a2e68347afc3d9313f82..b90ecc0f1e18d4801f6c1c58f8b0a5e9b1d3c5c0 100644 (file)
@@ -332,8 +332,7 @@ ModuleManager::visit(bool (*Visitor)(ModuleFile &M, void *UserData),
         break;
 
       // Pop the next module off the stack.
-      NextModule = State->Stack.back();
-      State->Stack.pop_back();
+      NextModule = State->Stack.pop_back_val();
     } while (true);
   }
 
index 7c44c217061f275cf2202b52c3eea704cfbee576..9d855ce649acc0a2e6d60c19d3e276614076c095 100644 (file)
@@ -85,10 +85,9 @@ void ReachableCode::computeReachableBlocks() {
   
   SmallVector<const CFGBlock*, 10> worklist;
   worklist.push_back(&cfg.getEntry());
-  
+
   while (!worklist.empty()) {
-    const CFGBlock *block = worklist.back();
-    worklist.pop_back();
+    const CFGBlock *block = worklist.pop_back_val();
     llvm::BitVector::reference isReachable = reachable[block->getBlockID()];
     if (isReachable)
       continue;
index 1df3053edfc24b6be4397a3cf3eca5f57b7c4ffc..98f68cfca1ffb0f9f819c215557c7e87f472d811 100644 (file)
@@ -2651,10 +2651,8 @@ void BugReport::pushInterestingSymbolsAndRegions() {
 }
 
 void BugReport::popInterestingSymbolsAndRegions() {
-  delete interestingSymbols.back();
-  interestingSymbols.pop_back();
-  delete interestingRegions.back();
-  interestingRegions.pop_back();
+  delete interestingSymbols.pop_back_val();
+  delete interestingRegions.pop_back_val();
 }
 
 const Stmt *BugReport::getStmt() const {
index af9518acc79d0e060316bcb20a712a2bc83b65e7..e9c4a35de6e8dc4df3c5c929c69565d1618ee73a 100644 (file)
@@ -357,8 +357,7 @@ ExplodedGraph::trim(ArrayRef<const NodeTy *> Sinks,
 
   // Process the first worklist until it is empty.
   while (!WL1.empty()) {
-    const ExplodedNode *N = WL1.back();
-    WL1.pop_back();
+    const ExplodedNode *N = WL1.pop_back_val();
 
     // Have we already visited this node?  If so, continue to the next one.
     if (Pass1.count(N))
@@ -388,8 +387,7 @@ ExplodedGraph::trim(ArrayRef<const NodeTy *> Sinks,
 
   // ===- Pass 2 (forward DFS to construct the new graph) -===
   while (!WL2.empty()) {
-    const ExplodedNode *N = WL2.back();
-    WL2.pop_back();
+    const ExplodedNode *N = WL2.pop_back_val();
 
     // Skip this node if we have already processed it.
     if (Pass2.find(N) != Pass2.end())
index 5f26085cabeb6a69f651a6307bce5f3cc4370306..33c7a82d8ea5eb220caefcd2e9175eb30e244fa0 100644 (file)
@@ -216,11 +216,10 @@ void PathDiagnosticConsumer::HandlePathDiagnostic(PathDiagnostic *D) {
     WorkList.push_back(&D->path);
 
     while (!WorkList.empty()) {
-      const PathPieces &path = *WorkList.back();
-      WorkList.pop_back();
+      const PathPieces &path = *WorkList.pop_back_val();
 
-      for (PathPieces::const_iterator I = path.begin(), E = path.end();
-           I != E; ++I) {
+      for (PathPieces::const_iterator I = path.begin(), E = path.end(); I != E;
+           ++I) {
         const PathDiagnosticPiece *piece = I->getPtr();
         FullSourceLoc L = piece->getLocation().asLocation().getExpansionLoc();
       
index 7f7881b5f45252f53ed44c964a4ac54be1ec5f95..5dca811722ac900c5d979ea99249bfddb880e9fd 100644 (file)
@@ -382,11 +382,10 @@ void PlistDiagnostics::FlushDiagnosticsImpl(
     WorkList.push_back(&D->path);
 
     while (!WorkList.empty()) {
-      const PathPieces &path = *WorkList.back();
-      WorkList.pop_back();
-    
-      for (PathPieces::const_iterator I = path.begin(), E = path.end();
-           I!=E; ++I) {
+      const PathPieces &path = *WorkList.pop_back_val();
+
+      for (PathPieces::const_iterator I = path.begin(), E = path.end(); I != E;
+           ++I) {
         const PathDiagnosticPiece *piece = I->getPtr();
         AddFID(FM, Fids, SM, piece->getLocation().asLocation());
         ArrayRef<SourceRange> Ranges = piece->getRanges();
index 7c75b6c3d2fd957fa900744186b7cbd544cebbd7..2fe599b67e8c98aef2927456c94e38df4211988a 100644 (file)
@@ -112,8 +112,7 @@ SymbolRef SymExpr::symbol_iterator::operator*() {
 }
 
 void SymExpr::symbol_iterator::expand() {
-  const SymExpr *SE = itr.back();
-  itr.pop_back();
+  const SymExpr *SE = itr.pop_back_val();
 
   switch (SE->getKind()) {
     case SymExpr::RegionValueKind:
index c89a121827e584928e21a2c1c79526e20ff94d14..765c900012185054391afe5aa3cb1dac51f8eb1f 100644 (file)
@@ -2256,8 +2256,7 @@ bool CursorVisitor::IsInRegionOfInterest(CXCursor C) {
 bool CursorVisitor::RunVisitorWorkList(VisitorWorkList &WL) {
   while (!WL.empty()) {
     // Dequeue the worklist item.
-    VisitorJob LI = WL.back();
-    WL.pop_back();
+    VisitorJob LI = WL.pop_back_val();
 
     // Set the Parent field, then back to its old value once we're done.
     SetParentRAII SetParent(Parent, StmtParent, LI.getParent());