Переглянути джерело

Merge topic 'reduce-string-copying'

2c2bb5f5 Remove unnecessary operator<< usage
1e4e2f99 Remove unused variables
25486156 Improved checking for number of arguments passed
86dc86dd Add const-reference qualifications
76bdb407 Change std::basic_string<char> to std::string

Acked-by: Kitware Robot <[email protected]>
Merge-request: !886
Brad King 8 роки тому
батько
коміт
f8642f953d
42 змінених файлів з 130 додано та 129 видалено
  1. 1 1
      Source/cmAddCustomTargetCommand.cxx
  2. 1 1
      Source/cmAddDependenciesCommand.cxx
  3. 1 1
      Source/cmAddExecutableCommand.cxx
  4. 1 1
      Source/cmAddLibraryCommand.cxx
  5. 1 1
      Source/cmAddSubDirectoryCommand.cxx
  6. 3 3
      Source/cmAuxSourceDirectoryCommand.cxx
  7. 2 2
      Source/cmBuildCommand.cxx
  8. 2 2
      Source/cmCMakeHostSystemInformationCommand.cxx
  9. 2 2
      Source/cmConfigureFileCommand.cxx
  10. 10 8
      Source/cmDefinePropertyCommand.cxx
  11. 4 4
      Source/cmExtraCodeBlocksGenerator.cxx
  12. 1 4
      Source/cmExtraCodeLiteGenerator.cxx
  13. 2 2
      Source/cmExtraEclipseCDT4Generator.cxx
  14. 1 1
      Source/cmFileCommand.cxx
  15. 3 3
      Source/cmFindPackageCommand.cxx
  16. 1 1
      Source/cmGetCMakePropertyCommand.cxx
  17. 1 1
      Source/cmGetDirectoryPropertyCommand.cxx
  18. 2 2
      Source/cmGetSourceFilePropertyCommand.cxx
  19. 2 2
      Source/cmGetTargetPropertyCommand.cxx
  20. 2 2
      Source/cmGetTestPropertyCommand.cxx
  21. 1 1
      Source/cmGlobalKdevelopGenerator.cxx
  22. 1 1
      Source/cmGlobalNinjaGenerator.cxx
  23. 11 9
      Source/cmInstallCommand.cxx
  24. 3 3
      Source/cmInstallFilesCommand.cxx
  25. 1 1
      Source/cmLocalGenerator.cxx
  26. 1 1
      Source/cmLocalNinjaGenerator.cxx
  27. 1 1
      Source/cmMarkAsAdvancedCommand.cxx
  28. 1 1
      Source/cmNewLineStyle.cxx
  29. 1 3
      Source/cmOSXBundleGenerator.cxx
  30. 22 19
      Source/cmProjectCommand.cxx
  31. 1 1
      Source/cmQtAutoGeneratorInitializer.cxx
  32. 1 1
      Source/cmRemoveCommand.cxx
  33. 6 6
      Source/cmSetPropertyCommand.cxx
  34. 11 11
      Source/cmStringCommand.cxx
  35. 6 7
      Source/cmSystemTools.cxx
  36. 1 1
      Source/cmTargetPropCommandBase.cxx
  37. 3 3
      Source/cmUtilitySourceCommand.cxx
  38. 2 2
      Source/cmVariableRequiresCommand.cxx
  39. 1 1
      Source/cmVariableWatchCommand.cxx
  40. 1 1
      Source/cmWriteFileCommand.cxx
  41. 3 3
      Source/cmake.cxx
  42. 8 8
      Source/cmcmd.cxx

+ 1 - 1
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) {

+ 1 - 1
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 \""

+ 1 - 1
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;

+ 1 - 1
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;
 

+ 1 - 1
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;

+ 3 - 3
Source/cmAuxSourceDirectoryCommand.cxx

@@ -18,13 +18,13 @@ class cmExecutionStatus;
 bool cmAuxSourceDirectoryCommand::InitialPass(
   std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if (args.size() < 2 || args.size() > 2) {
+  if (args.size() != 2) {
     this->SetError("called with incorrect number of arguments");
     return false;
   }
 
   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()) {

+ 2 - 2
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;

+ 2 - 2
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 += ";";
     }

+ 2 - 2
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 += "/";

+ 10 - 8
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.";

+ 4 - 4
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

+ 1 - 4
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) {
@@ -600,9 +600,6 @@ void cmExtraCodeLiteGenerator::CreateNewProjectFile(
   // which may have an acompanying header, one for all other files
   std::string projectType;
 
-  std::vector<std::string> headerExts =
-    this->GlobalGenerator->GetCMakeInstance()->GetHeaderExtensions();
-
   std::map<std::string, cmSourceFile*> cFiles;
   std::set<std::string> otherFiles;
 

+ 2 - 2
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);

+ 1 - 1
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);
   }

+ 3 - 3
Source/cmFindPackageCommand.cxx

@@ -938,7 +938,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)) {
@@ -950,7 +950,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)) {
@@ -962,7 +962,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)) {

+ 1 - 1
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") {

+ 1 - 1
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

+ 2 - 2
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

+ 2 - 2
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;
 

+ 2 - 2
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;

+ 1 - 1
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();

+ 1 - 1
Source/cmGlobalNinjaGenerator.cxx

@@ -56,7 +56,7 @@ void cmGlobalNinjaGenerator::Indent(std::ostream& os, int count)
 void cmGlobalNinjaGenerator::WriteDivider(std::ostream& os)
 {
   os << "# ======================================"
-     << "=======================================\n";
+        "=======================================\n";
 }
 
 void cmGlobalNinjaGenerator::WriteComment(std::ostream& os,

+ 11 - 9
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));
     }

+ 3 - 3
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);
 

+ 1 - 1
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 =

+ 1 - 1
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 &&

+ 1 - 1
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(

+ 1 - 1
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;

+ 1 - 3
Source/cmOSXBundleGenerator.cxx

@@ -48,8 +48,6 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName,
   cmSystemTools::MakeDirectory(out.c_str());
   this->Makefile->AddCMakeOutputFile(out);
 
-  std::string newoutpath = out;
-
   // Configure the Info.plist file.  Note that it needs the executable name
   // to be set.
   std::string plist = outpath;
@@ -60,7 +58,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName,
   this->LocalGenerator->GenerateAppleInfoPList(this->GT, targetName,
                                                plist.c_str());
   this->Makefile->AddCMakeOutputFile(plist);
-  outpath = newoutpath;
+  outpath = out;
 }
 
 void cmOSXBundleGenerator::CreateFramework(const std::string& targetName,

+ 22 - 19
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);

+ 1 - 1
Source/cmQtAutoGeneratorInitializer.cxx

@@ -825,7 +825,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) {

+ 1 - 1
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);
 

+ 6 - 6
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) {

+ 11 - 11
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")) {

+ 6 - 7
Source/cmSystemTools.cxx

@@ -196,7 +196,6 @@ void cmSystemTools::ExpandRegistryValues(std::string& source,
   while (regEntry.find(source)) {
     // the arguments are the second match
     std::string key = regEntry.match(1);
-    std::string val;
     std::string reg = "[";
     reg += key + "]";
     cmSystemTools::ReplaceString(source, reg.c_str(), "/registry");
@@ -348,12 +347,12 @@ bool cmSystemTools::IsInternallyOn(const char* val)
   if (!val) {
     return false;
   }
-  std::basic_string<char> v = val;
+  std::string v = val;
   if (v.size() > 4) {
     return false;
   }
 
-  for (std::basic_string<char>::iterator c = v.begin(); c != v.end(); c++) {
+  for (std::string::iterator c = v.begin(); c != v.end(); c++) {
     *c = static_cast<char>(toupper(*c));
   }
   return v == "I_ON";
@@ -368,7 +367,7 @@ bool cmSystemTools::IsOn(const char* val)
   if (len > 4) {
     return false;
   }
-  std::basic_string<char> v(val, len);
+  std::string v(val, len);
 
   static std::set<std::string> onValues;
   if (onValues.empty()) {
@@ -378,7 +377,7 @@ bool cmSystemTools::IsOn(const char* val)
     onValues.insert("TRUE");
     onValues.insert("Y");
   }
-  for (std::basic_string<char>::iterator c = v.begin(); c != v.end(); c++) {
+  for (std::string::iterator c = v.begin(); c != v.end(); c++) {
     *c = static_cast<char>(toupper(*c));
   }
   return (onValues.count(v) > 0);
@@ -413,8 +412,8 @@ bool cmSystemTools::IsOff(const char* val)
     offValues.insert("IGNORE");
   }
   // Try and avoid toupper().
-  std::basic_string<char> v(val, len);
-  for (std::basic_string<char>::iterator c = v.begin(); c != v.end(); c++) {
+  std::string v(val, len);
+  for (std::string::iterator c = v.begin(); c != v.end(); c++) {
     *c = static_cast<char>(toupper(*c));
   }
   return (offValues.count(v) > 0);

+ 1 - 1
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");

+ 3 - 3
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;
 

+ 2 - 2
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;

+ 1 - 1
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];

+ 1 - 1
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++;
 

+ 3 - 3
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()) {

+ 8 - 8
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");