From 006229278b54ee92003100773a0430565fb8fe87 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Thu, 23 May 2019 14:49:54 +0200 Subject: Use cmAppend to append ranges to std::vector instances --- Source/CTest/cmCTestBZR.cxx | 3 +- Source/CTest/cmCTestBuildHandler.cxx | 3 +- Source/CTest/cmCTestCoverageHandler.cxx | 16 ++++------- Source/CTest/cmCTestCurl.cxx | 9 ++---- Source/CTest/cmCTestHG.cxx | 3 +- Source/CTest/cmCTestMultiProcessHandler.cxx | 16 +++++------ Source/CTest/cmCTestP4.cxx | 5 ++-- Source/CTest/cmCTestSVN.cxx | 7 ++--- Source/CTest/cmCTestSubmitHandler.cxx | 21 +++++--------- Source/CTest/cmProcess.cxx | 3 +- Source/cmAddLibraryCommand.cxx | 3 +- Source/cmAddTestCommand.cxx | 3 +- Source/cmCTest.cxx | 9 +++--- Source/cmConditionEvaluator.cxx | 7 ++--- Source/cmCustomCommand.cxx | 9 +++--- Source/cmCustomCommandGenerator.cxx | 12 ++++---- Source/cmDocumentationSection.h | 3 +- Source/cmELF.cxx | 3 +- Source/cmExecuteProcessCommand.cxx | 2 +- Source/cmExportBuildFileGenerator.h | 3 +- Source/cmExtraCodeBlocksGenerator.cxx | 25 +++++++---------- Source/cmFileAPICodemodel.cxx | 4 +-- Source/cmFileCommand.cxx | 15 +++++----- Source/cmFindBase.cxx | 3 +- Source/cmFindCommon.cxx | 3 +- Source/cmFunctionCommand.cxx | 2 +- Source/cmGeneratorExpressionParser.cxx | 5 ++-- Source/cmGlobalGenerator.h | 2 +- Source/cmGlobalJOMMakefileGenerator.cxx | 3 +- Source/cmGlobalNMakeMakefileGenerator.cxx | 3 +- Source/cmGlobalNinjaGenerator.cxx | 5 ++-- Source/cmGlobalUnixMakefileGenerator3.cxx | 5 +--- Source/cmGlobalVisualStudio8Generator.cxx | 6 ++-- Source/cmGlobalXCodeGenerator.cxx | 3 +- Source/cmIDEOptions.cxx | 6 ++-- Source/cmIncludeDirectoryCommand.cxx | 7 ++--- Source/cmInstallFilesCommand.cxx | 4 +-- Source/cmInstallProgramsCommand.cxx | 3 +- Source/cmJsonObjects.cxx | 4 +-- Source/cmLocalGenerator.cxx | 13 ++++----- Source/cmLocalUnixMakefileGenerator3.cxx | 4 +-- Source/cmMacroCommand.cxx | 2 +- Source/cmMakefile.cxx | 3 +- Source/cmMakefileExecutableTargetGenerator.cxx | 6 ++-- Source/cmMakefileLibraryTargetGenerator.cxx | 8 +++--- Source/cmMakefileTargetGenerator.cxx | 32 +++++++--------------- Source/cmNinjaTargetGenerator.cxx | 3 +- Source/cmOrderDirectories.cxx | 6 ++-- Source/cmQtAutoGen.cxx | 5 ++-- Source/cmQtAutoMocUic.cxx | 15 ++++------ Source/cmQtAutoRcc.cxx | 2 +- Source/cmSetTargetPropertiesCommand.cxx | 3 +- Source/cmSetTestsPropertiesCommand.cxx | 3 +- Source/cmStateDirectory.cxx | 4 +-- Source/cmSystemTools.cxx | 14 +++++----- Source/cmTarget.cxx | 38 +++++++++++--------------- Source/cmake.cxx | 5 +--- Source/cmakemain.cxx | 2 +- Source/cmcmd.cxx | 11 ++++---- 59 files changed, 181 insertions(+), 246 deletions(-) diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx index 83aeb64..b957856 100644 --- a/Source/CTest/cmCTestBZR.cxx +++ b/Source/CTest/cmCTestBZR.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestBZR.h" +#include "cmAlgorithms.h" #include "cmCTest.h" #include "cmCTestVC.h" #include "cmProcessTools.h" @@ -242,7 +243,7 @@ private: void CharacterDataHandler(const char* data, int length) override { - this->CData.insert(this->CData.end(), data, data + length); + cmAppend(this->CData, data, data + length); } void EndElement(const std::string& name) override diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 1e17e1c..c8e4fa1 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -978,8 +978,7 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, size_t length, if (it != queue->end()) { // Create a contiguous array for the line this->CurrentProcessingLine.clear(); - this->CurrentProcessingLine.insert(this->CurrentProcessingLine.end(), - queue->begin(), it); + cmAppend(this->CurrentProcessingLine, queue->begin(), it); this->CurrentProcessingLine.push_back(0); const char* line = this->CurrentProcessingLine.data(); diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index d76bd2a..f6028c4 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestCoverageHandler.h" +#include "cmAlgorithms.h" #include "cmCTest.h" #include "cmDuration.h" #include "cmGeneratedFileStream.h" @@ -813,15 +814,11 @@ int cmCTestCoverageHandler::HandleJacocoCoverage( // ...and in the binary directory. cmsys::Glob g2; - std::vector binFiles; g2.SetRecurse(true); std::string binaryDir = this->CTest->GetCTestConfiguration("BuildDirectory"); std::string binCoverageFile = binaryDir + "/*jacoco.xml"; g2.FindFiles(binCoverageFile); - binFiles = g2.GetFiles(); - if (!binFiles.empty()) { - files.insert(files.end(), binFiles.begin(), binFiles.end()); - } + cmAppend(files, g2.GetFiles()); if (!files.empty()) { cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, @@ -1465,8 +1462,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage( " looking for LCOV files in: " << daGlob << std::endl, this->Quiet); gl.FindFiles(daGlob); // Keep a list of all LCOV files - lcovFiles.insert(lcovFiles.end(), gl.GetFiles().begin(), - gl.GetFiles().end()); + cmAppend(lcovFiles, gl.GetFiles()); for (std::string const& file : lcovFiles) { lcovFile = file; @@ -1604,11 +1600,11 @@ void cmCTestCoverageHandler::FindGCovFiles(std::vector& files) std::string daGlob = lm.first; daGlob += "/*.da"; gl.FindFiles(daGlob); - files.insert(files.end(), gl.GetFiles().begin(), gl.GetFiles().end()); + cmAppend(files, gl.GetFiles()); daGlob = lm.first; daGlob += "/*.gcda"; gl.FindFiles(daGlob); - files.insert(files.end(), gl.GetFiles().begin(), gl.GetFiles().end()); + cmAppend(files, gl.GetFiles()); } } @@ -1645,7 +1641,7 @@ bool cmCTestCoverageHandler::FindLCovFiles(std::vector& files) "Error while finding files matching " << daGlob << std::endl); return false; } - files.insert(files.end(), gl.GetFiles().begin(), gl.GetFiles().end()); + cmAppend(files, gl.GetFiles()); cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Now searching in: " << daGlob << std::endl, this->Quiet); return true; diff --git a/Source/CTest/cmCTestCurl.cxx b/Source/CTest/cmCTestCurl.cxx index 6eb4354..cc63e45 100644 --- a/Source/CTest/cmCTestCurl.cxx +++ b/Source/CTest/cmCTestCurl.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestCurl.h" +#include "cmAlgorithms.h" #include "cmCTest.h" #include "cmCurl.h" #include "cmSystemTools.h" @@ -43,19 +44,15 @@ size_t curlWriteMemoryCallback(void* ptr, size_t size, size_t nmemb, void* data) { int realsize = static_cast(size * nmemb); - - std::vector* vec = static_cast*>(data); const char* chPtr = static_cast(ptr); - vec->insert(vec->end(), chPtr, chPtr + realsize); + cmAppend(*static_cast*>(data), chPtr, chPtr + realsize); return realsize; } size_t curlDebugCallback(CURL* /*unused*/, curl_infotype /*unused*/, char* chPtr, size_t size, void* data) { - std::vector* vec = static_cast*>(data); - vec->insert(vec->end(), chPtr, chPtr + size); - + cmAppend(*static_cast*>(data), chPtr, chPtr + size); return size; } } diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx index 727c59c..ba2252a 100644 --- a/Source/CTest/cmCTestHG.cxx +++ b/Source/CTest/cmCTestHG.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestHG.h" +#include "cmAlgorithms.h" #include "cmCTest.h" #include "cmCTestVC.h" #include "cmProcessTools.h" @@ -202,7 +203,7 @@ private: void CharacterDataHandler(const char* data, int length) override { - this->CData.insert(this->CData.end(), data, data + length); + cmAppend(this->CData, data, data + length); } void EndElement(const std::string& name) override diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 477161a..ef63073 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -3,6 +3,7 @@ #include "cmCTestMultiProcessHandler.h" #include "cmAffinity.h" +#include "cmAlgorithms.h" #include "cmCTest.h" #include "cmCTestRunTest.h" #include "cmCTestTestHandler.h" @@ -653,13 +654,10 @@ void cmCTestMultiProcessHandler::CreateParallelTestCostList() // Reverse iterate over the different dependency levels (deepest first). // Sort tests within each level by COST and append them to the cost list. for (TestSet const& currentSet : cmReverseRange(priorityStack)) { - TestComparator comp(this); - TestList sortedCopy; - - sortedCopy.insert(sortedCopy.end(), currentSet.begin(), currentSet.end()); - - std::stable_sort(sortedCopy.begin(), sortedCopy.end(), comp); + cmAppend(sortedCopy, currentSet); + std::stable_sort(sortedCopy.begin(), sortedCopy.end(), + TestComparator(this)); for (auto const& j : sortedCopy) { if (alreadySortedTests.find(j) == alreadySortedTests.end()) { @@ -688,8 +686,8 @@ void cmCTestMultiProcessHandler::CreateSerialTestCostList() presortedList.push_back(i.first); } - TestComparator comp(this); - std::stable_sort(presortedList.begin(), presortedList.end(), comp); + std::stable_sort(presortedList.begin(), presortedList.end(), + TestComparator(this)); TestSet alreadySortedTests; @@ -992,7 +990,7 @@ static Json::Value DumpCTestInfo( const std::vector& args = testRun.GetArguments(); if (!args.empty()) { commandAndArgs.reserve(args.size() + 1); - commandAndArgs.insert(commandAndArgs.end(), args.begin(), args.end()); + cmAppend(commandAndArgs, args); } testInfo["command"] = DumpToJsonArray(commandAndArgs); } diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index aa42810..2eb8dba 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestP4.h" +#include "cmAlgorithms.h" #include "cmCTest.h" #include "cmCTestVC.h" #include "cmProcessTools.h" @@ -324,9 +325,7 @@ void cmCTestP4::SetP4Options(std::vector& CommandOptions) // The CTEST_P4_OPTIONS variable adds additional Perforce command line // options before the main command std::string opts = this->CTest->GetCTestConfiguration("P4Options"); - std::vector args = cmSystemTools::ParseArguments(opts); - - P4Options.insert(P4Options.end(), args.begin(), args.end()); + cmAppend(P4Options, cmSystemTools::ParseArguments(opts)); } CommandOptions.clear(); diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index 04749b7..c834686 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestSVN.h" +#include "cmAlgorithms.h" #include "cmCTest.h" #include "cmCTestVC.h" #include "cmProcessTools.h" @@ -269,9 +270,7 @@ bool cmCTestSVN::RunSVNCommand(std::vector const& parameters, std::vector args; args.push_back(this->CommandLineTool.c_str()); - - args.insert(args.end(), parameters.begin(), parameters.end()); - + cmAppend(args, parameters); args.push_back("--non-interactive"); std::string userOptions = this->CTest->GetCTestConfiguration("SVNOptions"); @@ -344,7 +343,7 @@ private: void CharacterDataHandler(const char* data, int length) override { - this->CData.insert(this->CData.end(), data, data + length); + cmAppend(this->CData, data, data + length); } void EndElement(const std::string& name) override diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 2b54365..1fa7988 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -63,7 +63,7 @@ private: void CharacterDataHandler(const char* data, int length) override { - this->CurrentValue.insert(this->CurrentValue.end(), data, data + length); + cmAppend(this->CurrentValue, data, data + length); } void EndElement(const std::string& name) override @@ -93,12 +93,9 @@ static size_t cmCTestSubmitHandlerWriteMemoryCallback(void* ptr, size_t size, size_t nmemb, void* data) { int realsize = static_cast(size * nmemb); - - cmCTestSubmitHandlerVectorOfChar* vec = - static_cast(data); const char* chPtr = static_cast(ptr); - vec->insert(vec->end(), chPtr, chPtr + realsize); - + cmAppend(*static_cast(data), chPtr, + chPtr + realsize); return realsize; } @@ -107,10 +104,8 @@ static size_t cmCTestSubmitHandlerCurlDebugCallback(CURL* /*unused*/, char* chPtr, size_t size, void* data) { - cmCTestSubmitHandlerVectorOfChar* vec = - static_cast(data); - vec->insert(vec->end(), chPtr, chPtr + size); - + cmAppend(*static_cast(data), chPtr, + chPtr + size); return size; } @@ -769,8 +764,7 @@ int cmCTestSubmitHandler::ProcessHandler() if (!this->Files.empty()) { // Submit the explicitly selected files: - // - files.insert(files.end(), this->Files.begin(), this->Files.end()); + cmAppend(files, this->Files); } // Add to the list of files to submit from any selected, existing parts: @@ -816,8 +810,7 @@ int cmCTestSubmitHandler::ProcessHandler() } // Submit files from this part. - std::vector const& pfiles = this->CTest->GetSubmitFiles(p); - files.insert(files.end(), pfiles.begin(), pfiles.end()); + cmAppend(files, this->CTest->GetSubmitFiles(p)); } // Make sure files are unique, but preserve order. diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx index a2c30bb..7a3b82e 100644 --- a/Source/CTest/cmProcess.cxx +++ b/Source/CTest/cmProcess.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmProcess.h" +#include "cmAlgorithms.h" #include "cmCTest.h" #include "cmCTestRunTest.h" #include "cmCTestTestHandler.h" @@ -215,7 +216,7 @@ void cmProcess::OnRead(ssize_t nread, const uv_buf_t* buf) if (nread > 0) { std::string strdata; this->Conv.DecodeText(buf->base, static_cast(nread), strdata); - this->Output.insert(this->Output.end(), strdata.begin(), strdata.end()); + cmAppend(this->Output, strdata); while (this->Output.GetLine(line)) { this->Runner.CheckOutput(line); diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index adf4464..ad12e89 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -4,6 +4,7 @@ #include +#include "cmAlgorithms.h" #include "cmGeneratorExpression.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" @@ -338,7 +339,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector const& args, return true; } - srclists.insert(srclists.end(), s, args.end()); + cmAppend(srclists, s, args.end()); this->Makefile->AddLibrary(libName, type, srclists, excludeFromAll); diff --git a/Source/cmAddTestCommand.cxx b/Source/cmAddTestCommand.cxx index 3a3afdb..bf28702 100644 --- a/Source/cmAddTestCommand.cxx +++ b/Source/cmAddTestCommand.cxx @@ -27,8 +27,7 @@ bool cmAddTestCommand::InitialPass(std::vector const& args, } // Collect the command with arguments. - std::vector command; - command.insert(command.end(), args.begin() + 1, args.end()); + std::vector command(args.begin() + 1, args.end()); // Create the test but add a generator only the first time it is // seen. This preserves behavior from before test generators. diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 003ebdc..071ff56 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1282,7 +1282,7 @@ int cmCTest::RunTest(std::vector argv, std::string* output, while (cmsysProcess_WaitForData(cp, &data, &length, nullptr)) { processOutput.DecodeText(data, length, strdata); if (output) { - tempOutput.insert(tempOutput.end(), data, data + length); + cmAppend(tempOutput, data, data + length); } cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, cmCTestLogWrite(strdata.c_str(), strdata.size())); @@ -2194,8 +2194,7 @@ int cmCTest::Run(std::vector& args, std::string* output) bool SRArgumentSpecified = false; // copy the command line - this->Impl->InitialCommandLineArguments.insert( - this->Impl->InitialCommandLineArguments.end(), args.begin(), args.end()); + cmAppend(this->Impl->InitialCommandLineArguments, args); // process the command line arguments for (size_t i = 1; i < args.size(); ++i) { @@ -2958,10 +2957,10 @@ bool cmCTest::RunCommand(std::vector const& args, res = cmsysProcess_WaitForData(cp, &data, &length, nullptr); switch (res) { case cmsysProcess_Pipe_STDOUT: - tempOutput.insert(tempOutput.end(), data, data + length); + cmAppend(tempOutput, data, data + length); break; case cmsysProcess_Pipe_STDERR: - tempError.insert(tempError.end(), data, data + length); + cmAppend(tempError, data, data + length); break; default: done = true; diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 303b147..e7e91c1 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -94,10 +94,7 @@ bool cmConditionEvaluator::IsTrue( } // store the reduced args in this vector - cmArgumentList newArgs; - - // copy to the list structure - newArgs.insert(newArgs.end(), args.begin(), args.end()); + cmArgumentList newArgs(args.begin(), args.end()); // now loop through the arguments and see if we can reduce any of them // we do this multiple times. Once for each level of precedence @@ -398,7 +395,7 @@ bool cmConditionEvaluator::HandleLevel0(cmArgumentList& newArgs, // copy to the list structure cmArgumentList::iterator argP1 = arg; argP1++; - newArgs2.insert(newArgs2.end(), argP1, argClose); + cmAppend(newArgs2, argP1, argClose); newArgs2.pop_back(); // now recursively invoke IsTrue to handle the values inside the // parenthetical expression diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx index ad8c9b9..7402eeb 100644 --- a/Source/cmCustomCommand.cxx +++ b/Source/cmCustomCommand.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCustomCommand.h" +#include "cmAlgorithms.h" #include "cmMakefile.h" #include @@ -54,13 +55,12 @@ const char* cmCustomCommand::GetComment() const void cmCustomCommand::AppendCommands(const cmCustomCommandLines& commandLines) { - this->CommandLines.insert(this->CommandLines.end(), commandLines.begin(), - commandLines.end()); + cmAppend(this->CommandLines, commandLines); } void cmCustomCommand::AppendDepends(const std::vector& depends) { - this->Depends.insert(this->Depends.end(), depends.begin(), depends.end()); + cmAppend(this->Depends, depends); } bool cmCustomCommand::GetEscapeOldStyle() const @@ -101,8 +101,7 @@ void cmCustomCommand::SetImplicitDepends(ImplicitDependsList const& l) void cmCustomCommand::AppendImplicitDepends(ImplicitDependsList const& l) { - this->ImplicitDepends.insert(this->ImplicitDepends.end(), l.begin(), - l.end()); + cmAppend(this->ImplicitDepends, l); } bool cmCustomCommand::GetUsesTerminal() const diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 6bf9946..e58fc76 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCustomCommandGenerator.h" +#include "cmAlgorithms.h" #include "cmCustomCommand.h" #include "cmCustomCommandLines.h" #include "cmGeneratorExpression.h" @@ -33,9 +34,7 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, this->GE->Parse(clarg); std::string parsed_arg = cge->Evaluate(this->LG, this->Config); if (this->CC.GetCommandExpandLists()) { - std::vector ExpandedArg; - cmSystemTools::ExpandListArgument(parsed_arg, ExpandedArg); - argv.insert(argv.end(), ExpandedArg.begin(), ExpandedArg.end()); + cmAppend(argv, cmSystemTools::ExpandedListArgument(parsed_arg)); } else { argv.push_back(std::move(parsed_arg)); } @@ -54,15 +53,14 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, std::vector depends = this->CC.GetDepends(); for (std::string const& d : depends) { std::unique_ptr cge = this->GE->Parse(d); - std::vector result; - cmSystemTools::ExpandListArgument(cge->Evaluate(this->LG, this->Config), - result); + std::vector result = cmSystemTools::ExpandedListArgument( + cge->Evaluate(this->LG, this->Config)); for (std::string& it : result) { if (cmSystemTools::FileIsFullPath(it)) { it = cmSystemTools::CollapseFullPath(it); } } - this->Depends.insert(this->Depends.end(), result.begin(), result.end()); + cmAppend(this->Depends, result); } const std::string& workingdirectory = this->CC.GetWorkingDirectory(); diff --git a/Source/cmDocumentationSection.h b/Source/cmDocumentationSection.h index 7031b52..19c7407 100644 --- a/Source/cmDocumentationSection.h +++ b/Source/cmDocumentationSection.h @@ -5,6 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include "cmAlgorithms.h" #include "cmDocumentationEntry.h" #include @@ -46,7 +47,7 @@ public: } void Append(const std::vector& entries) { - this->Entries.insert(this->Entries.end(), entries.begin(), entries.end()); + cmAppend(this->Entries, entries); } /** Append an entry to this section using NULL terminated chars */ diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index 27f9131..2226463 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmELF.h" +#include "cmAlgorithms.h" #include "cm_kwiml.h" #include "cmsys/FStream.hxx" #include @@ -572,7 +573,7 @@ std::vector cmELFInternalImpl::EncodeDynamicEntries( } char* pdyn = reinterpret_cast(&dyn); - result.insert(result.end(), pdyn, pdyn + sizeof(ELF_Dyn)); + cmAppend(result, pdyn, pdyn + sizeof(ELF_Dyn)); } return result; diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx index 0d9859e..494afbb 100644 --- a/Source/cmExecuteProcessCommand.cxx +++ b/Source/cmExecuteProcessCommand.cxx @@ -393,5 +393,5 @@ void cmExecuteProcessCommandAppend(std::vector& output, const char* data, --length; } #endif - output.insert(output.end(), data, data + length); + cmAppend(output, data, data + length); } diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h index ada2709..0a1e755 100644 --- a/Source/cmExportBuildFileGenerator.h +++ b/Source/cmExportBuildFileGenerator.h @@ -5,6 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include "cmAlgorithms.h" #include "cmExportFileGenerator.h" #include "cmStateTypes.h" @@ -39,7 +40,7 @@ public: void GetTargets(std::vector& targets) const; void AppendTargets(std::vector const& targets) { - this->Targets.insert(this->Targets.end(), targets.begin(), targets.end()); + cmAppend(this->Targets, targets); } void SetExportSet(cmExportSet*); diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index c6e44e3..f47744b 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -209,9 +209,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( // Collect all files std::vector listFiles; for (cmLocalGenerator* lg : it.second) { - const std::vector& files = - lg->GetMakefile()->GetListFiles(); - listFiles.insert(listFiles.end(), files.begin(), files.end()); + cmAppend(listFiles, lg->GetMakefile()->GetListFiles()); } // Convert @@ -563,27 +561,24 @@ void cmExtraCodeBlocksGenerator::AppendTarget( // the include directories for this target std::vector allIncludeDirs; - - std::vector includes; - lg->GetIncludeDirectories(includes, target, "C", buildType); - - allIncludeDirs.insert(allIncludeDirs.end(), includes.begin(), - includes.end()); + { + std::vector includes; + lg->GetIncludeDirectories(includes, target, "C", buildType); + cmAppend(allIncludeDirs, includes); + } std::string systemIncludeDirs = makefile->GetSafeDefinition( "CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS"); if (!systemIncludeDirs.empty()) { - std::vector dirs; - cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs); - allIncludeDirs.insert(allIncludeDirs.end(), dirs.begin(), dirs.end()); + cmAppend(allIncludeDirs, + cmSystemTools::ExpandedListArgument(systemIncludeDirs)); } systemIncludeDirs = makefile->GetSafeDefinition( "CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS"); if (!systemIncludeDirs.empty()) { - std::vector dirs; - cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs); - allIncludeDirs.insert(allIncludeDirs.end(), dirs.begin(), dirs.end()); + cmAppend(allIncludeDirs, + cmSystemTools::ExpandedListArgument(systemIncludeDirs)); } std::vector::const_iterator end = diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 45e8303..0fb166a 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmFileAPICodemodel.h" +#include "cmAlgorithms.h" #include "cmCryptoHash.h" #include "cmFileAPI.h" #include "cmGeneratorExpression.h" @@ -477,8 +478,7 @@ Json::Value CodemodelConfig::DumpTargets() cmGlobalGenerator* gg = this->FileAPI.GetCMakeInstance()->GetGlobalGenerator(); for (cmLocalGenerator const* lg : gg->GetLocalGenerators()) { - std::vector const& list = lg->GetGeneratorTargets(); - targetList.insert(targetList.end(), list.begin(), list.end()); + cmAppend(targetList, lg->GetGeneratorTargets()); } std::sort(targetList.begin(), targetList.end(), [](cmGeneratorTarget* l, cmGeneratorTarget* r) { diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index c0e263a..7a3954e 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -890,7 +890,7 @@ bool cmFileCommand::HandleGlobCommand(std::vector const& args, } std::vector& foundFiles = g.GetFiles(); - files.insert(files.end(), foundFiles.begin(), foundFiles.end()); + cmAppend(files, foundFiles); if (configureDepends) { std::sort(foundFiles.begin(), foundFiles.end()); @@ -1476,23 +1476,22 @@ size_t cmWriteToMemoryCallback(void* ptr, size_t size, size_t nmemb, void* data) { int realsize = static_cast(size * nmemb); - cmFileCommandVectorOfChar* vec = - static_cast(data); const char* chPtr = static_cast(ptr); - vec->insert(vec->end(), chPtr, chPtr + realsize); + cmAppend(*static_cast(data), chPtr, + chPtr + realsize); return realsize; } size_t cmFileCommandCurlDebugCallback(CURL*, curl_infotype type, char* chPtr, size_t size, void* data) { - cmFileCommandVectorOfChar* vec = - static_cast(data); + cmFileCommandVectorOfChar& vec = + *static_cast(data); switch (type) { case CURLINFO_TEXT: case CURLINFO_HEADER_IN: case CURLINFO_HEADER_OUT: - vec->insert(vec->end(), chPtr, chPtr + size); + cmAppend(vec, chPtr, chPtr + size); break; case CURLINFO_DATA_IN: case CURLINFO_DATA_OUT: @@ -1502,7 +1501,7 @@ size_t cmFileCommandCurlDebugCallback(CURL*, curl_infotype type, char* chPtr, int n = sprintf(buf, "[%" KWIML_INT_PRIu64 " bytes data]\n", static_cast(size)); if (n > 0) { - vec->insert(vec->end(), buf, buf + n); + cmAppend(vec, buf, buf + n); } } break; default: diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index 2e5e29c..e590802 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -146,8 +146,7 @@ bool cmFindBase::ParseArguments(std::vector const& argsIn) std::vector shortArgs = this->Names; this->Names.clear(); // clear out any values in Names this->Names.push_back(shortArgs[0]); - this->UserGuessArgs.insert(this->UserGuessArgs.end(), - shortArgs.begin() + 1, shortArgs.end()); + cmAppend(this->UserGuessArgs, shortArgs.begin() + 1, shortArgs.end()); } this->ExpandPaths(); diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index 9aaa000..954558f 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -6,6 +6,7 @@ #include #include +#include "cmAlgorithms.h" #include "cmMakefile.h" #include "cmSystemTools.h" @@ -221,7 +222,7 @@ void cmFindCommon::RerootPaths(std::vector& paths) // If searching both rooted and unrooted paths add the original // paths again. if (this->FindRootPathMode == RootPathModeBoth) { - paths.insert(paths.end(), unrootedPaths.begin(), unrootedPaths.end()); + cmAppend(paths, unrootedPaths); } } diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index 9d75b72..9067a5f 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -177,7 +177,7 @@ bool cmFunctionCommand::InitialPass(std::vector const& args, // create a function blocker cmFunctionFunctionBlocker* f = new cmFunctionFunctionBlocker(); - f->Args.insert(f->Args.end(), args.begin(), args.end()); + cmAppend(f->Args, args); this->Makefile->AddFunctionBlocker(f); return true; } diff --git a/Source/cmGeneratorExpressionParser.cxx b/Source/cmGeneratorExpressionParser.cxx index 7aa3314..304378d 100644 --- a/Source/cmGeneratorExpressionParser.cxx +++ b/Source/cmGeneratorExpressionParser.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGeneratorExpressionParser.h" +#include "cmAlgorithms.h" #include "cmGeneratorExpressionEvaluator.h" #include @@ -52,9 +53,9 @@ static void extendResult( textContent->Extend( static_cast(contents.front())->GetLength()); delete contents.front(); - result.insert(result.end(), contents.begin() + 1, contents.end()); + cmAppend(result, contents.begin() + 1, contents.end()); } else { - result.insert(result.end(), contents.begin(), contents.end()); + cmAppend(result, contents); } } diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 88c586a..dcd8c5f 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -67,7 +67,7 @@ struct GeneratedMakeCommand void Add(std::vector::const_iterator start, std::vector::const_iterator end) { - PrimaryCommand.insert(PrimaryCommand.end(), start, end); + cmAppend(PrimaryCommand, start, end); } std::string Printable() const { return cmJoin(PrimaryCommand, " "); } diff --git a/Source/cmGlobalJOMMakefileGenerator.cxx b/Source/cmGlobalJOMMakefileGenerator.cxx index 43c9666..ff54288 100644 --- a/Source/cmGlobalJOMMakefileGenerator.cxx +++ b/Source/cmGlobalJOMMakefileGenerator.cxx @@ -66,8 +66,7 @@ cmGlobalJOMMakefileGenerator::GenerateBuildCommand( // Since we have full control over the invocation of JOM, let us // make it quiet. jomMakeOptions.push_back(this->MakeSilentFlag); - jomMakeOptions.insert(jomMakeOptions.end(), makeOptions.begin(), - makeOptions.end()); + cmAppend(jomMakeOptions, makeOptions); // JOM does parallel builds by default, the -j is only needed if a specific // number is given diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx index a4838bc..2273c00 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.cxx +++ b/Source/cmGlobalNMakeMakefileGenerator.cxx @@ -66,8 +66,7 @@ cmGlobalNMakeMakefileGenerator::GenerateBuildCommand( // Since we have full control over the invocation of nmake, let us // make it quiet. nmakeMakeOptions.push_back(this->MakeSilentFlag); - nmakeMakeOptions.insert(nmakeMakeOptions.end(), makeOptions.begin(), - makeOptions.end()); + cmAppend(nmakeMakeOptions, makeOptions); return this->cmGlobalUnixMakefileGenerator3::GenerateBuildCommand( makeProgram, projectName, projectDir, targetNames, config, fast, diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 5ddaaa3..ea65a77 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1016,7 +1016,7 @@ void cmGlobalNinjaGenerator::AppendTargetDepends( this->AppendTargetOutputs(targetDep, outs, depends); } std::sort(outs.begin(), outs.end()); - outputs.insert(outputs.end(), outs.begin(), outs.end()); + cmAppend(outputs, outs); } } @@ -1025,8 +1025,7 @@ void cmGlobalNinjaGenerator::AppendTargetDependsClosure( { cmNinjaOuts outs; this->AppendTargetDependsClosure(target, outs, true); - - outputs.insert(outputs.end(), outs.begin(), outs.end()); + cmAppend(outputs, outs); } void cmGlobalNinjaGenerator::AppendTargetDependsClosure( diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 8053f61..aa584ad 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -282,11 +282,8 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() // for each cmMakefile get its list of dependencies std::vector lfiles; for (cmLocalGenerator* localGen : this->LocalGenerators) { - lg = static_cast(localGen); - // Get the list of files contributing to this generation step. - lfiles.insert(lfiles.end(), lg->GetMakefile()->GetListFiles().begin(), - lg->GetMakefile()->GetListFiles().end()); + cmAppend(lfiles, localGen->GetMakefile()->GetListFiles()); } cmake* cm = this->GetCMakeInstance(); diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 0da9986..85ddc85 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -141,10 +141,8 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() // Collect the input files used to generate all targets in this // project. std::vector listFiles; - for (unsigned int j = 0; j < generators.size(); ++j) { - cmMakefile* lmf = generators[j]->GetMakefile(); - listFiles.insert(listFiles.end(), lmf->GetListFiles().begin(), - lmf->GetListFiles().end()); + for (cmLocalGenerator* gen : generators) { + cmAppend(listFiles, gen->GetMakefile()->GetListFiles()); } // Add a custom prebuild target to run the VerifyGlobs script. diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index f2eb0ce..7c2bcd3 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -583,8 +583,7 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile( { std::vector lfiles; for (auto gen : gens) { - std::vector const& lf = gen->GetMakefile()->GetListFiles(); - lfiles.insert(lfiles.end(), lf.begin(), lf.end()); + cmAppend(lfiles, gen->GetMakefile()->GetListFiles()); } // sort the array diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx index ea67d45..7b992d7 100644 --- a/Source/cmIDEOptions.cxx +++ b/Source/cmIDEOptions.cxx @@ -6,6 +6,7 @@ #include #include +#include "cmAlgorithms.h" #include "cmIDEFlagTable.h" #include "cmSystemTools.h" @@ -170,7 +171,7 @@ void cmIDEOptions::AddDefines(std::string const& defines) } void cmIDEOptions::AddDefines(const std::vector& defines) { - this->Defines.insert(this->Defines.end(), defines.begin(), defines.end()); + cmAppend(this->Defines, defines); } std::vector const& cmIDEOptions::GetDefines() const @@ -192,8 +193,7 @@ void cmIDEOptions::AddIncludes(std::string const& includes) } void cmIDEOptions::AddIncludes(const std::vector& includes) { - this->Includes.insert(this->Includes.end(), includes.begin(), - includes.end()); + cmAppend(this->Includes, includes); } std::vector const& cmIDEOptions::GetIncludes() const diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx index 549a263..62e2abd 100644 --- a/Source/cmIncludeDirectoryCommand.cxx +++ b/Source/cmIncludeDirectoryCommand.cxx @@ -6,6 +6,7 @@ #include #include +#include "cmAlgorithms.h" #include "cmGeneratorExpression.h" #include "cmMakefile.h" #include "cmSystemTools.h" @@ -52,11 +53,9 @@ bool cmIncludeDirectoryCommand::InitialPass( this->GetIncludes(*i, includes); if (before) { - beforeIncludes.insert(beforeIncludes.end(), includes.begin(), - includes.end()); + cmAppend(beforeIncludes, includes); } else { - afterIncludes.insert(afterIncludes.end(), includes.begin(), - includes.end()); + cmAppend(afterIncludes, includes); } if (system) { systemIncludes.insert(includes.begin(), includes.end()); diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index b068e46..efbcb67 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmInstallFilesCommand.h" +#include "cmAlgorithms.h" #include "cmGeneratorExpression.h" #include "cmGlobalGenerator.h" #include "cmInstallFilesGenerator.h" @@ -35,8 +36,7 @@ bool cmInstallFilesCommand::InitialPass(std::vector const& args, this->CreateInstallGenerator(); } else { this->IsFilesForm = false; - this->FinalArgs.insert(this->FinalArgs.end(), args.begin() + 1, - args.end()); + cmAppend(this->FinalArgs, args.begin() + 1, args.end()); } this->Makefile->GetGlobalGenerator()->AddInstallComponent( diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx index f01a4c1..a58f875 100644 --- a/Source/cmInstallProgramsCommand.cxx +++ b/Source/cmInstallProgramsCommand.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmInstallProgramsCommand.h" +#include "cmAlgorithms.h" #include "cmGeneratorExpression.h" #include "cmGlobalGenerator.h" #include "cmInstallFilesGenerator.h" @@ -25,7 +26,7 @@ bool cmInstallProgramsCommand::InitialPass( this->Destination = args[0]; - this->FinalArgs.insert(this->FinalArgs.end(), args.begin() + 1, args.end()); + cmAppend(this->FinalArgs, args.begin() + 1, args.end()); this->Makefile->GetGlobalGenerator()->AddInstallComponent( this->Makefile->GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME")); diff --git a/Source/cmJsonObjects.cxx b/Source/cmJsonObjects.cxx index d723ced..636a8e1 100644 --- a/Source/cmJsonObjects.cxx +++ b/Source/cmJsonObjects.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmJsonObjects.h" // IWYU pragma: keep +#include "cmAlgorithms.h" #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" @@ -601,8 +602,7 @@ static Json::Value DumpTargetsList( std::vector targetList; for (auto const& lgIt : generators) { - const auto& list = lgIt->GetGeneratorTargets(); - targetList.insert(targetList.end(), list.begin(), list.end()); + cmAppend(targetList, lgIt->GetGeneratorTargets()); } std::sort(targetList.begin(), targetList.end()); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 047d405..787e98e 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -351,9 +351,8 @@ void cmLocalGenerator::CreateEvaluationFileOutputs(std::string const& config) void cmLocalGenerator::ProcessEvaluationFiles( std::vector& generatedFiles) { - std::vector ef = - this->Makefile->GetEvaluationFiles(); - for (cmGeneratorExpressionEvaluationFile* geef : ef) { + for (cmGeneratorExpressionEvaluationFile* geef : + this->Makefile->GetEvaluationFiles()) { geef->Generate(this); if (cmSystemTools::GetFatalErrorOccured()) { return; @@ -372,10 +371,10 @@ void cmLocalGenerator::ProcessEvaluationFiles( return; } - generatedFiles.insert(generatedFiles.end(), files.begin(), files.end()); - std::vector::iterator newIt = - generatedFiles.end() - files.size(); - std::inplace_merge(generatedFiles.begin(), newIt, generatedFiles.end()); + cmAppend(generatedFiles, files); + std::inplace_merge(generatedFiles.begin(), + generatedFiles.end() - files.size(), + generatedFiles.end()); } } diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 04e3d12..c392e97 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -862,7 +862,7 @@ void cmLocalUnixMakefileGenerator3::AppendRuleDepends( // Add a dependency on the rule file itself unless an option to skip // it is specifically enabled by the user or project. if (!this->Makefile->IsOn("CMAKE_SKIP_RULE_DEPENDENCY")) { - depends.insert(depends.end(), ruleFiles.begin(), ruleFiles.end()); + cmAppend(depends, ruleFiles); } } @@ -1037,7 +1037,7 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand( this->CreateCDCommand(commands1, dir, relative); // push back the custom commands - commands.insert(commands.end(), commands1.begin(), commands1.end()); + cmAppend(commands, commands1); } void cmLocalUnixMakefileGenerator3::AppendCleanCommand( diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index 6565f02..e9c6aea 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -212,7 +212,7 @@ bool cmMacroCommand::InitialPass(std::vector const& args, // create a function blocker cmMacroFunctionBlocker* f = new cmMacroFunctionBlocker(); - f->Args.insert(f->Args.end(), args.begin(), args.end()); + cmAppend(f->Args, args); this->Makefile->AddFunctionBlocker(f); return true; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index ca5f009..c601e6a 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2534,8 +2534,7 @@ const std::string& cmMakefile::GetSafeDefinition(const std::string& name) const std::vector cmMakefile::GetDefinitions() const { std::vector res = this->StateSnapshot.ClosureKeys(); - std::vector cacheKeys = this->GetState()->GetCacheEntryKeys(); - res.insert(res.end(), cacheKeys.begin(), cacheKeys.end()); + cmAppend(res, this->GetState()->GetCacheEntryKeys()); std::sort(res.begin(), res.end()); return res; } diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 571da1a..552463d 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -268,7 +268,7 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule( this->LocalGenerator->CreateCDCommand( commands1, this->Makefile->GetCurrentBinaryDirectory(), this->LocalGenerator->GetBinaryDirectory()); - commands.insert(commands.end(), commands1.begin(), commands1.end()); + cmAppend(commands, commands1); commands1.clear(); // Write the build rule. @@ -638,7 +638,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) this->LocalGenerator->CreateCDCommand( commands1, this->Makefile->GetCurrentBinaryDirectory(), this->LocalGenerator->GetBinaryDirectory()); - commands.insert(commands.end(), commands1.begin(), commands1.end()); + cmAppend(commands, commands1); commands1.clear(); // Add a rule to create necessary symlinks for the library. @@ -651,7 +651,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) this->LocalGenerator->CreateCDCommand( commands1, this->Makefile->GetCurrentBinaryDirectory(), this->LocalGenerator->GetBinaryDirectory()); - commands.insert(commands.end(), commands1.begin(), commands1.end()); + cmAppend(commands, commands1); commands1.clear(); } diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index d4d565d..99f0df8 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -399,7 +399,7 @@ void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules( this->LocalGenerator->CreateCDCommand( commands1, this->Makefile->GetCurrentBinaryDirectory(), this->LocalGenerator->GetBinaryDirectory()); - commands.insert(commands.end(), commands1.begin(), commands1.end()); + cmAppend(commands, commands1); commands1.clear(); // Compute the list of outputs. @@ -575,7 +575,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( this->LocalGenerator->CreateCDCommand( commands1, this->Makefile->GetCurrentBinaryDirectory(), this->LocalGenerator->GetBinaryDirectory()); - commands.insert(commands.end(), commands1.begin(), commands1.end()); + cmAppend(commands, commands1); commands1.clear(); } @@ -915,7 +915,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( this->LocalGenerator->CreateCDCommand( commands1, this->Makefile->GetCurrentBinaryDirectory(), this->LocalGenerator->GetBinaryDirectory()); - commands.insert(commands.end(), commands1.begin(), commands1.end()); + cmAppend(commands, commands1); commands1.clear(); // Add a rule to create necessary symlinks for the library. @@ -932,7 +932,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( this->LocalGenerator->CreateCDCommand( commands1, this->Makefile->GetCurrentBinaryDirectory(), this->LocalGenerator->GetBinaryDirectory()); - commands.insert(commands.end(), commands1.begin(), commands1.end()); + cmAppend(commands, commands1); commands1.clear(); } diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index d326ec5..b3bab4b 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -219,14 +219,9 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() std::vector buildEventCommands = this->GeneratorTarget->GetPreBuildCommands(); - buildEventCommands.insert( - buildEventCommands.end(), - this->GeneratorTarget->GetPreLinkCommands().begin(), - this->GeneratorTarget->GetPreLinkCommands().end()); - buildEventCommands.insert( - buildEventCommands.end(), - this->GeneratorTarget->GetPostBuildCommands().begin(), - this->GeneratorTarget->GetPostBuildCommands().end()); + cmAppend(buildEventCommands, this->GeneratorTarget->GetPreLinkCommands()); + cmAppend(buildEventCommands, + this->GeneratorTarget->GetPostBuildCommands()); for (const auto& be : buildEventCommands) { const std::vector& byproducts = be.GetByproducts(); @@ -819,8 +814,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( this->LocalGenerator->CreateCDCommand( compileCommands, this->LocalGenerator->GetCurrentBinaryDirectory(), this->LocalGenerator->GetBinaryDirectory()); - commands.insert(commands.end(), compileCommands.begin(), - compileCommands.end()); + cmAppend(commands, compileCommands); } // Check for extra outputs created by the compilation. @@ -882,8 +876,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( preprocessCommands, this->LocalGenerator->GetCurrentBinaryDirectory(), this->LocalGenerator->GetBinaryDirectory()); - commands.insert(commands.end(), preprocessCommands.begin(), - preprocessCommands.end()); + cmAppend(commands, preprocessCommands); } else { std::string cmd = "$(CMAKE_COMMAND) -E cmake_unimplemented_variable "; cmd += preprocessRuleVar; @@ -929,8 +922,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( this->LocalGenerator->CreateCDCommand( assemblyCommands, this->LocalGenerator->GetCurrentBinaryDirectory(), this->LocalGenerator->GetBinaryDirectory()); - commands.insert(commands.end(), assemblyCommands.begin(), - assemblyCommands.end()); + cmAppend(commands, assemblyCommands); } else { std::string cmd = "$(CMAKE_COMMAND) -E cmake_unimplemented_variable "; cmd += assemblyRuleVar; @@ -1177,8 +1169,7 @@ void cmMakefileTargetGenerator::DriveCustomCommands( if (cmCustomCommand* cc = source->GetCustomCommand()) { cmCustomCommandGenerator ccg(*cc, this->ConfigName, this->LocalGenerator); - const std::vector& outputs = ccg.GetOutputs(); - depends.insert(depends.end(), outputs.begin(), outputs.end()); + cmAppend(depends, ccg.GetOutputs()); } } } @@ -1402,8 +1393,7 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule( } // Make sure the extra files are built. - depends.insert(depends.end(), this->ExtraFiles.begin(), - this->ExtraFiles.end()); + cmAppend(depends, this->ExtraFiles); } // Write the driver rule. @@ -1425,8 +1415,7 @@ void cmMakefileTargetGenerator::AppendTargetDepends( const std::string& cfg = this->LocalGenerator->GetConfigName(); if (cmComputeLinkInformation* cli = this->GeneratorTarget->GetLinkInformation(cfg)) { - std::vector const& libDeps = cli->GetDepends(); - depends.insert(depends.end(), libDeps.begin(), libDeps.end()); + cmAppend(depends, cli->GetDepends()); } } @@ -1443,8 +1432,7 @@ void cmMakefileTargetGenerator::AppendObjectDepends( } // Add dependencies on the external object files. - depends.insert(depends.end(), this->ExternalObjects.begin(), - this->ExternalObjects.end()); + cmAppend(depends, this->ExternalObjects); // Add a dependency on the rule file itself. this->LocalGenerator->AppendRuleDepend(depends, diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index e6a13bb..9652a51 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -841,8 +841,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements() this->GeneratorTarget, orderOnlyDeps, DependOnTargetOrdering); // Add order-only dependencies on other files associated with the target. - orderOnlyDeps.insert(orderOnlyDeps.end(), this->ExtraFiles.begin(), - this->ExtraFiles.end()); + cmAppend(orderOnlyDeps, this->ExtraFiles); // Add order-only dependencies on custom command outputs. for (cmCustomCommand const* cc : this->CustomCommands) { diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index 2c28fc0..585db42 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -329,15 +329,13 @@ void cmOrderDirectories::AddLinkLibrary(std::string const& fullPath) void cmOrderDirectories::AddUserDirectories( std::vector const& extra) { - this->UserDirectories.insert(this->UserDirectories.end(), extra.begin(), - extra.end()); + cmAppend(this->UserDirectories, extra); } void cmOrderDirectories::AddLanguageDirectories( std::vector const& dirs) { - this->LanguageDirectories.insert(this->LanguageDirectories.end(), - dirs.begin(), dirs.end()); + cmAppend(this->LanguageDirectories, dirs); } void cmOrderDirectories::SetImplicitDirectories( diff --git a/Source/cmQtAutoGen.cxx b/Source/cmQtAutoGen.cxx index a245b54..3683edd 100644 --- a/Source/cmQtAutoGen.cxx +++ b/Source/cmQtAutoGen.cxx @@ -68,7 +68,7 @@ void MergeOptions(std::vector& baseOpts, } } // Append options - baseOpts.insert(baseOpts.end(), extraOpts.begin(), extraOpts.end()); + cmAppend(baseOpts, extraOpts); } // - Class definitions @@ -347,8 +347,7 @@ bool cmQtAutoGen::RccLister::list(std::string const& qrcFile, { std::vector cmd; cmd.emplace_back(this->RccExcutable_); - cmd.insert(cmd.end(), this->ListOptions_.begin(), - this->ListOptions_.end()); + cmAppend(cmd, this->ListOptions_); cmd.emplace_back(cmSystemTools::GetFilenameName(qrcFile)); // Log command diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 36794d6..dbabba0 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -293,11 +293,10 @@ void cmQtAutoMocUic::JobMocPredefsT::Process() // Compose command std::vector cmd = MocConst().PredefsCmd; // Add includes - cmd.insert(cmd.end(), MocConst().Includes.begin(), - MocConst().Includes.end()); + cmAppend(cmd, MocConst().Includes); // Add definitions for (std::string const& def : MocConst().Definitions) { - cmd.push_back("-D" + def); + cmd.emplace_back("-D" + def); } // Execute command if (!RunProcess(GenT::MOC, result, cmd, reason.get())) { @@ -1398,8 +1397,7 @@ void cmQtAutoMocUic::JobMocT::Process() std::vector cmd; cmd.push_back(MocConst().Executable); // Add options - cmd.insert(cmd.end(), MocConst().AllOptions.begin(), - MocConst().AllOptions.end()); + cmAppend(cmd, MocConst().AllOptions); // Add predefs include if (!MocConst().PredefsFileAbs.empty()) { cmd.emplace_back("--include"); @@ -1452,7 +1450,7 @@ void cmQtAutoMocUic::JobUicT::Process() UicMergeOptions(allOpts, optionIt->second, (BaseConst().QtVersionMajor == 5)); } - cmd.insert(cmd.end(), allOpts.begin(), allOpts.end()); + cmAppend(cmd, allOpts); } cmd.emplace_back("-o"); cmd.emplace_back(outputFile); @@ -1881,9 +1879,8 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) // Sort include directories on demand if (BaseConst().IncludeProjectDirsBefore) { // Move strings to temporary list - std::list includes; - includes.insert(includes.end(), MocConst().IncludePaths.begin(), - MocConst().IncludePaths.end()); + std::list includes(MocConst().IncludePaths.begin(), + MocConst().IncludePaths.end()); MocConst_.IncludePaths.clear(); MocConst_.IncludePaths.reserve(includes.size()); // Append project directories only diff --git a/Source/cmQtAutoRcc.cxx b/Source/cmQtAutoRcc.cxx index 7ac7339..20885df 100644 --- a/Source/cmQtAutoRcc.cxx +++ b/Source/cmQtAutoRcc.cxx @@ -431,7 +431,7 @@ bool cmQtAutoRcc::GenerateRcc() // Compose rcc command std::vector cmd; cmd.push_back(RccExecutable_); - cmd.insert(cmd.end(), Options_.begin(), Options_.end()); + cmAppend(cmd, Options_); cmd.emplace_back("-o"); cmd.push_back(RccFileOutput_); cmd.push_back(QrcFile_); diff --git a/Source/cmSetTargetPropertiesCommand.cxx b/Source/cmSetTargetPropertiesCommand.cxx index 6425913..1dc7e69 100644 --- a/Source/cmSetTargetPropertiesCommand.cxx +++ b/Source/cmSetTargetPropertiesCommand.cxx @@ -4,6 +4,7 @@ #include +#include "cmAlgorithms.h" #include "cmMakefile.h" #include "cmTarget.h" @@ -30,7 +31,7 @@ bool cmSetTargetPropertiesCommand::InitialPass( this->SetError("called with incorrect number of arguments."); return false; } - propertyPairs.insert(propertyPairs.end(), j, args.end()); + cmAppend(propertyPairs, j, args.end()); break; } numFiles++; diff --git a/Source/cmSetTestsPropertiesCommand.cxx b/Source/cmSetTestsPropertiesCommand.cxx index e27c675..cc9587c 100644 --- a/Source/cmSetTestsPropertiesCommand.cxx +++ b/Source/cmSetTestsPropertiesCommand.cxx @@ -4,6 +4,7 @@ #include +#include "cmAlgorithms.h" #include "cmMakefile.h" #include "cmTest.h" @@ -30,7 +31,7 @@ bool cmSetTestsPropertiesCommand::InitialPass( this->SetError("called with incorrect number of arguments."); return false; } - propertyPairs.insert(propertyPairs.end(), j, args.end()); + cmAppend(propertyPairs, j, args.end()); break; } numFiles++; diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx index 31273cc..182d3fe 100644 --- a/Source/cmStateDirectory.cxx +++ b/Source/cmStateDirectory.cxx @@ -621,9 +621,7 @@ const char* cmStateDirectory::GetProperty(const std::string& prop, } if (prop == "VARIABLES") { std::vector res = this->Snapshot_.ClosureKeys(); - std::vector cacheKeys = - this->Snapshot_.State->GetCacheEntryKeys(); - res.insert(res.end(), cacheKeys.begin(), cacheKeys.end()); + cmAppend(res, this->Snapshot_.State->GetCacheEntryKeys()); std::sort(res.begin(), res.end()); output = cmJoin(res, ";"); return output.c_str(); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 6359d60..612284a 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -501,7 +501,7 @@ std::vector cmSystemTools::HandleResponseFile( #else cmSystemTools::ParseUnixCommandLine(line.c_str(), args2); #endif - arg_full.insert(arg_full.end(), args2.begin(), args2.end()); + cmAppend(arg_full, args2); } } else { arg_full.push_back(arg); @@ -726,7 +726,7 @@ bool cmSystemTools::RunSingleCommand(std::vector const& command, cmSystemTools::Stdout(strdata); } if (captureStdOut) { - tempStdOut.insert(tempStdOut.end(), data, data + length); + cmAppend(tempStdOut, data, data + length); } } else if (pipe == cmsysProcess_Pipe_STDERR) { if (outputflag != OUTPUT_NONE) { @@ -734,7 +734,7 @@ bool cmSystemTools::RunSingleCommand(std::vector const& command, cmSystemTools::Stderr(strdata); } if (captureStdErr) { - tempStdErr.insert(tempStdErr.end(), data, data + length); + cmAppend(tempStdErr, data, data + length); } } } @@ -1917,26 +1917,26 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line, processOutput.DecodeText(data, length, strdata, 1); // Append to the stdout buffer. std::vector::size_type size = out.size(); - out.insert(out.end(), strdata.begin(), strdata.end()); + cmAppend(out, strdata); outiter = out.begin() + size; } else if (pipe == cmsysProcess_Pipe_STDERR) { processOutput.DecodeText(data, length, strdata, 2); // Append to the stderr buffer. std::vector::size_type size = err.size(); - err.insert(err.end(), strdata.begin(), strdata.end()); + cmAppend(err, strdata); erriter = err.begin() + size; } else if (pipe == cmsysProcess_Pipe_None) { // Both stdout and stderr pipes have broken. Return leftover data. processOutput.DecodeText(std::string(), strdata, 1); if (!strdata.empty()) { std::vector::size_type size = out.size(); - out.insert(out.end(), strdata.begin(), strdata.end()); + cmAppend(out, strdata); outiter = out.begin() + size; } processOutput.DecodeText(std::string(), strdata, 2); if (!strdata.empty()) { std::vector::size_type size = err.size(); - err.insert(err.end(), strdata.begin(), strdata.end()); + cmAppend(err, strdata); erriter = err.begin() + size; } if (!out.empty()) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8b41e28..cd67586 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -34,13 +34,6 @@ #include "cmTargetPropertyComputer.h" #include "cmake.h" -//! Append all elements from the second container to the first container -template -static inline void CApp(C& container, R const& range) -{ - container.insert(container.end(), range.begin(), range.end()); -} - template <> const char* cmTargetPropertyComputer::ComputeLocationForBuild( cmTarget const* tgt) @@ -406,29 +399,30 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, if (!this->IsImported()) { // Initialize the INCLUDE_DIRECTORIES property based on the current value // of the same directory property: - CApp(impl->IncludeDirectoriesEntries, - impl->Makefile->GetIncludeDirectoriesEntries()); - CApp(impl->IncludeDirectoriesBacktraces, - impl->Makefile->GetIncludeDirectoriesBacktraces()); + cmAppend(impl->IncludeDirectoriesEntries, + impl->Makefile->GetIncludeDirectoriesEntries()); + cmAppend(impl->IncludeDirectoriesBacktraces, + impl->Makefile->GetIncludeDirectoriesBacktraces()); { auto const& sysInc = impl->Makefile->GetSystemIncludeDirectories(); impl->SystemIncludeDirectories.insert(sysInc.begin(), sysInc.end()); } - CApp(impl->CompileOptionsEntries, - impl->Makefile->GetCompileOptionsEntries()); - CApp(impl->CompileOptionsBacktraces, - impl->Makefile->GetCompileOptionsBacktraces()); + cmAppend(impl->CompileOptionsEntries, + impl->Makefile->GetCompileOptionsEntries()); + cmAppend(impl->CompileOptionsBacktraces, + impl->Makefile->GetCompileOptionsBacktraces()); - CApp(impl->LinkOptionsEntries, impl->Makefile->GetLinkOptionsEntries()); - CApp(impl->LinkOptionsBacktraces, - impl->Makefile->GetLinkOptionsBacktraces()); + cmAppend(impl->LinkOptionsEntries, + impl->Makefile->GetLinkOptionsEntries()); + cmAppend(impl->LinkOptionsBacktraces, + impl->Makefile->GetLinkOptionsBacktraces()); - CApp(impl->LinkDirectoriesEntries, - impl->Makefile->GetLinkDirectoriesEntries()); - CApp(impl->LinkDirectoriesBacktraces, - impl->Makefile->GetLinkDirectoriesBacktraces()); + cmAppend(impl->LinkDirectoriesEntries, + impl->Makefile->GetLinkDirectoriesEntries()); + cmAppend(impl->LinkDirectoriesBacktraces, + impl->Makefile->GetLinkDirectoriesBacktraces()); } if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 0762ae1..f0b53f4 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1045,10 +1045,7 @@ void cmake::GetRegisteredGenerators(std::vector& generators, std::vector names = gen->GetGeneratorNames(); if (includeNamesWithPlatform) { - std::vector namesWithPlatform = - gen->GetGeneratorNamesWithPlatform(); - names.insert(names.end(), namesWithPlatform.begin(), - namesWithPlatform.end()); + cmAppend(names, gen->GetGeneratorNamesWithPlatform()); } for (std::string const& name : names) { diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index e639c66..64026ca 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -122,7 +122,7 @@ static int do_command(int ac, char const* const* av) std::vector args; args.reserve(ac - 1); args.emplace_back(av[0]); - args.insert(args.end(), av + 2, av + ac); + cmAppend(args, av + 2, av + ac); return cmcmd::ExecuteCMakeCommand(args); } diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 3c75957..ad34107 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -173,7 +173,7 @@ static int HandleIWYU(const std::string& runCmd, // and adding all the arguments we give to the compiler. std::vector iwyu_cmd; cmSystemTools::ExpandListArgument(runCmd, iwyu_cmd, true); - iwyu_cmd.insert(iwyu_cmd.end(), orig_cmd.begin() + 1, orig_cmd.end()); + cmAppend(iwyu_cmd, orig_cmd.begin() + 1, orig_cmd.end()); // Run the iwyu command line. Capture its stderr and hide its stdout. // Ignore its return code because the tool always returns non-zero. std::string stdErr; @@ -201,11 +201,11 @@ static int HandleTidy(const std::string& runCmd, const std::string& sourceFile, // automatically skip over the compiler itself and extract the // options. int ret; - std::vector tidy_cmd; - cmSystemTools::ExpandListArgument(runCmd, tidy_cmd, true); + std::vector tidy_cmd = + cmSystemTools::ExpandedListArgument(runCmd, true); tidy_cmd.push_back(sourceFile); tidy_cmd.emplace_back("--"); - tidy_cmd.insert(tidy_cmd.end(), orig_cmd.begin(), orig_cmd.end()); + cmAppend(tidy_cmd, orig_cmd); // Run the tidy command line. Capture its stdout and hide its stderr. std::string stdOut; @@ -1919,8 +1919,7 @@ int cmVSLink::RunMT(std::string const& out, bool notify) if (this->LinkGeneratesManifest) { mtCommand.push_back(this->LinkerManifestFile); } - mtCommand.insert(mtCommand.end(), this->UserManifests.begin(), - this->UserManifests.end()); + cmAppend(mtCommand, this->UserManifests); mtCommand.push_back(out); if (notify) { // Add an undocumented option that enables a special return -- cgit v0.12