Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 344472e

Browse files
committed
Use pop_back_val() instead of both back() and pop_back().
No functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189112 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 7865b8e commit 344472e

30 files changed

+60
-103
lines changed

Diff for: include/clang/AST/ASTUnresolvedSet.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ class ASTUnresolvedSet {
5858
return false;
5959
}
6060

61-
void erase(unsigned I) {
62-
Decls[I] = Decls.back();
63-
Decls.pop_back();
64-
}
61+
void erase(unsigned I) { Decls[I] = Decls.pop_back_val(); }
6562

6663
void clear() { Decls.clear(); }
6764

Diff for: include/clang/AST/CommentParser.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,8 @@ class Parser {
6161
void consumeToken() {
6262
if (MoreLATokens.empty())
6363
L.lex(Tok);
64-
else {
65-
Tok = MoreLATokens.back();
66-
MoreLATokens.pop_back();
67-
}
64+
else
65+
Tok = MoreLATokens.pop_back_val();
6866
}
6967

7068
void putBack(const Token &OldTok) {

Diff for: include/clang/AST/UnresolvedSet.h

+2-8
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,9 @@ class UnresolvedSetImpl {
139139
I.ir->set(New, AS);
140140
}
141141

142-
void erase(unsigned I) {
143-
decls()[I] = decls().back();
144-
decls().pop_back();
145-
}
142+
void erase(unsigned I) { decls()[I] = decls().pop_back_val(); }
146143

147-
void erase(iterator I) {
148-
*I.ir = decls().back();
149-
decls().pop_back();
150-
}
144+
void erase(iterator I) { *I.ir = decls().pop_back_val(); }
151145

152146
void setAccess(iterator I, AccessSpecifier AS) {
153147
I.ir->setAccess(AS);

Diff for: include/clang/Analysis/FlowSensitive/DataflowSolver.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ class DataflowWorkListTy {
4545
/// dequeue - Remove a block from the worklist.
4646
const CFGBlock *dequeue() {
4747
assert(!BlockQueue.empty());
48-
const CFGBlock *B = BlockQueue.back();
49-
BlockQueue.pop_back();
48+
const CFGBlock *B = BlockQueue.pop_back_val();
5049
BlockSet[B] = 0;
5150
return B;
5251
}

Diff for: include/clang/Lex/PreprocessorLexer.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ class PreprocessorLexer {
111111
/// stack, returning information about it. If the conditional stack is empty,
112112
/// this returns true and does not fill in the arguments.
113113
bool popConditionalLevel(PPConditionalInfo &CI) {
114-
if (ConditionalStack.empty()) return true;
115-
CI = ConditionalStack.back();
116-
ConditionalStack.pop_back();
114+
if (ConditionalStack.empty())
115+
return true;
116+
CI = ConditionalStack.pop_back_val();
117117
return false;
118118
}
119119

Diff for: lib/AST/CXXInheritance.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ bool CXXRecordDecl::forallBases(ForallBasesCallback *BaseMatches,
168168
}
169169
}
170170

171-
if (Queue.empty()) break;
172-
Record = Queue.back(); // not actually a queue.
173-
Queue.pop_back();
171+
if (Queue.empty())
172+
break;
173+
Record = Queue.pop_back_val(); // not actually a queue.
174174
}
175175

176176
return AllMatches;

Diff for: lib/AST/CommentSema.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,7 @@ HTMLEndTagComment *Sema::actOnHTMLEndTag(SourceLocation LocBegin,
515515
}
516516

517517
while (!HTMLOpenTags.empty()) {
518-
const HTMLStartTagComment *HST = HTMLOpenTags.back();
519-
HTMLOpenTags.pop_back();
518+
const HTMLStartTagComment *HST = HTMLOpenTags.pop_back_val();
520519
StringRef LastNotClosedTagName = HST->getTagName();
521520
if (LastNotClosedTagName == TagName)
522521
break;

Diff for: lib/AST/NestedNameSpecifier.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,7 @@ void NestedNameSpecifierLocBuilder::MakeTrivial(ASTContext &Context,
566566
for (NestedNameSpecifier *NNS = Qualifier; NNS; NNS = NNS->getPrefix())
567567
Stack.push_back(NNS);
568568
while (!Stack.empty()) {
569-
NestedNameSpecifier *NNS = Stack.back();
570-
Stack.pop_back();
569+
NestedNameSpecifier *NNS = Stack.pop_back_val();
571570
switch (NNS->getKind()) {
572571
case NestedNameSpecifier::Identifier:
573572
case NestedNameSpecifier::Namespace:

Diff for: lib/Analysis/CFGReachabilityAnalysis.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,10 @@ void CFGReverseBlockReachabilityAnalysis::mapReachability(const CFGBlock *Dst) {
5050
// multiple queries relating to a destination node.
5151
worklist.push_back(Dst);
5252
bool firstRun = true;
53-
54-
while (!worklist.empty()) {
55-
const CFGBlock *block = worklist.back();
56-
worklist.pop_back();
57-
53+
54+
while (!worklist.empty()) {
55+
const CFGBlock *block = worklist.pop_back_val();
56+
5857
if (visited[block->getBlockID()])
5958
continue;
6059
visited[block->getBlockID()] = true;

Diff for: lib/Analysis/LiveVariables.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ void DataflowWorklist::sortWorklist() {
8787
const CFGBlock *DataflowWorklist::dequeue() {
8888
if (worklist.empty())
8989
return 0;
90-
const CFGBlock *b = worklist.back();
91-
worklist.pop_back();
90+
const CFGBlock *b = worklist.pop_back_val();
9291
enqueuedBlocks[b->getBlockID()] = false;
9392
return b;
9493
}

Diff for: lib/Analysis/UninitializedValues.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,9 @@ const CFGBlock *DataflowWorklist::dequeue() {
240240

241241
// First dequeue from the worklist. This can represent
242242
// updates along backedges that we want propagated as quickly as possible.
243-
if (!worklist.empty()) {
244-
B = worklist.back();
245-
worklist.pop_back();
246-
}
243+
if (!worklist.empty())
244+
B = worklist.pop_back_val();
245+
247246
// Next dequeue from the initial reverse post order. This is the
248247
// theoretical ideal in the presence of no back edges.
249248
else if (PO_I != PO_E) {
@@ -527,8 +526,7 @@ class TransferFunctions : public StmtVisitor<TransferFunctions> {
527526
// of marking it as not being a candidate element of the frontier.
528527
SuccsVisited[block->getBlockID()] = block->succ_size();
529528
while (!Queue.empty()) {
530-
const CFGBlock *B = Queue.back();
531-
Queue.pop_back();
529+
const CFGBlock *B = Queue.pop_back_val();
532530
for (CFGBlock::const_pred_iterator I = B->pred_begin(), E = B->pred_end();
533531
I != E; ++I) {
534532
const CFGBlock *Pred = *I;

Diff for: lib/CodeGen/CodeGenModule.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -863,8 +863,7 @@ void CodeGenModule::EmitModuleLinkOptions() {
863863
// Find all of the modules to import, making a little effort to prune
864864
// non-leaf modules.
865865
while (!Stack.empty()) {
866-
clang::Module *Mod = Stack.back();
867-
Stack.pop_back();
866+
clang::Module *Mod = Stack.pop_back_val();
868867

869868
bool AnyChildren = false;
870869

Diff for: lib/Lex/TokenLexer.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,7 @@ void TokenLexer::ExpandFunctionArguments() {
329329
(unsigned)ArgNo == Macro->getNumArgs()-1 &&
330330
Macro->isVariadic()) {
331331
// Remove the paste operator, report use of the extension.
332-
PP.Diag(ResultToks.back().getLocation(), diag::ext_paste_comma);
333-
ResultToks.pop_back();
332+
PP.Diag(ResultToks.pop_back_val().getLocation(), diag::ext_paste_comma);
334333
}
335334

336335
ResultToks.append(ArgToks, ArgToks+NumToks);
@@ -386,8 +385,7 @@ void TokenLexer::ExpandFunctionArguments() {
386385
assert(PasteBefore);
387386
if (NonEmptyPasteBefore) {
388387
assert(ResultToks.back().is(tok::hashhash));
389-
NextTokGetsSpace |= ResultToks.back().hasLeadingSpace();
390-
ResultToks.pop_back();
388+
NextTokGetsSpace |= ResultToks.pop_back_val().hasLeadingSpace();
391389
}
392390

393391
// If this is the __VA_ARGS__ token, and if the argument wasn't provided,

Diff for: lib/Sema/Sema.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -630,8 +630,7 @@ void Sema::ActOnEndOfTranslationUnit() {
630630
SmallVector<Module *, 2> Stack;
631631
Stack.push_back(CurrentModule);
632632
while (!Stack.empty()) {
633-
Module *Mod = Stack.back();
634-
Stack.pop_back();
633+
Module *Mod = Stack.pop_back_val();
635634

636635
// Resolve the exported declarations and conflicts.
637636
// FIXME: Actually complain, once we figure out how to teach the

Diff for: lib/Sema/SemaAccess.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,7 @@ static AccessResult IsDerivedFromInclusive(const CXXRecordDecl *Derived,
315315

316316
if (Queue.empty()) break;
317317

318-
Derived = Queue.back();
319-
Queue.pop_back();
318+
Derived = Queue.pop_back_val();
320319
}
321320

322321
return OnFailure;

Diff for: lib/Sema/SemaChecking.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -6031,8 +6031,7 @@ void Sema::CheckUnsequencedOperations(Expr *E) {
60316031
SmallVector<Expr *, 8> WorkList;
60326032
WorkList.push_back(E);
60336033
while (!WorkList.empty()) {
6034-
Expr *Item = WorkList.back();
6035-
WorkList.pop_back();
6034+
Expr *Item = WorkList.pop_back_val();
60366035
SequenceChecker(*this, Item, WorkList);
60376036
}
60386037
}

Diff for: lib/Sema/SemaCodeComplete.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,8 @@ getRequiredQualification(ASTContext &Context,
464464

465465
NestedNameSpecifier *Result = 0;
466466
while (!TargetParents.empty()) {
467-
const DeclContext *Parent = TargetParents.back();
468-
TargetParents.pop_back();
469-
467+
const DeclContext *Parent = TargetParents.pop_back_val();
468+
470469
if (const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Parent)) {
471470
if (!Namespace->getIdentifier())
472471
continue;

Diff for: lib/Sema/SemaDeclCXX.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -1249,8 +1249,7 @@ static bool findCircularInheritance(const CXXRecordDecl *Class,
12491249
if (Queue.empty())
12501250
return false;
12511251

1252-
Current = Queue.back();
1253-
Queue.pop_back();
1252+
Current = Queue.pop_back_val();
12541253
}
12551254

12561255
return false;

Diff for: lib/Sema/SemaLookup.cpp

+6-9
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ namespace {
167167
if (queue.empty())
168168
return;
169169

170-
DC = queue.back();
171-
queue.pop_back();
170+
DC = queue.pop_back_val();
172171
}
173172
}
174173

@@ -1446,8 +1445,7 @@ static bool LookupQualifiedNameInUsingDirectives(Sema &S, LookupResult &R,
14461445

14471446
bool Found = false;
14481447
while (!Queue.empty()) {
1449-
NamespaceDecl *ND = Queue.back();
1450-
Queue.pop_back();
1448+
NamespaceDecl *ND = Queue.pop_back_val();
14511449

14521450
// We go through some convolutions here to avoid copying results
14531451
// between LookupResults.
@@ -2039,8 +2037,7 @@ addAssociatedClassesAndNamespaces(AssociatedLookup &Result,
20392037
Bases.push_back(Class);
20402038
while (!Bases.empty()) {
20412039
// Pop this class off the stack.
2042-
Class = Bases.back();
2043-
Bases.pop_back();
2040+
Class = Bases.pop_back_val();
20442041

20452042
// Visit the base classes.
20462043
for (CXXRecordDecl::base_class_iterator Base = Class->bases_begin(),
@@ -2224,9 +2221,9 @@ addAssociatedClassesAndNamespaces(AssociatedLookup &Result, QualType Ty) {
22242221
continue;
22252222
}
22262223

2227-
if (Queue.empty()) break;
2228-
T = Queue.back();
2229-
Queue.pop_back();
2224+
if (Queue.empty())
2225+
break;
2226+
T = Queue.pop_back_val();
22302227
}
22312228
}
22322229

Diff for: lib/Sema/SemaTemplate.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -3527,8 +3527,7 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template,
35273527
// deduced argument and place it on the argument pack. Note that we
35283528
// stay on the same template parameter so that we can deduce more
35293529
// arguments.
3530-
ArgumentPack.push_back(Converted.back());
3531-
Converted.pop_back();
3530+
ArgumentPack.push_back(Converted.pop_back_val());
35323531
} else {
35333532
// Move to the next template parameter.
35343533
++Param;

Diff for: lib/Sema/SemaTemplateDeduction.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -1431,8 +1431,7 @@ DeduceTemplateArgumentsByTypeMatch(Sema &S,
14311431
Deduced.end());
14321432
while (!ToVisit.empty()) {
14331433
// Retrieve the next class in the inheritance hierarchy.
1434-
const RecordType *NextT = ToVisit.back();
1435-
ToVisit.pop_back();
1434+
const RecordType *NextT = ToVisit.pop_back_val();
14361435

14371436
// If we have already seen this type, skip it.
14381437
if (!Visited.insert(NextT))
@@ -2091,8 +2090,7 @@ ConvertDeducedTemplateArgument(Sema &S, NamedDecl *Param,
20912090
return true;
20922091

20932092
// Move the converted template argument into our argument pack.
2094-
PackedArgsBuilder.push_back(Output.back());
2095-
Output.pop_back();
2093+
PackedArgsBuilder.push_back(Output.pop_back_val());
20962094
}
20972095

20982096
// Create the resulting argument pack.

Diff for: lib/Serialization/ASTReader.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -2819,13 +2819,12 @@ void ASTReader::makeModuleVisible(Module *Mod,
28192819
bool Complain) {
28202820
llvm::SmallPtrSet<Module *, 4> Visited;
28212821
SmallVector<Module *, 4> Stack;
2822-
Stack.push_back(Mod);
2822+
Stack.push_back(Mod);
28232823
while (!Stack.empty()) {
2824-
Mod = Stack.back();
2825-
Stack.pop_back();
2824+
Mod = Stack.pop_back_val();
28262825

28272826
if (NameVisibility <= Mod->NameVisibility) {
2828-
// This module already has this level of visibility (or greater), so
2827+
// This module already has this level of visibility (or greater), so
28292828
// there is nothing more to do.
28302829
continue;
28312830
}

Diff for: lib/Serialization/ModuleManager.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,7 @@ ModuleManager::visit(bool (*Visitor)(ModuleFile &M, void *UserData),
332332
break;
333333

334334
// Pop the next module off the stack.
335-
NextModule = State->Stack.back();
336-
State->Stack.pop_back();
335+
NextModule = State->Stack.pop_back_val();
337336
} while (true);
338337
}
339338

Diff for: lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,9 @@ void ReachableCode::computeReachableBlocks() {
8585

8686
SmallVector<const CFGBlock*, 10> worklist;
8787
worklist.push_back(&cfg.getEntry());
88-
88+
8989
while (!worklist.empty()) {
90-
const CFGBlock *block = worklist.back();
91-
worklist.pop_back();
90+
const CFGBlock *block = worklist.pop_back_val();
9291
llvm::BitVector::reference isReachable = reachable[block->getBlockID()];
9392
if (isReachable)
9493
continue;

Diff for: lib/StaticAnalyzer/Core/BugReporter.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -2651,10 +2651,8 @@ void BugReport::pushInterestingSymbolsAndRegions() {
26512651
}
26522652

26532653
void BugReport::popInterestingSymbolsAndRegions() {
2654-
delete interestingSymbols.back();
2655-
interestingSymbols.pop_back();
2656-
delete interestingRegions.back();
2657-
interestingRegions.pop_back();
2654+
delete interestingSymbols.pop_back_val();
2655+
delete interestingRegions.pop_back_val();
26582656
}
26592657

26602658
const Stmt *BugReport::getStmt() const {

Diff for: lib/StaticAnalyzer/Core/ExplodedGraph.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,7 @@ ExplodedGraph::trim(ArrayRef<const NodeTy *> Sinks,
357357

358358
// Process the first worklist until it is empty.
359359
while (!WL1.empty()) {
360-
const ExplodedNode *N = WL1.back();
361-
WL1.pop_back();
360+
const ExplodedNode *N = WL1.pop_back_val();
362361

363362
// Have we already visited this node? If so, continue to the next one.
364363
if (Pass1.count(N))
@@ -388,8 +387,7 @@ ExplodedGraph::trim(ArrayRef<const NodeTy *> Sinks,
388387

389388
// ===- Pass 2 (forward DFS to construct the new graph) -===
390389
while (!WL2.empty()) {
391-
const ExplodedNode *N = WL2.back();
392-
WL2.pop_back();
390+
const ExplodedNode *N = WL2.pop_back_val();
393391

394392
// Skip this node if we have already processed it.
395393
if (Pass2.find(N) != Pass2.end())

Diff for: lib/StaticAnalyzer/Core/PathDiagnostic.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,10 @@ void PathDiagnosticConsumer::HandlePathDiagnostic(PathDiagnostic *D) {
216216
WorkList.push_back(&D->path);
217217

218218
while (!WorkList.empty()) {
219-
const PathPieces &path = *WorkList.back();
220-
WorkList.pop_back();
219+
const PathPieces &path = *WorkList.pop_back_val();
221220

222-
for (PathPieces::const_iterator I = path.begin(), E = path.end();
223-
I != E; ++I) {
221+
for (PathPieces::const_iterator I = path.begin(), E = path.end(); I != E;
222+
++I) {
224223
const PathDiagnosticPiece *piece = I->getPtr();
225224
FullSourceLoc L = piece->getLocation().asLocation().getExpansionLoc();
226225

0 commit comments

Comments
 (0)