diff options
author | Pavel Solodovnikov <hellyeahdominate@gmail.com> | 2017-05-24 20:18:28 (GMT) |
---|---|---|
committer | Pavel Solodovnikov <hellyeahdominate@gmail.com> | 2017-05-26 16:50:11 (GMT) |
commit | 86dc86dd6c66a6d61234efcddddddf466a6597d2 (patch) | |
tree | f7fcf0d9852d4d66b362a9c0fba67fd9d42661e8 | |
parent | 76bdb4076277cda0e68e1d80cdf715020eab5a7a (diff) | |
download | CMake-86dc86dd6c66a6d61234efcddddddf466a6597d2.zip CMake-86dc86dd6c66a6d61234efcddddddf466a6597d2.tar.gz CMake-86dc86dd6c66a6d61234efcddddddf466a6597d2.tar.bz2 |
Add const-reference qualifications
39 files changed, 121 insertions, 114 deletions
diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx index 0d01493..5db6e09 100644 --- a/Source/cmAddCustomTargetCommand.cxx +++ b/Source/cmAddCustomTargetCommand.cxx @@ -24,7 +24,7 @@ bool cmAddCustomTargetCommand::InitialPass( return false; } - std::string targetName = args[0]; + std::string const& targetName = args[0]; // Check the target name. if (targetName.find_first_of("/\\") != targetName.npos) { diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx index e49d5d5..a73b57e 100644 --- a/Source/cmAddDependenciesCommand.cxx +++ b/Source/cmAddDependenciesCommand.cxx @@ -19,7 +19,7 @@ bool cmAddDependenciesCommand::InitialPass( return false; } - std::string target_name = args[0]; + std::string const& target_name = args[0]; if (this->Makefile->IsAlias(target_name)) { std::ostringstream e; e << "Cannot add target-level dependencies to alias target \"" diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index aae1085..1d0376f 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -24,7 +24,7 @@ bool cmAddExecutableCommand::InitialPass(std::vector<std::string> const& args, } std::vector<std::string>::const_iterator s = args.begin(); - std::string exename = *s; + std::string const& exename = *s; ++s; bool use_win32 = false; diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index 0bdf963..ebf1763 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -37,7 +37,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args, std::vector<std::string>::const_iterator s = args.begin(); - std::string libName = *s; + std::string const& libName = *s; ++s; diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx index dbd4dd1..1727ca5 100644 --- a/Source/cmAddSubDirectoryCommand.cxx +++ b/Source/cmAddSubDirectoryCommand.cxx @@ -20,7 +20,7 @@ bool cmAddSubDirectoryCommand::InitialPass( } // store the binpath - std::string srcArg = args[0]; + std::string const& srcArg = args[0]; std::string binArg; bool excludeFromAll = false; diff --git a/Source/cmAuxSourceDirectoryCommand.cxx b/Source/cmAuxSourceDirectoryCommand.cxx index c92c47b..8e34cb1 100644 --- a/Source/cmAuxSourceDirectoryCommand.cxx +++ b/Source/cmAuxSourceDirectoryCommand.cxx @@ -24,7 +24,7 @@ bool cmAuxSourceDirectoryCommand::InitialPass( } std::string sourceListValue; - std::string templateDirectory = args[0]; + std::string const& templateDirectory = args[0]; std::string tdir; if (!cmSystemTools::FileIsFullPath(templateDirectory.c_str())) { tdir = this->Makefile->GetCurrentSourceDirectory(); @@ -54,7 +54,7 @@ bool cmAuxSourceDirectoryCommand::InitialPass( std::string ext = file.substr(dotpos + 1); std::string base = file.substr(0, dotpos); // Process only source files - std::vector<std::string> srcExts = + std::vector<std::string> const& srcExts = this->Makefile->GetCMakeInstance()->GetSourceExtensions(); if (!base.empty() && std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end()) { diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx index 6836151..fd87600 100644 --- a/Source/cmBuildCommand.cxx +++ b/Source/cmBuildCommand.cxx @@ -32,7 +32,7 @@ bool cmBuildCommand::MainSignature(std::vector<std::string> const& args) } // The cmake variable in which to store the result. - const char* variable = args[0].c_str(); + std::string const& variable = args[0]; // Parse remaining arguments. std::string configuration; @@ -104,7 +104,7 @@ bool cmBuildCommand::TwoArgsSignature(std::vector<std::string> const& args) return false; } - const char* define = args[0].c_str(); + std::string const& define = args[0]; const char* cacheValue = this->Makefile->GetDefinition(define); std::string configType; diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx index e135ac6..4475c5a 100644 --- a/Source/cmCMakeHostSystemInformationCommand.cxx +++ b/Source/cmCMakeHostSystemInformationCommand.cxx @@ -26,7 +26,7 @@ bool cmCMakeHostSystemInformationCommand::InitialPass( return false; } - std::string variable = args[current_index + 1]; + std::string const& variable = args[current_index + 1]; current_index += 2; if (args.size() < (current_index + 2) || args[current_index] != "QUERY") { @@ -41,7 +41,7 @@ bool cmCMakeHostSystemInformationCommand::InitialPass( std::string result_list; for (size_t i = current_index + 1; i < args.size(); ++i) { - std::string key = args[i]; + std::string const& key = args[i]; if (i != current_index + 1) { result_list += ";"; } diff --git a/Source/cmConfigureFileCommand.cxx b/Source/cmConfigureFileCommand.cxx index b9c7549..18005f2 100644 --- a/Source/cmConfigureFileCommand.cxx +++ b/Source/cmConfigureFileCommand.cxx @@ -19,7 +19,7 @@ bool cmConfigureFileCommand::InitialPass(std::vector<std::string> const& args, return false; } - const char* inFile = args[0].c_str(); + std::string const& inFile = args[0]; if (!cmSystemTools::FileIsFullPath(inFile)) { this->InputFile = this->Makefile->GetCurrentSourceDirectory(); this->InputFile += "/"; @@ -38,7 +38,7 @@ bool cmConfigureFileCommand::InitialPass(std::vector<std::string> const& args, return false; } - const char* outFile = args[1].c_str(); + std::string const& outFile = args[1]; if (!cmSystemTools::FileIsFullPath(outFile)) { this->OutputFile = this->Makefile->GetCurrentBinaryDirectory(); this->OutputFile += "/"; diff --git a/Source/cmDefinePropertyCommand.cxx b/Source/cmDefinePropertyCommand.cxx index 9a097f3..86a83da 100644 --- a/Source/cmDefinePropertyCommand.cxx +++ b/Source/cmDefinePropertyCommand.cxx @@ -20,23 +20,25 @@ bool cmDefinePropertyCommand::InitialPass(std::vector<std::string> const& args, // Get the scope in which to define the property. cmProperty::ScopeType scope; - if (args[0] == "GLOBAL") { + std::string const& scope_arg = args[0]; + + if (scope_arg == "GLOBAL") { scope = cmProperty::GLOBAL; - } else if (args[0] == "DIRECTORY") { + } else if (scope_arg == "DIRECTORY") { scope = cmProperty::DIRECTORY; - } else if (args[0] == "TARGET") { + } else if (scope_arg == "TARGET") { scope = cmProperty::TARGET; - } else if (args[0] == "SOURCE") { + } else if (scope_arg == "SOURCE") { scope = cmProperty::SOURCE_FILE; - } else if (args[0] == "TEST") { + } else if (scope_arg == "TEST") { scope = cmProperty::TEST; - } else if (args[0] == "VARIABLE") { + } else if (scope_arg == "VARIABLE") { scope = cmProperty::VARIABLE; - } else if (args[0] == "CACHED_VARIABLE") { + } else if (scope_arg == "CACHED_VARIABLE") { scope = cmProperty::CACHED_VARIABLE; } else { std::ostringstream e; - e << "given invalid scope " << args[0] << ". " + e << "given invalid scope " << scope_arg << ". " << "Valid scopes are " << "GLOBAL, DIRECTORY, TARGET, SOURCE, " << "TEST, VARIABLE, CACHED_VARIABLE."; diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 2dffcaa..5b7b827 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -353,7 +353,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( all_files_map_t allFiles; std::vector<std::string> cFiles; - std::vector<std::string> srcExts = + std::vector<std::string> const& srcExts = this->GlobalGenerator->GetCMakeInstance()->GetSourceExtensions(); for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin(); @@ -387,7 +387,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( bool isCFile = false; std::string lang = (*si)->GetLanguage(); if (lang == "C" || lang == "CXX") { - std::string srcext = (*si)->GetExtension(); + std::string const& srcext = (*si)->GetExtension(); for (std::vector<std::string>::const_iterator ext = srcExts.begin(); ext != srcExts.end(); ++ext) { @@ -398,7 +398,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( } } - std::string fullPath = (*si)->GetFullPath(); + std::string const& fullPath = (*si)->GetFullPath(); if (isCFile) { cFiles.push_back(fullPath); @@ -414,7 +414,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( } } - std::vector<std::string> headerExts = + std::vector<std::string> const& headerExts = this->GlobalGenerator->GetCMakeInstance()->GetHeaderExtensions(); // The following loop tries to add header files matching to implementation diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index 98eebe6..ea5379a 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -240,7 +240,7 @@ std::string cmExtraCodeLiteGenerator::CollectSourceFiles( bool isCFile = false; std::string lang = (*si)->GetLanguage(); if (lang == "C" || lang == "CXX") { - std::string srcext = (*si)->GetExtension(); + std::string const& srcext = (*si)->GetExtension(); for (std::vector<std::string>::const_iterator ext = srcExts.begin(); ext != srcExts.end(); ++ext) { if (srcext == *ext) { diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 8d1adc7..2a6ce98 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -453,7 +453,7 @@ void cmExtraEclipseCDT4Generator::WriteGroups( for (std::vector<const cmSourceFile*>::const_iterator fileIt = sFiles.begin(); fileIt != sFiles.end(); ++fileIt) { - std::string fullPath = (*fileIt)->GetFullPath(); + std::string const& fullPath = (*fileIt)->GetFullPath(); if (!cmSystemTools::FileIsDirectory(fullPath)) { std::string linkName4 = linkName3; @@ -508,7 +508,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets(cmXMLWriter& xml) for (std::vector<cmSourceFile*>::const_iterator sfIt = files.begin(); sfIt != files.end(); sfIt++) { // Add the file to the list of sources. - std::string source = (*sfIt)->GetFullPath(); + std::string const& source = (*sfIt)->GetFullPath(); cmSourceGroup* sourceGroup = makefile->FindSourceGroup(source.c_str(), sourceGroups); sourceGroup->AssignSource(*sfIt); diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index ff6e2b7..32a539c 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -110,7 +110,7 @@ bool cmFileCommand::InitialPass(std::vector<std::string> const& args, this->SetError("must be called with at least two arguments."); return false; } - std::string subCommand = args[0]; + std::string const& subCommand = args[0]; if (subCommand == "WRITE") { return this->HandleWriteCommand(args, false); } diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 6f6a3f6..fd67d6c 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -924,7 +924,7 @@ bool cmFindPackageCommand::FindConfig() bool cmFindPackageCommand::FindPrefixedConfig() { - std::vector<std::string>& prefixes = this->SearchPaths; + std::vector<std::string> const& prefixes = this->SearchPaths; for (std::vector<std::string>::const_iterator pi = prefixes.begin(); pi != prefixes.end(); ++pi) { if (this->SearchPrefix(*pi)) { @@ -936,7 +936,7 @@ bool cmFindPackageCommand::FindPrefixedConfig() bool cmFindPackageCommand::FindFrameworkConfig() { - std::vector<std::string>& prefixes = this->SearchPaths; + std::vector<std::string> const& prefixes = this->SearchPaths; for (std::vector<std::string>::const_iterator i = prefixes.begin(); i != prefixes.end(); ++i) { if (this->SearchFrameworkPrefix(*i)) { @@ -948,7 +948,7 @@ bool cmFindPackageCommand::FindFrameworkConfig() bool cmFindPackageCommand::FindAppBundleConfig() { - std::vector<std::string>& prefixes = this->SearchPaths; + std::vector<std::string> const& prefixes = this->SearchPaths; for (std::vector<std::string>::const_iterator i = prefixes.begin(); i != prefixes.end(); ++i) { if (this->SearchAppBundlePrefix(*i)) { diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx index 7962da6..5ba3326 100644 --- a/Source/cmGetCMakePropertyCommand.cxx +++ b/Source/cmGetCMakePropertyCommand.cxx @@ -20,7 +20,7 @@ bool cmGetCMakePropertyCommand::InitialPass( return false; } - std::string variable = args[0]; + std::string const& variable = args[0]; std::string output = "NOTFOUND"; if (args[1] == "VARIABLES") { diff --git a/Source/cmGetDirectoryPropertyCommand.cxx b/Source/cmGetDirectoryPropertyCommand.cxx index 920e1a0..6cb8e19 100644 --- a/Source/cmGetDirectoryPropertyCommand.cxx +++ b/Source/cmGetDirectoryPropertyCommand.cxx @@ -20,7 +20,7 @@ bool cmGetDirectoryPropertyCommand::InitialPass( } std::vector<std::string>::const_iterator i = args.begin(); - std::string variable = *i; + std::string const& variable = *i; ++i; // get the directory argument if there is one diff --git a/Source/cmGetSourceFilePropertyCommand.cxx b/Source/cmGetSourceFilePropertyCommand.cxx index 509ef95..1a5f08e 100644 --- a/Source/cmGetSourceFilePropertyCommand.cxx +++ b/Source/cmGetSourceFilePropertyCommand.cxx @@ -15,8 +15,8 @@ bool cmGetSourceFilePropertyCommand::InitialPass( this->SetError("called with incorrect number of arguments"); return false; } - const char* var = args[0].c_str(); - const char* file = args[1].c_str(); + std::string const& var = args[0]; + std::string const& file = args[1]; cmSourceFile* sf = this->Makefile->GetSource(file); // for the location we must create a source file first diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx index 2379292..0910a53 100644 --- a/Source/cmGetTargetPropertyCommand.cxx +++ b/Source/cmGetTargetPropertyCommand.cxx @@ -22,8 +22,8 @@ bool cmGetTargetPropertyCommand::InitialPass( this->SetError("called with incorrect number of arguments"); return false; } - std::string var = args[0]; - const std::string& targetName = args[1]; + std::string const& var = args[0]; + std::string const& targetName = args[1]; std::string prop; bool prop_exists = false; diff --git a/Source/cmGetTestPropertyCommand.cxx b/Source/cmGetTestPropertyCommand.cxx index a8a44b7..6424515 100644 --- a/Source/cmGetTestPropertyCommand.cxx +++ b/Source/cmGetTestPropertyCommand.cxx @@ -16,8 +16,8 @@ bool cmGetTestPropertyCommand::InitialPass( return false; } - std::string testName = args[0]; - std::string var = args[2]; + std::string const& testName = args[0]; + std::string const& var = args[2]; cmTest* test = this->Makefile->GetTest(testName); if (test) { const char* prop = CM_NULLPTR; diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index a958a17..e72c6e3 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -101,7 +101,7 @@ bool cmGlobalKdevelopGenerator::CreateFilelistFile( std::set<std::string> files; std::string tmp; - std::vector<std::string> hdrExts = + std::vector<std::string> const& hdrExts = this->GlobalGenerator->GetCMakeInstance()->GetHeaderExtensions(); for (std::vector<cmLocalGenerator*>::const_iterator it = lgs.begin(); diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index ba554aa..93e467c 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -75,29 +75,31 @@ bool cmInstallCommand::InitialPass(std::vector<std::string> const& args, this->DefaultComponentName = "Unspecified"; } + std::string const& mode = args[0]; + // Switch among the command modes. - if (args[0] == "SCRIPT") { + if (mode == "SCRIPT") { return this->HandleScriptMode(args); } - if (args[0] == "CODE") { + if (mode == "CODE") { return this->HandleScriptMode(args); } - if (args[0] == "TARGETS") { + if (mode == "TARGETS") { return this->HandleTargetsMode(args); } - if (args[0] == "FILES") { + if (mode == "FILES") { return this->HandleFilesMode(args); } - if (args[0] == "PROGRAMS") { + if (mode == "PROGRAMS") { return this->HandleFilesMode(args); } - if (args[0] == "DIRECTORY") { + if (mode == "DIRECTORY") { return this->HandleDirectoryMode(args); } - if (args[0] == "EXPORT") { + if (mode == "EXPORT") { return this->HandleExportMode(args); } - if (args[0] == "EXPORT_ANDROID_MK") { + if (mode == "EXPORT_ANDROID_MK") { return this->HandleExportAndroidMKMode(args); } @@ -165,7 +167,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) script.c_str(), false, component.c_str(), exclude_from_all)); } else if (doing_code) { doing_code = false; - std::string code = args[i]; + std::string const& code = args[i]; this->Makefile->AddInstallGenerator(new cmInstallScriptGenerator( code.c_str(), true, component.c_str(), exclude_from_all)); } diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index 86fd46d..4a3b620 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -54,7 +54,7 @@ void cmInstallFilesCommand::FinalPass() } std::string testf; - std::string ext = this->FinalArgs[0]; + std::string const& ext = this->FinalArgs[0]; // two different options if (this->FinalArgs.size() > 1) { @@ -64,7 +64,7 @@ void cmInstallFilesCommand::FinalPass() // for each argument, get the files for (; s != this->FinalArgs.end(); ++s) { // replace any variables - std::string temps = *s; + std::string const& temps = *s; if (!cmSystemTools::GetFilenamePath(temps).empty()) { testf = cmSystemTools::GetFilenamePath(temps) + "/" + cmSystemTools::GetFilenameWithoutLastExtension(temps) + ext; @@ -78,7 +78,7 @@ void cmInstallFilesCommand::FinalPass() } else // reg exp list { std::vector<std::string> files; - std::string regex = this->FinalArgs[0]; + std::string const& regex = this->FinalArgs[0]; cmSystemTools::Glob(this->Makefile->GetCurrentSourceDirectory(), regex, files); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 307024a..e48378d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2258,7 +2258,7 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget( { // Construct the object file name using the full path to the source // file which is its only unique identification. - const char* fullPath = source.GetFullPath().c_str(); + std::string const& fullPath = source.GetFullPath(); // Try referencing the source relative to the source tree. std::string relFromSource = diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index a8350b3..266710c 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -213,7 +213,7 @@ void cmLocalNinjaGenerator::WritePools(std::ostream& os) std::vector<std::string> pools; cmSystemTools::ExpandListArgument(jobpools, pools); for (size_t i = 0; i < pools.size(); ++i) { - const std::string pool = pools[i]; + std::string const& pool = pools[i]; const std::string::size_type eq = pool.find('='); unsigned int jobs; if (eq != std::string::npos && diff --git a/Source/cmMarkAsAdvancedCommand.cxx b/Source/cmMarkAsAdvancedCommand.cxx index b2f0d22..14fd96f 100644 --- a/Source/cmMarkAsAdvancedCommand.cxx +++ b/Source/cmMarkAsAdvancedCommand.cxx @@ -30,7 +30,7 @@ bool cmMarkAsAdvancedCommand::InitialPass(std::vector<std::string> const& args, i = 1; } for (; i < args.size(); ++i) { - std::string variable = args[i]; + std::string const& variable = args[i]; cmState* state = this->Makefile->GetState(); if (!state->GetCacheEntryValue(variable)) { this->Makefile->GetCMakeInstance()->AddCacheEntry( diff --git a/Source/cmNewLineStyle.cxx b/Source/cmNewLineStyle.cxx index 55451ff..5500eba 100644 --- a/Source/cmNewLineStyle.cxx +++ b/Source/cmNewLineStyle.cxx @@ -23,7 +23,7 @@ bool cmNewLineStyle::ReadFromArguments(const std::vector<std::string>& args, if (args[i] == "NEWLINE_STYLE") { size_t const styleIndex = i + 1; if (args.size() > styleIndex) { - const std::string eol = args[styleIndex]; + std::string const& eol = args[styleIndex]; if (eol == "LF" || eol == "UNIX") { NewLineStyle = LF; return true; diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index d47a047..d72c790 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -22,11 +22,14 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args, this->SetError("PROJECT called with incorrect number of arguments"); return false; } - this->Makefile->SetProjectName(args[0]); - std::string bindir = args[0]; + std::string const& projectName = args[0]; + + this->Makefile->SetProjectName(projectName); + + std::string bindir = projectName; bindir += "_BINARY_DIR"; - std::string srcdir = args[0]; + std::string srcdir = projectName; srcdir += "_SOURCE_DIR"; this->Makefile->AddCacheDefinition( @@ -44,7 +47,7 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args, this->Makefile->AddDefinition(srcdir, this->Makefile->GetCurrentSourceDirectory()); - this->Makefile->AddDefinition("PROJECT_NAME", args[0].c_str()); + this->Makefile->AddDefinition("PROJECT_NAME", projectName.c_str()); // Set the CMAKE_PROJECT_NAME variable to be the highest-level // project name in the tree. If there are two project commands @@ -54,10 +57,10 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args, // will work. if (!this->Makefile->GetDefinition("CMAKE_PROJECT_NAME") || (this->Makefile->IsRootMakefile())) { - this->Makefile->AddDefinition("CMAKE_PROJECT_NAME", args[0].c_str()); - this->Makefile->AddCacheDefinition("CMAKE_PROJECT_NAME", args[0].c_str(), - "Value Computed by CMake", - cmStateEnums::STATIC); + this->Makefile->AddDefinition("CMAKE_PROJECT_NAME", projectName.c_str()); + this->Makefile->AddCacheDefinition( + "CMAKE_PROJECT_NAME", projectName.c_str(), "Value Computed by CMake", + cmStateEnums::STATIC); } bool haveVersion = false; @@ -163,19 +166,19 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args, } std::string vv; - vv = args[0] + "_VERSION"; + vv = projectName + "_VERSION"; this->Makefile->AddDefinition("PROJECT_VERSION", vs.c_str()); this->Makefile->AddDefinition(vv, vs.c_str()); - vv = args[0] + "_VERSION_MAJOR"; + vv = projectName + "_VERSION_MAJOR"; this->Makefile->AddDefinition("PROJECT_VERSION_MAJOR", vb[0]); this->Makefile->AddDefinition(vv, vb[0]); - vv = args[0] + "_VERSION_MINOR"; + vv = projectName + "_VERSION_MINOR"; this->Makefile->AddDefinition("PROJECT_VERSION_MINOR", vb[1]); this->Makefile->AddDefinition(vv, vb[1]); - vv = args[0] + "_VERSION_PATCH"; + vv = projectName + "_VERSION_PATCH"; this->Makefile->AddDefinition("PROJECT_VERSION_PATCH", vb[2]); this->Makefile->AddDefinition(vv, vb[2]); - vv = args[0] + "_VERSION_TWEAK"; + vv = projectName + "_VERSION_TWEAK"; this->Makefile->AddDefinition("PROJECT_VERSION_TWEAK", vb[3]); this->Makefile->AddDefinition(vv, vb[3]); } else if (cmp0048 != cmPolicies::OLD) { @@ -186,11 +189,11 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args, vv.push_back("PROJECT_VERSION_MINOR"); vv.push_back("PROJECT_VERSION_PATCH"); vv.push_back("PROJECT_VERSION_TWEAK"); - vv.push_back(args[0] + "_VERSION"); - vv.push_back(args[0] + "_VERSION_MAJOR"); - vv.push_back(args[0] + "_VERSION_MINOR"); - vv.push_back(args[0] + "_VERSION_PATCH"); - vv.push_back(args[0] + "_VERSION_TWEAK"); + vv.push_back(projectName + "_VERSION"); + vv.push_back(projectName + "_VERSION_MAJOR"); + vv.push_back(projectName + "_VERSION_MINOR"); + vv.push_back(projectName + "_VERSION_PATCH"); + vv.push_back(projectName + "_VERSION_TWEAK"); std::string vw; for (std::vector<std::string>::iterator i = vv.begin(); i != vv.end(); ++i) { @@ -234,7 +237,7 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args, languages.push_back("CXX"); } this->Makefile->EnableLanguage(languages, false); - std::string extraInclude = "CMAKE_PROJECT_" + args[0] + "_INCLUDE"; + std::string extraInclude = "CMAKE_PROJECT_" + projectName + "_INCLUDE"; const char* include = this->Makefile->GetDefinition(extraInclude); if (include) { bool readit = this->Makefile->ReadDependentFile(include); diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index 239b18d..cf90f91 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -755,7 +755,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( fileIt != srcFiles.end(); ++fileIt) { cmSourceFile* sf = *fileIt; if (!PropertyEnabled(sf, "SKIP_AUTOGEN")) { - const std::string ext = sf->GetExtension(); + std::string const& ext = sf->GetExtension(); // Add generated file that will be scanned by moc or uic to // the dependencies if (mocEnabled || uicEnabled) { diff --git a/Source/cmRemoveCommand.cxx b/Source/cmRemoveCommand.cxx index 5a52927..1db8441 100644 --- a/Source/cmRemoveCommand.cxx +++ b/Source/cmRemoveCommand.cxx @@ -15,7 +15,7 @@ bool cmRemoveCommand::InitialPass(std::vector<std::string> const& args, return true; } - const char* variable = args[0].c_str(); // VAR is always first + std::string const& variable = args[0]; // VAR is always first // get the old value const char* cacheValue = this->Makefile->GetDefinition(variable); diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index 60c198a..b57f62a 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -138,7 +138,7 @@ bool cmSetPropertyCommand::HandleGlobalMode() // Set or append the property. cmake* cm = this->Makefile->GetCMakeInstance(); - const char* name = this->PropertyName.c_str(); + std::string const& name = this->PropertyName; const char* value = this->PropertyValue.c_str(); if (this->Remove) { value = CM_NULLPTR; @@ -188,7 +188,7 @@ bool cmSetPropertyCommand::HandleDirectoryMode() } // Set or append the property. - const char* name = this->PropertyName.c_str(); + std::string const& name = this->PropertyName; const char* value = this->PropertyValue.c_str(); if (this->Remove) { value = CM_NULLPTR; @@ -229,7 +229,7 @@ bool cmSetPropertyCommand::HandleTargetMode() bool cmSetPropertyCommand::HandleTarget(cmTarget* target) { // Set or append the property. - const char* name = this->PropertyName.c_str(); + std::string const& name = this->PropertyName; const char* value = this->PropertyValue.c_str(); if (this->Remove) { value = CM_NULLPTR; @@ -268,7 +268,7 @@ bool cmSetPropertyCommand::HandleSourceMode() bool cmSetPropertyCommand::HandleSource(cmSourceFile* sf) { // Set or append the property. - const char* name = this->PropertyName.c_str(); + std::string const& name = this->PropertyName; const char* value = this->PropertyValue.c_str(); if (this->Remove) { value = CM_NULLPTR; @@ -316,7 +316,7 @@ bool cmSetPropertyCommand::HandleTestMode() bool cmSetPropertyCommand::HandleTest(cmTest* test) { // Set or append the property. - const char* name = this->PropertyName.c_str(); + std::string const& name = this->PropertyName; const char* value = this->PropertyValue.c_str(); if (this->Remove) { value = CM_NULLPTR; @@ -383,7 +383,7 @@ bool cmSetPropertyCommand::HandleCacheMode() bool cmSetPropertyCommand::HandleCacheEntry(std::string const& cacheKey) { // Set or append the property. - const char* name = this->PropertyName.c_str(); + std::string const& name = this->PropertyName; const char* value = this->PropertyValue.c_str(); cmState* state = this->Makefile->GetState(); if (this->Remove) { diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index d6907e3..7a097ba 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -128,7 +128,7 @@ bool cmStringCommand::HandleToUpperLowerCommand( return false; } - std::string outvar = args[2]; + std::string const& outvar = args[2]; std::string output; if (toUpper) { @@ -149,7 +149,7 @@ bool cmStringCommand::HandleAsciiCommand(std::vector<std::string> const& args) return false; } std::string::size_type cc; - std::string outvar = args[args.size() - 1]; + std::string const& outvar = args[args.size() - 1]; std::string output; for (cc = 1; cc < args.size() - 1; cc++) { int ch = atoi(args[cc].c_str()); @@ -212,7 +212,7 @@ bool cmStringCommand::HandleRegexCommand(std::vector<std::string> const& args) this->SetError("sub-command REGEX requires a mode to be specified."); return false; } - std::string mode = args[1]; + std::string const& mode = args[1]; if (mode == "MATCH") { if (args.size() < 5) { this->SetError("sub-command REGEX, mode MATCH needs " @@ -247,8 +247,8 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args) { //"STRING(REGEX MATCH <regular_expression> <output variable> // <input> [<input>...])\n"; - std::string regex = args[2]; - std::string outvar = args[3]; + std::string const& regex = args[2]; + std::string const& outvar = args[3]; this->Makefile->ClearMatches(); // Compile the regular expression. @@ -288,8 +288,8 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args) { //"STRING(REGEX MATCHALL <regular_expression> <output variable> <input> // [<input>...])\n"; - std::string regex = args[2]; - std::string outvar = args[3]; + std::string const& regex = args[2]; + std::string const& outvar = args[3]; this->Makefile->ClearMatches(); // Compile the regular expression. @@ -334,9 +334,9 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args) { //"STRING(REGEX REPLACE <regular_expression> <replace_expression> // <output variable> <input> [<input>...])\n" - std::string regex = args[2]; - std::string replace = args[3]; - std::string outvar = args[4]; + std::string const& regex = args[2]; + std::string const& replace = args[3]; + std::string const& outvar = args[4]; // Pull apart the replace expression to find the escaped [0-9] values. std::vector<RegexReplacement> replacement; @@ -502,7 +502,7 @@ bool cmStringCommand::HandleCompareCommand( this->SetError("sub-command COMPARE requires a mode to be specified."); return false; } - std::string mode = args[1]; + std::string const& mode = args[1]; if ((mode == "EQUAL") || (mode == "NOTEQUAL") || (mode == "LESS") || (mode == "LESS_EQUAL") || (mode == "GREATER") || (mode == "GREATER_EQUAL")) { diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index 9a5c1da..45fe430 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -78,7 +78,7 @@ bool cmTargetPropCommandBase::ProcessContentArgs( std::vector<std::string> const& args, unsigned int& argIndex, bool prepend, bool system) { - const std::string scope = args[argIndex]; + std::string const& scope = args[argIndex]; if (scope != "PUBLIC" && scope != "PRIVATE" && scope != "INTERFACE") { this->SetError("called with invalid arguments"); diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx index 37d8bfb..eabd7ef 100644 --- a/Source/cmUtilitySourceCommand.cxx +++ b/Source/cmUtilitySourceCommand.cxx @@ -23,7 +23,7 @@ bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args, std::vector<std::string>::const_iterator arg = args.begin(); // The first argument is the cache entry name. - std::string cacheEntry = *arg++; + std::string const& cacheEntry = *arg++; const char* cacheValue = this->Makefile->GetDefinition(cacheEntry); // If it exists already and appears up to date then we are done. If // the string contains "(IntDir)" but that is not the @@ -57,11 +57,11 @@ bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args, // The second argument is the utility's executable name, which will be // needed later. - std::string utilityName = *arg++; + std::string const& utilityName = *arg++; // The third argument specifies the relative directory of the source // of the utility. - std::string relativeSource = *arg++; + std::string const& relativeSource = *arg++; std::string utilitySource = this->Makefile->GetCurrentSourceDirectory(); utilitySource = utilitySource + "/" + relativeSource; diff --git a/Source/cmVariableRequiresCommand.cxx b/Source/cmVariableRequiresCommand.cxx index 10b0a88..06ca53c 100644 --- a/Source/cmVariableRequiresCommand.cxx +++ b/Source/cmVariableRequiresCommand.cxx @@ -17,11 +17,11 @@ bool cmVariableRequiresCommand::InitialPass( return false; } - std::string testVariable = args[0]; + std::string const& testVariable = args[0]; if (!this->Makefile->IsOn(testVariable)) { return true; } - std::string resultVariable = args[1]; + std::string const& resultVariable = args[1]; bool requirementsMet = true; std::string notSet; bool hasAdvanced = false; diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx index 90b0b28..281850e 100644 --- a/Source/cmVariableWatchCommand.cxx +++ b/Source/cmVariableWatchCommand.cxx @@ -106,7 +106,7 @@ bool cmVariableWatchCommand::InitialPass(std::vector<std::string> const& args, this->SetError("must be called with at least one argument."); return false; } - std::string variable = args[0]; + std::string const& variable = args[0]; std::string command; if (args.size() > 1) { command = args[1]; diff --git a/Source/cmWriteFileCommand.cxx b/Source/cmWriteFileCommand.cxx index f569e80..fc5fd21 100644 --- a/Source/cmWriteFileCommand.cxx +++ b/Source/cmWriteFileCommand.cxx @@ -21,7 +21,7 @@ bool cmWriteFileCommand::InitialPass(std::vector<std::string> const& args, std::string message; std::vector<std::string>::const_iterator i = args.begin(); - std::string fileName = *i; + std::string const& fileName = *i; bool overwrite = true; i++; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 53e9ab0..6894393 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -301,7 +301,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) { bool findPackageMode = false; for (unsigned int i = 1; i < args.size(); ++i) { - std::string arg = args[i]; + std::string const& arg = args[i]; if (arg.find("-D", 0) == 0) { std::string entry = arg.substr(2); if (entry.empty()) { @@ -617,7 +617,7 @@ void cmake::SetArgs(const std::vector<std::string>& args, bool haveToolset = false; bool havePlatform = false; for (unsigned int i = 1; i < args.size(); ++i) { - std::string arg = args[i]; + std::string const& arg = args[i]; if (arg.find("-H", 0) == 0) { directoriesSet = true; std::string path = arg.substr(2); @@ -2146,7 +2146,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) // process the arguments bool writeToStdout = true; for (unsigned int i = 1; i < args.size(); ++i) { - std::string arg = args[i]; + std::string const& arg = args[i]; if (arg.find("-G", 0) == 0) { std::string value = arg.substr(2); if (value.empty()) { diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index dc267e7..9f2e8b7 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -663,7 +663,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // Command to change directory and run a program. if (args[1] == "chdir" && args.size() >= 4) { - std::string directory = args[2]; + std::string const& directory = args[2]; if (!cmSystemTools::FileExists(directory.c_str())) { cmSystemTools::Error("Directory does not exist for chdir command: ", args[2].c_str()); @@ -883,8 +883,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) if (args[1] == "tar" && args.size() > 3) { const char* knownFormats[] = { "7zip", "gnutar", "pax", "paxr", "zip" }; - std::string flags = args[2]; - std::string outFile = args[3]; + std::string const& flags = args[2]; + std::string const& outFile = args[3]; std::vector<std::string> files; std::string mtime; std::string format; @@ -1077,9 +1077,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) int cmcmd::SymlinkLibrary(std::vector<std::string>& args) { int result = 0; - std::string realName = args[2]; - std::string soName = args[3]; - std::string name = args[4]; + std::string const& realName = args[2]; + std::string const& soName = args[3]; + std::string const& name = args[4]; if (soName != realName) { if (!cmcmd::SymlinkInternal(realName, soName)) { cmSystemTools::ReportLastSystemError("cmake_symlink_library"); @@ -1098,8 +1098,8 @@ int cmcmd::SymlinkLibrary(std::vector<std::string>& args) int cmcmd::SymlinkExecutable(std::vector<std::string>& args) { int result = 0; - std::string realName = args[2]; - std::string name = args[3]; + std::string const& realName = args[2]; + std::string const& name = args[3]; if (name != realName) { if (!cmcmd::SymlinkInternal(realName, name)) { cmSystemTools::ReportLastSystemError("cmake_symlink_executable"); |