From: Benjamin Kramer Date: Fri, 12 Jun 2015 15:31:50 +0000 (+0000) Subject: push_back() loop -> append() for random access iterators. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f367dd90cc2f51f43ad1f2d93b3e69613f43f3f1;p=platform%2Fupstream%2Fllvm.git push_back() loop -> append() for random access iterators. append will resize the vector to the optimal size. No functional change intended. llvm-svn: 239607 --- diff --git a/clang/include/clang/AST/CommentParser.h b/clang/include/clang/AST/CommentParser.h index 42bf4c9..fa88628 100644 --- a/clang/include/clang/AST/CommentParser.h +++ b/clang/include/clang/AST/CommentParser.h @@ -75,11 +75,7 @@ class Parser { return; MoreLATokens.push_back(Tok); - for (const Token *I = &Toks.back(), - *B = &Toks.front(); - I != B; --I) { - MoreLATokens.push_back(*I); - } + MoreLATokens.append(Toks.rbegin(), std::prev(Toks.rend())); Tok = Toks[0]; } diff --git a/clang/include/clang/AST/DataRecursiveASTVisitor.h b/clang/include/clang/AST/DataRecursiveASTVisitor.h index 5632e07..f6e2cad 100644 --- a/clang/include/clang/AST/DataRecursiveASTVisitor.h +++ b/clang/include/clang/AST/DataRecursiveASTVisitor.h @@ -531,10 +531,7 @@ bool RecursiveASTVisitor::TraverseStmt(Stmt *S) { } } - for (SmallVectorImpl::reverse_iterator RI = StmtsToEnqueue.rbegin(), - RE = StmtsToEnqueue.rend(); - RI != RE; ++RI) - Queue.push_back(*RI); + Queue.append(StmtsToEnqueue.rbegin(), StmtsToEnqueue.rend()); } return true; diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h index f6e61c0..2f4714b 100644 --- a/clang/include/clang/Lex/Preprocessor.h +++ b/clang/include/clang/Lex/Preprocessor.h @@ -455,8 +455,9 @@ class Preprocessor : public RefCountedBase { void overrideActiveModuleMacros(Preprocessor &PP, IdentifierInfo *II) { if (auto *Info = getModuleInfo(PP, II)) { - for (auto *Active : Info->ActiveModuleMacros) - Info->OverriddenMacros.push_back(Active); + Info->OverriddenMacros.insert(Info->OverriddenMacros.end(), + Info->ActiveModuleMacros.begin(), + Info->ActiveModuleMacros.end()); Info->ActiveModuleMacros.clear(); Info->IsAmbiguous = false; } diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp index 1992804..7f5a15d 100644 --- a/clang/lib/Basic/Diagnostic.cpp +++ b/clang/lib/Basic/Diagnostic.cpp @@ -321,18 +321,10 @@ void DiagnosticsEngine::Report(const StoredDiagnostic &storedDiag) { NumDiagArgs = 0; DiagRanges.clear(); - DiagRanges.reserve(storedDiag.range_size()); - for (StoredDiagnostic::range_iterator - RI = storedDiag.range_begin(), - RE = storedDiag.range_end(); RI != RE; ++RI) - DiagRanges.push_back(*RI); + DiagRanges.append(storedDiag.range_begin(), storedDiag.range_end()); DiagFixItHints.clear(); - DiagFixItHints.reserve(storedDiag.fixit_size()); - for (StoredDiagnostic::fixit_iterator - FI = storedDiag.fixit_begin(), - FE = storedDiag.fixit_end(); FI != FE; ++FI) - DiagFixItHints.push_back(*FI); + DiagFixItHints.append(storedDiag.fixit_begin(), storedDiag.fixit_end()); assert(Client && "DiagnosticConsumer not set!"); Level DiagLevel = storedDiag.getLevel(); diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp index ef9a92d..9981fcc 100644 --- a/clang/lib/CodeGen/CGObjC.cpp +++ b/clang/lib/CodeGen/CGObjC.cpp @@ -2996,13 +2996,9 @@ CodeGenFunction::GenerateObjCAtomicGetterCopyHelperFunction( SmallVector ConstructorArgs; ConstructorArgs.push_back(&SRC); - CXXConstructExpr::arg_iterator A = CXXConstExpr->arg_begin(); - ++A; - - for (CXXConstructExpr::arg_iterator AEnd = CXXConstExpr->arg_end(); - A != AEnd; ++A) - ConstructorArgs.push_back(*A); - + ConstructorArgs.append(std::next(CXXConstExpr->arg_begin()), + CXXConstExpr->arg_end()); + CXXConstructExpr *TheCXXConstructExpr = CXXConstructExpr::Create(C, Ty, SourceLocation(), CXXConstExpr->getConstructor(), diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 50edc42..3e0b4a5 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -722,11 +722,7 @@ void Sema::ActOnEndOfTranslationUnit() { ModMap.resolveConflicts(Mod, /*Complain=*/false); // Queue the submodules, so their exports will also be resolved. - for (Module::submodule_iterator Sub = Mod->submodule_begin(), - SubEnd = Mod->submodule_end(); - Sub != SubEnd; ++Sub) { - Stack.push_back(*Sub); - } + Stack.append(Mod->submodule_begin(), Mod->submodule_end()); } } diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp index 29b948d..f69367f 100644 --- a/clang/lib/Serialization/ASTWriterDecl.cpp +++ b/clang/lib/Serialization/ASTWriterDecl.cpp @@ -190,8 +190,7 @@ namespace clang { assert(D->isCanonicalDecl() && "non-canonical decl in set"); Writer.AddDeclRef(D, Record); } - for (DeclID ID : LazySpecializations) - Record.push_back(ID); + Record.append(LazySpecializations.begin(), LazySpecializations.end()); } }; } diff --git a/clang/tools/libclang/ARCMigrate.cpp b/clang/tools/libclang/ARCMigrate.cpp index b0b869b..b597383 100644 --- a/clang/tools/libclang/ARCMigrate.cpp +++ b/clang/tools/libclang/ARCMigrate.cpp @@ -101,9 +101,7 @@ CXRemapping clang_getRemappingsFromFileList(const char **filePaths, } TextDiagnosticBuffer diagBuffer; - SmallVector Files; - for (unsigned i = 0; i != numFiles; ++i) - Files.push_back(filePaths[i]); + SmallVector Files(filePaths, filePaths + numFiles); bool err = arcmt::getFileRemappingsFromFileList(remap->Vec, Files, &diagBuffer);