Convert some leftover loops to C++11 range-based loop

Fix issues diagnosed by clang-tidy [modern-loop-convert]

Signed-off-by: Matthias Maennich <matthias@maennich.net>
This commit is contained in:
Matthias Maennich
2017-09-20 23:44:34 +02:00
committed by Brad King
parent b5d7f5b0e8
commit f0bab294dc
9 changed files with 165 additions and 232 deletions

View File

@@ -213,8 +213,7 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
cmSystemTools::ExpandListArgument(sign_files, relFiles); cmSystemTools::ExpandListArgument(sign_files, relFiles);
// sign the files supplied by the user, ie. frameworks. // sign the files supplied by the user, ie. frameworks.
for (std::vector<std::string>::iterator it = relFiles.begin(); for (auto const& file : relFiles) {
it != relFiles.end(); ++it) {
std::ostringstream temp_sign_file_cmd; std::ostringstream temp_sign_file_cmd;
temp_sign_file_cmd << this->GetOption("CPACK_COMMAND_CODESIGN"); temp_sign_file_cmd << this->GetOption("CPACK_COMMAND_CODESIGN");
temp_sign_file_cmd << " " << sign_parameter << " -s \"" temp_sign_file_cmd << " " << sign_parameter << " -s \""
@@ -223,11 +222,11 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
temp_sign_file_cmd << this->GetOption("CPACK_APPLE_BUNDLE_ID"); temp_sign_file_cmd << this->GetOption("CPACK_APPLE_BUNDLE_ID");
temp_sign_file_cmd << " \""; temp_sign_file_cmd << " \"";
temp_sign_file_cmd << bundle_path; temp_sign_file_cmd << bundle_path;
temp_sign_file_cmd << *it << "\""; temp_sign_file_cmd << file << "\"";
if (!this->RunCommand(temp_sign_file_cmd, &output)) { if (!this->RunCommand(temp_sign_file_cmd, &output)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error signing file:" << bundle_path << *it << std::endl "Error signing file:" << bundle_path << file << std::endl
<< output << std::endl); << output << std::endl);
return 0; return 0;

View File

@@ -136,17 +136,17 @@ int cmCPackDragNDropGenerator::InitializeInternal()
"CPACK_DMG_SLA_LANGUAGES set but empty" << std::endl); "CPACK_DMG_SLA_LANGUAGES set but empty" << std::endl);
return 0; return 0;
} }
for (size_t i = 0; i < languages.size(); ++i) { for (auto const& language : languages) {
std::string license = slaDirectory + "/" + languages[i] + ".license.txt"; std::string license = slaDirectory + "/" + language + ".license.txt";
if (!singleLicense && !cmSystemTools::FileExists(license)) { if (!singleLicense && !cmSystemTools::FileExists(license)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Missing license file " cmCPackLogger(cmCPackLog::LOG_ERROR, "Missing license file "
<< languages[i] << ".license.txt" << std::endl); << language << ".license.txt" << std::endl);
return 0; return 0;
} }
std::string menu = slaDirectory + "/" + languages[i] + ".menu.txt"; std::string menu = slaDirectory + "/" + language + ".menu.txt";
if (!cmSystemTools::FileExists(menu)) { if (!cmSystemTools::FileExists(menu)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Missing menu file " cmCPackLogger(cmCPackLog::LOG_ERROR, "Missing menu file "
<< languages[i] << ".menu.txt" << std::endl); << language << ".menu.txt" << std::endl);
return 0; return 0;
} }
} }
@@ -185,19 +185,19 @@ int cmCPackDragNDropGenerator::PackageFiles()
// loop to create dmg files // loop to create dmg files
packageFileNames.clear(); packageFileNames.clear();
for (size_t i = 0; i < package_files.size(); i++) { for (auto const& package_file : package_files) {
std::string full_package_name = std::string(toplevel) + std::string("/"); std::string full_package_name = std::string(toplevel) + std::string("/");
if (package_files[i] == "ALL_IN_ONE") { if (package_file == "ALL_IN_ONE") {
full_package_name += this->GetOption("CPACK_PACKAGE_FILE_NAME"); full_package_name += this->GetOption("CPACK_PACKAGE_FILE_NAME");
} else { } else {
full_package_name += package_files[i]; full_package_name += package_file;
} }
full_package_name += std::string(GetOutputExtension()); full_package_name += std::string(GetOutputExtension());
packageFileNames.push_back(full_package_name); packageFileNames.push_back(full_package_name);
std::string src_dir = toplevel; std::string src_dir = toplevel;
src_dir += "/"; src_dir += "/";
src_dir += package_files[i]; src_dir += package_file;
if (0 == this->CreateDMG(src_dir, full_package_name)) { if (0 == this->CreateDMG(src_dir, full_package_name)) {
return 0; return 0;
@@ -796,8 +796,8 @@ bool cmCPackDragNDropGenerator::WriteLicense(
if (!this->BreakLongLine(line, lines, error)) { if (!this->BreakLongLine(line, lines, error)) {
return false; return false;
} }
for (size_t i = 0; i < lines.size(); ++i) { for (auto const& l : lines) {
outputStream << " \"" << lines[i] << "\"\n"; outputStream << " \"" << l << "\"\n";
} }
} }
outputStream << " \"\\n\"\n"; outputStream << " \"\\n\"\n";

View File

@@ -436,18 +436,13 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
// now make the allbuild depend on all the non-utility targets // now make the allbuild depend on all the non-utility targets
// in the project // in the project
for (std::vector<cmLocalGenerator*>::iterator i = gens.begin(); for (auto& gen : gens) {
i != gens.end(); ++i) { if (this->IsExcluded(root, gen)) {
cmLocalGenerator* lg = *i;
if (this->IsExcluded(root, *i)) {
continue; continue;
} }
const std::vector<cmGeneratorTarget*>& tgts = lg->GetGeneratorTargets(); const std::vector<cmGeneratorTarget*>& tgts = gen->GetGeneratorTargets();
for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); for (auto target : tgts) {
l != tgts.end(); l++) {
cmGeneratorTarget* target = *l;
if (target->GetType() == cmStateEnums::GLOBAL_TARGET) { if (target->GetType() == cmStateEnums::GLOBAL_TARGET) {
continue; continue;
} }
@@ -473,7 +468,7 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
cmCustomCommandLines commandLines; cmCustomCommandLines commandLines;
commandLines.push_back(makeHelper); commandLines.push_back(makeHelper);
std::vector<std::string> no_byproducts; std::vector<std::string> no_byproducts;
lg->GetMakefile()->AddCustomCommandToTarget( gen->GetMakefile()->AddCustomCommandToTarget(
target->GetName(), no_byproducts, no_depends, commandLines, target->GetName(), no_byproducts, no_depends, commandLines,
cmTarget::POST_BUILD, "Depend check for xcode", dir.c_str(), true, cmTarget::POST_BUILD, "Depend check for xcode", dir.c_str(), true,
false, "", false, cmMakefile::AcceptObjectLibraryCommands); false, "", false, cmMakefile::AcceptObjectLibraryCommands);
@@ -485,7 +480,7 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
} }
// Refer to the build configuration file for easy editing. // Refer to the build configuration file for easy editing.
listfile = lg->GetCurrentSourceDirectory(); listfile = gen->GetCurrentSourceDirectory();
listfile += "/"; listfile += "/";
listfile += "CMakeLists.txt"; listfile += "CMakeLists.txt";
target->AddSource(listfile); target->AddSource(listfile);
@@ -497,9 +492,8 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile(
cmLocalGenerator* root, std::vector<cmLocalGenerator*> const& gens) cmLocalGenerator* root, std::vector<cmLocalGenerator*> const& gens)
{ {
std::vector<std::string> lfiles; std::vector<std::string> lfiles;
for (std::vector<cmLocalGenerator*>::const_iterator gi = gens.begin(); for (auto gen : gens) {
gi != gens.end(); ++gi) { std::vector<std::string> const& lf = gen->GetMakefile()->GetListFiles();
std::vector<std::string> const& lf = (*gi)->GetMakefile()->GetListFiles();
lfiles.insert(lfiles.end(), lf.begin(), lf.end()); lfiles.insert(lfiles.end(), lf.begin(), lf.end());
} }
@@ -559,8 +553,8 @@ void cmGlobalXCodeGenerator::SortXCodeObjects()
void cmGlobalXCodeGenerator::ClearXCodeObjects() void cmGlobalXCodeGenerator::ClearXCodeObjects()
{ {
this->TargetDoneSet.clear(); this->TargetDoneSet.clear();
for (unsigned int i = 0; i < this->XCodeObjects.size(); ++i) { for (auto& obj : this->XCodeObjects) {
delete this->XCodeObjects[i]; delete obj;
} }
this->XCodeObjects.clear(); this->XCodeObjects.clear();
this->XCodeObjectIDs.clear(); this->XCodeObjectIDs.clear();
@@ -934,13 +928,11 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
typedef std::map<std::string, cmGeneratorTarget*, cmCompareTargets> typedef std::map<std::string, cmGeneratorTarget*, cmCompareTargets>
cmSortedTargets; cmSortedTargets;
cmSortedTargets sortedTargets; cmSortedTargets sortedTargets;
for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); for (auto tgt : tgts) {
l != tgts.end(); l++) { sortedTargets[tgt->GetName()] = tgt;
sortedTargets[(*l)->GetName()] = *l;
} }
for (cmSortedTargets::iterator l = sortedTargets.begin(); for (auto& sortedTarget : sortedTargets) {
l != sortedTargets.end(); l++) { cmGeneratorTarget* gtgt = sortedTarget.second;
cmGeneratorTarget* gtgt = l->second;
std::string targetName = gtgt->GetName(); std::string targetName = gtgt->GetName();
@@ -1043,9 +1035,8 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
sourceBuildPhase->AddAttribute("buildActionMask", sourceBuildPhase->AddAttribute("buildActionMask",
this->CreateString("2147483647")); this->CreateString("2147483647"));
buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
for (std::vector<cmXCodeObject*>::iterator i = sourceFiles.begin(); for (auto& sourceFile : sourceFiles) {
i != sourceFiles.end(); ++i) { buildFiles->AddObject(sourceFile);
buildFiles->AddObject(*i);
} }
sourceBuildPhase->AddAttribute("files", buildFiles); sourceBuildPhase->AddAttribute("files", buildFiles);
sourceBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", sourceBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
@@ -1061,9 +1052,8 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
headerBuildPhase->AddAttribute("buildActionMask", headerBuildPhase->AddAttribute("buildActionMask",
this->CreateString("2147483647")); this->CreateString("2147483647"));
buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
for (std::vector<cmXCodeObject*>::iterator i = headerFiles.begin(); for (auto& headerFile : headerFiles) {
i != headerFiles.end(); ++i) { buildFiles->AddObject(headerFile);
buildFiles->AddObject(*i);
} }
headerBuildPhase->AddAttribute("files", buildFiles); headerBuildPhase->AddAttribute("files", buildFiles);
headerBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", headerBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
@@ -1080,9 +1070,8 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
resourceBuildPhase->AddAttribute("buildActionMask", resourceBuildPhase->AddAttribute("buildActionMask",
this->CreateString("2147483647")); this->CreateString("2147483647"));
buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
for (std::vector<cmXCodeObject*>::iterator i = resourceFiles.begin(); for (auto& resourceFile : resourceFiles) {
i != resourceFiles.end(); ++i) { buildFiles->AddObject(resourceFile);
buildFiles->AddObject(*i);
} }
resourceBuildPhase->AddAttribute("files", buildFiles); resourceBuildPhase->AddAttribute("files", buildFiles);
resourceBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", resourceBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
@@ -1190,9 +1179,8 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
this->CreateString("2147483647")); this->CreateString("2147483647"));
buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
frameworkBuildPhase->AddAttribute("files", buildFiles); frameworkBuildPhase->AddAttribute("files", buildFiles);
for (std::vector<cmXCodeObject*>::iterator i = externalObjFiles.begin(); for (auto& externalObjFile : externalObjFiles) {
i != externalObjFiles.end(); ++i) { buildFiles->AddObject(externalObjFile);
buildFiles->AddObject(*i);
} }
frameworkBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", frameworkBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
this->CreateString("0")); this->CreateString("0"));
@@ -1213,14 +1201,13 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
void cmGlobalXCodeGenerator::ForceLinkerLanguages() void cmGlobalXCodeGenerator::ForceLinkerLanguages()
{ {
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) { for (auto& localGenerator : this->LocalGenerators) {
const std::vector<cmGeneratorTarget*>& tgts = const std::vector<cmGeneratorTarget*>& tgts =
this->LocalGenerators[i]->GetGeneratorTargets(); localGenerator->GetGeneratorTargets();
// All targets depend on the build-system check target. // All targets depend on the build-system check target.
for (std::vector<cmGeneratorTarget*>::const_iterator ti = tgts.begin(); for (auto tgt : tgts) {
ti != tgts.end(); ++ti) {
// This makes sure all targets link using the proper language. // This makes sure all targets link using the proper language.
this->ForceLinkerLanguage(*ti); this->ForceLinkerLanguage(tgt);
} }
} }
} }
@@ -1241,9 +1228,8 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt)
// If the language is compiled as a source trust Xcode to link with it. // If the language is compiled as a source trust Xcode to link with it.
cmLinkImplementation const* impl = gtgt->GetLinkImplementation("NOCONFIG"); cmLinkImplementation const* impl = gtgt->GetLinkImplementation("NOCONFIG");
for (std::vector<std::string>::const_iterator li = impl->Languages.begin(); for (auto const& Language : impl->Languages) {
li != impl->Languages.end(); ++li) { if (Language == llang) {
if (*li == llang) {
return; return;
} }
} }
@@ -1545,16 +1531,15 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
makefileStream << "all: "; makefileStream << "all: ";
std::map<const cmCustomCommand*, std::string> tname; std::map<const cmCustomCommand*, std::string> tname;
int count = 0; int count = 0;
for (std::vector<cmCustomCommand>::const_iterator i = commands.begin(); for (auto const& command : commands) {
i != commands.end(); ++i) { cmCustomCommandGenerator ccg(command, configName,
cmCustomCommandGenerator ccg(*i, configName, this->CurrentLocalGenerator); this->CurrentLocalGenerator);
if (ccg.GetNumberOfCommands() > 0) { if (ccg.GetNumberOfCommands() > 0) {
const std::vector<std::string>& outputs = ccg.GetOutputs(); const std::vector<std::string>& outputs = ccg.GetOutputs();
if (!outputs.empty()) { if (!outputs.empty()) {
for (std::vector<std::string>::const_iterator o = outputs.begin(); for (auto const& output : outputs) {
o != outputs.end(); ++o) {
makefileStream << "\\\n\t" makefileStream << "\\\n\t"
<< this->ConvertToRelativeForMake(o->c_str()); << this->ConvertToRelativeForMake(output.c_str());
} }
} else { } else {
std::ostringstream str; std::ostringstream str;
@@ -1565,18 +1550,18 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
} }
} }
makefileStream << "\n\n"; makefileStream << "\n\n";
for (std::vector<cmCustomCommand>::const_iterator i = commands.begin(); for (auto const& command : commands) {
i != commands.end(); ++i) { cmCustomCommandGenerator ccg(command, configName,
cmCustomCommandGenerator ccg(*i, configName, this->CurrentLocalGenerator); this->CurrentLocalGenerator);
if (ccg.GetNumberOfCommands() > 0) { if (ccg.GetNumberOfCommands() > 0) {
makefileStream << "\n"; makefileStream << "\n";
const std::vector<std::string>& outputs = ccg.GetOutputs(); const std::vector<std::string>& outputs = ccg.GetOutputs();
if (!outputs.empty()) { if (!outputs.empty()) {
// There is at least one output, start the rule for it // There is at least one output, start the rule for it
const char* sep = ""; const char* sep = "";
for (std::vector<std::string>::const_iterator oi = outputs.begin(); for (auto const& output : outputs) {
oi != outputs.end(); ++oi) { makefileStream << sep
makefileStream << sep << this->ConvertToRelativeForMake(oi->c_str()); << this->ConvertToRelativeForMake(output.c_str());
sep = " "; sep = " ";
} }
makefileStream << ": "; makefileStream << ": ";
@@ -1584,11 +1569,9 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
// There are no outputs. Use the generated force rule name. // There are no outputs. Use the generated force rule name.
makefileStream << tname[&ccg.GetCC()] << ": "; makefileStream << tname[&ccg.GetCC()] << ": ";
} }
for (std::vector<std::string>::const_iterator d = for (auto const& d : ccg.GetDepends()) {
ccg.GetDepends().begin();
d != ccg.GetDepends().end(); ++d) {
std::string dep; std::string dep;
if (this->CurrentLocalGenerator->GetRealDependency(*d, configName, if (this->CurrentLocalGenerator->GetRealDependency(d, configName,
dep)) { dep)) {
makefileStream << "\\\n" makefileStream << "\\\n"
<< this->ConvertToRelativeForMake(dep.c_str()); << this->ConvertToRelativeForMake(dep.c_str());
@@ -1643,9 +1626,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
std::set<std::string> languages; std::set<std::string> languages;
gtgt->GetLanguages(languages, configName); gtgt->GetLanguages(languages, configName);
std::map<std::string, std::string> cflags; std::map<std::string, std::string> cflags;
for (std::set<std::string>::iterator li = languages.begin(); for (auto const& lang : languages) {
li != languages.end(); ++li) {
std::string const& lang = *li;
std::string& flags = cflags[lang]; std::string& flags = cflags[lang];
// Add language-specific flags. // Add language-specific flags.
@@ -1741,9 +1722,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
} else { } else {
cmXCodeObject* archObjects = cmXCodeObject* archObjects =
this->CreateObject(cmXCodeObject::OBJECT_LIST); this->CreateObject(cmXCodeObject::OBJECT_LIST);
for (std::vector<std::string>::iterator i = archs.begin(); for (auto& arch : archs) {
i != archs.end(); i++) { archObjects->AddObject(this->CreateString(arch));
archObjects->AddObject(this->CreateString(*i));
} }
buildSettings->AddAttribute("ARCHS", archObjects); buildSettings->AddAttribute("ARCHS", archObjects);
} }
@@ -1968,10 +1948,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
std::set<std::string> emitted; std::set<std::string> emitted;
emitted.insert("/System/Library/Frameworks"); emitted.insert("/System/Library/Frameworks");
for (std::vector<std::string>::iterator i = includes.begin(); for (auto& include : includes) {
i != includes.end(); ++i) { if (this->NameResolvesToFramework(include)) {
if (this->NameResolvesToFramework(*i)) { std::string frameworkDir = include;
std::string frameworkDir = *i;
frameworkDir += "/../"; frameworkDir += "/../";
frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir); frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir);
if (emitted.insert(frameworkDir).second) { if (emitted.insert(frameworkDir).second) {
@@ -1984,9 +1963,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
} }
} }
} else { } else {
std::string incpath = this->XCodeEscapePath(*i); std::string incpath = this->XCodeEscapePath(include);
if (emitSystemIncludes && if (emitSystemIncludes &&
gtgt->IsSystemIncludeDirectory(*i, configName)) { gtgt->IsSystemIncludeDirectory(include, configName)) {
sysdirs.Add(incpath); sysdirs.Add(incpath);
} else { } else {
dirs.Add(incpath); dirs.Add(incpath);
@@ -1996,12 +1975,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
// Add framework search paths needed for linking. // Add framework search paths needed for linking.
if (cmComputeLinkInformation* cli = gtgt->GetLinkInformation(configName)) { if (cmComputeLinkInformation* cli = gtgt->GetLinkInformation(configName)) {
std::vector<std::string> const& fwDirs = cli->GetFrameworkPaths(); std::vector<std::string> const& fwDirs = cli->GetFrameworkPaths();
for (std::vector<std::string>::const_iterator fdi = fwDirs.begin(); for (auto const& fwDir : fwDirs) {
fdi != fwDirs.end(); ++fdi) { if (emitted.insert(fwDir).second) {
if (emitted.insert(*fdi).second) { std::string incpath = this->XCodeEscapePath(fwDir);
std::string incpath = this->XCodeEscapePath(*fdi);
if (emitSystemIncludes && if (emitSystemIncludes &&
gtgt->IsSystemIncludeDirectory(*fdi, configName)) { gtgt->IsSystemIncludeDirectory(fwDir, configName)) {
sysfdirs.Add(incpath); sysfdirs.Add(incpath);
} else { } else {
fdirs.Add(incpath); fdirs.Add(incpath);
@@ -2029,13 +2007,12 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
// system include directory awareness. We need to also keep on setting // system include directory awareness. We need to also keep on setting
// HEADER_SEARCH_PATHS to work around a missing compile options flag for // HEADER_SEARCH_PATHS to work around a missing compile options flag for
// GNU assembly files (#16449) // GNU assembly files (#16449)
for (std::set<std::string>::iterator li = languages.begin(); for (auto const& language : languages) {
li != languages.end(); ++li) {
std::string includeFlags = this->CurrentLocalGenerator->GetIncludeFlags( std::string includeFlags = this->CurrentLocalGenerator->GetIncludeFlags(
includes, gtgt, *li, true, false, configName); includes, gtgt, language, true, false, configName);
if (!includeFlags.empty()) { if (!includeFlags.empty()) {
cflags[*li] += " " + includeFlags; cflags[language] += " " + includeFlags;
} }
} }
} }
@@ -2046,10 +2023,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
std::string optLevel = "0"; std::string optLevel = "0";
// Minimal map of flags to build settings. // Minimal map of flags to build settings.
for (std::set<std::string>::iterator li = languages.begin(); for (auto const& language : languages) {
li != languages.end(); ++li) { std::string& flags = cflags[language];
std::string& flags = cflags[*li]; std::string& gflag = gflags[language];
std::string& gflag = gflags[*li];
std::string oflag = std::string oflag =
this->ExtractFlagRegex("(^| )(-Ofast|-Os|-O[0-9]*)( |$)", 2, flags); this->ExtractFlagRegex("(^| )(-Ofast|-Os|-O[0-9]*)( |$)", 2, flags);
if (oflag.size() == 2) { if (oflag.size() == 2) {
@@ -2074,10 +2050,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
if (!same_gflags) { if (!same_gflags) {
// We can't set the Xcode flag differently depending on the language, // We can't set the Xcode flag differently depending on the language,
// so put them back in this case. // so put them back in this case.
for (std::set<std::string>::iterator li = languages.begin(); for (auto const& language : languages) {
li != languages.end(); ++li) { cflags[language] += " ";
cflags[*li] += " "; cflags[language] += gflags[language];
cflags[*li] += gflags[*li];
} }
debugStr = "NO"; debugStr = "NO";
} else if (last_gflag && (last_gflag->empty() || *last_gflag == "-g0")) { } else if (last_gflag && (last_gflag->empty() || *last_gflag == "-g0")) {
@@ -2094,18 +2069,17 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
this->CreateString("NO")); this->CreateString("NO"));
buildSettings->AddAttribute("GCC_INLINES_ARE_PRIVATE_EXTERN", buildSettings->AddAttribute("GCC_INLINES_ARE_PRIVATE_EXTERN",
this->CreateString("NO")); this->CreateString("NO"));
for (std::set<std::string>::iterator li = languages.begin(); for (auto const& language : languages) {
li != languages.end(); ++li) { std::string flags = cflags[language] + " " + defFlags;
std::string flags = cflags[*li] + " " + defFlags; if (language == "CXX") {
if (*li == "CXX") {
buildSettings->AddAttribute("OTHER_CPLUSPLUSFLAGS", buildSettings->AddAttribute("OTHER_CPLUSPLUSFLAGS",
this->CreateString(flags)); this->CreateString(flags));
} else if (*li == "Fortran") { } else if (language == "Fortran") {
buildSettings->AddAttribute("IFORT_OTHER_FLAGS", buildSettings->AddAttribute("IFORT_OTHER_FLAGS",
this->CreateString(flags)); this->CreateString(flags));
} else if (*li == "C") { } else if (language == "C") {
buildSettings->AddAttribute("OTHER_CFLAGS", this->CreateString(flags)); buildSettings->AddAttribute("OTHER_CFLAGS", this->CreateString(flags));
} else if (*li == "Swift") { } else if (language == "Swift") {
buildSettings->AddAttribute("OTHER_SWIFT_FLAGS", buildSettings->AddAttribute("OTHER_SWIFT_FLAGS",
this->CreateString(flags)); this->CreateString(flags));
} }
@@ -2229,15 +2203,14 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
// Convert "XCODE_ATTRIBUTE_*" properties directly. // Convert "XCODE_ATTRIBUTE_*" properties directly.
{ {
std::vector<std::string> const& props = gtgt->GetPropertyKeys(); std::vector<std::string> const& props = gtgt->GetPropertyKeys();
for (std::vector<std::string>::const_iterator i = props.begin(); for (auto const& prop : props) {
i != props.end(); ++i) { if (prop.find("XCODE_ATTRIBUTE_") == 0) {
if (i->find("XCODE_ATTRIBUTE_") == 0) { std::string attribute = prop.substr(16);
std::string attribute = i->substr(16);
this->FilterConfigurationAttribute(configName, attribute); this->FilterConfigurationAttribute(configName, attribute);
if (!attribute.empty()) { if (!attribute.empty()) {
cmGeneratorExpression ge; cmGeneratorExpression ge;
std::string processed = std::string processed =
ge.Parse(gtgt->GetProperty(*i)) ge.Parse(gtgt->GetProperty(prop))
->Evaluate(this->CurrentLocalGenerator, configName); ->Evaluate(this->CurrentLocalGenerator, configName);
buildSettings->AddAttribute(attribute, buildSettings->AddAttribute(attribute,
this->CreateString(processed)); this->CreateString(processed));
@@ -2325,15 +2298,15 @@ std::string cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target,
configlist->SetComment(comment); configlist->SetComment(comment);
target->AddAttribute("buildConfigurationList", target->AddAttribute("buildConfigurationList",
this->CreateObjectReference(configlist)); this->CreateObjectReference(configlist));
for (unsigned int i = 0; i < configVector.size(); ++i) { for (auto const& i : configVector) {
cmXCodeObject* config = cmXCodeObject* config =
this->CreateObject(cmXCodeObject::XCBuildConfiguration); this->CreateObject(cmXCodeObject::XCBuildConfiguration);
buildConfigurations->AddObject(config); buildConfigurations->AddObject(config);
cmXCodeObject* buildSettings = cmXCodeObject* buildSettings =
this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
this->CreateBuildSettings(gtgt, buildSettings, configVector[i]); this->CreateBuildSettings(gtgt, buildSettings, i);
config->AddAttribute("name", this->CreateString(configVector[i])); config->AddAttribute("name", this->CreateString(i));
config->SetComment(configVector[i]); config->SetComment(i);
config->AddAttribute("buildSettings", buildSettings); config->AddAttribute("buildSettings", buildSettings);
} }
if (!configVector.empty()) { if (!configVector.empty()) {
@@ -2562,15 +2535,14 @@ void cmGlobalXCodeGenerator::AppendBuildSettingAttribute(
std::vector<cmXCodeObject*> list = buildConfigs->GetObjectList(); std::vector<cmXCodeObject*> list = buildConfigs->GetObjectList();
// each configuration and the target itself has a buildSettings in it // each configuration and the target itself has a buildSettings in it
// list.push_back(target); // list.push_back(target);
for (std::vector<cmXCodeObject*>::iterator i = list.begin(); i != list.end(); for (auto& i : list) {
++i) {
if (!configName.empty()) { if (!configName.empty()) {
if ((*i)->GetObject("name")->GetString() == configName) { if (i->GetObject("name")->GetString() == configName) {
cmXCodeObject* settings = (*i)->GetObject("buildSettings"); cmXCodeObject* settings = i->GetObject("buildSettings");
this->AppendOrAddBuildSetting(settings, attribute, value); this->AppendOrAddBuildSetting(settings, attribute, value);
} }
} else { } else {
cmXCodeObject* settings = (*i)->GetObject("buildSettings"); cmXCodeObject* settings = i->GetObject("buildSettings");
this->AppendOrAddBuildSetting(settings, attribute, value); this->AppendOrAddBuildSetting(settings, attribute, value);
} }
} }
@@ -2589,20 +2561,15 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
// Add dependencies on other CMake targets. // Add dependencies on other CMake targets.
TargetDependSet const& deps = this->GetTargetDirectDepends(gt); TargetDependSet const& deps = this->GetTargetDirectDepends(gt);
for (TargetDependSet::const_iterator i = deps.begin(); i != deps.end(); for (auto dep : deps) {
++i) { if (cmXCodeObject* dptarget = this->FindXCodeTarget(dep)) {
if (cmXCodeObject* dptarget = this->FindXCodeTarget(*i)) {
this->AddDependTarget(target, dptarget); this->AddDependTarget(target, dptarget);
} }
} }
// Loop over configuration types and set per-configuration info. // Loop over configuration types and set per-configuration info.
for (std::vector<std::string>::iterator i = for (auto const& configName : this->CurrentConfigurationTypes) {
this->CurrentConfigurationTypes.begin();
i != this->CurrentConfigurationTypes.end(); ++i) {
// Get the current configuration name. // Get the current configuration name.
std::string configName = *i;
if (this->XcodeVersion >= 50) { if (this->XcodeVersion >= 50) {
// Add object library contents as link flags. // Add object library contents as link flags.
std::string linkObjs; std::string linkObjs;
@@ -2638,9 +2605,8 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
// Add dependencies directly on library files. // Add dependencies directly on library files.
{ {
std::vector<std::string> const& libDeps = cli.GetDepends(); std::vector<std::string> const& libDeps = cli.GetDepends();
for (std::vector<std::string>::const_iterator j = libDeps.begin(); for (auto const& libDep : libDeps) {
j != libDeps.end(); ++j) { target->AddDependLibrary(configName, libDep);
target->AddDependLibrary(configName, *j);
} }
} }
@@ -2648,16 +2614,15 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
{ {
std::vector<std::string> const& libDirs = cli.GetDirectories(); std::vector<std::string> const& libDirs = cli.GetDirectories();
std::string linkDirs; std::string linkDirs;
for (std::vector<std::string>::const_iterator libDir = libDirs.begin(); for (auto const& libDir : libDirs) {
libDir != libDirs.end(); ++libDir) { if (!libDir.empty() && libDir != "/usr/lib") {
if (!libDir->empty() && *libDir != "/usr/lib") {
// Now add the same one but append // Now add the same one but append
// $(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) to it: // $(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) to it:
linkDirs += " "; linkDirs += " ";
linkDirs += this->XCodeEscapePath( linkDirs += this->XCodeEscapePath(
*libDir + "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)"); libDir + "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)");
linkDirs += " "; linkDirs += " ";
linkDirs += this->XCodeEscapePath(*libDir); linkDirs += this->XCodeEscapePath(libDir);
} }
} }
this->AppendBuildSettingAttribute(target, "LIBRARY_SEARCH_PATHS", this->AppendBuildSettingAttribute(target, "LIBRARY_SEARCH_PATHS",
@@ -2670,18 +2635,18 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
const char* sep = ""; const char* sep = "";
typedef cmComputeLinkInformation::ItemVector ItemVector; typedef cmComputeLinkInformation::ItemVector ItemVector;
ItemVector const& libNames = cli.GetItems(); ItemVector const& libNames = cli.GetItems();
for (ItemVector::const_iterator li = libNames.begin(); for (auto const& libName : libNames) {
li != libNames.end(); ++li) {
linkLibs += sep; linkLibs += sep;
sep = " "; sep = " ";
if (li->IsPath) { if (libName.IsPath) {
linkLibs += this->XCodeEscapePath(li->Value); linkLibs += this->XCodeEscapePath(libName.Value);
} else if (!li->Target || } else if (!libName.Target ||
li->Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { libName.Target->GetType() !=
linkLibs += li->Value; cmStateEnums::INTERFACE_LIBRARY) {
linkLibs += libName.Value;
} }
if (li->Target && !li->Target->IsImported()) { if (libName.Target && !libName.Target->IsImported()) {
target->AddDependTarget(configName, li->Target->GetName()); target->AddDependTarget(configName, libName.Target->GetName());
} }
} }
this->AppendBuildSettingAttribute( this->AppendBuildSettingAttribute(
@@ -2693,15 +2658,12 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
bool cmGlobalXCodeGenerator::CreateGroups( bool cmGlobalXCodeGenerator::CreateGroups(
std::vector<cmLocalGenerator*>& generators) std::vector<cmLocalGenerator*>& generators)
{ {
for (std::vector<cmLocalGenerator*>::iterator i = generators.begin(); for (auto& generator : generators) {
i != generators.end(); ++i) { cmMakefile* mf = generator->GetMakefile();
cmMakefile* mf = (*i)->GetMakefile();
std::vector<cmSourceGroup> sourceGroups = mf->GetSourceGroups(); std::vector<cmSourceGroup> sourceGroups = mf->GetSourceGroups();
const std::vector<cmGeneratorTarget*>& tgts = (*i)->GetGeneratorTargets(); const std::vector<cmGeneratorTarget*>& tgts =
for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin(); generator->GetGeneratorTargets();
l != tgts.end(); l++) { for (auto gtgt : tgts) {
cmGeneratorTarget* gtgt = *l;
// Same skipping logic here as in CreateXCodeTargets so that we do not // Same skipping logic here as in CreateXCodeTargets so that we do not
// end up with (empty anyhow) ALL_BUILD and XCODE_DEPEND_HELPER source // end up with (empty anyhow) ALL_BUILD and XCODE_DEPEND_HELPER source
// groups: // groups:
@@ -2725,10 +2687,8 @@ bool cmGlobalXCodeGenerator::CreateGroups(
gtgt->GetAllConfigSources(); gtgt->GetAllConfigSources();
// Put cmSourceFile instances in proper groups: // Put cmSourceFile instances in proper groups:
for (std::vector<cmGeneratorTarget::AllConfigSource>::const_iterator si = for (auto const& si : sources) {
sources.begin(); cmSourceFile const* sf = si.Source;
si != sources.end(); ++si) {
cmSourceFile const* sf = si->Source;
if (this->XcodeVersion >= 50 && !sf->GetObjectLibrary().empty()) { if (this->XcodeVersion >= 50 && !sf->GetObjectLibrary().empty()) {
// Object library files go on the link line instead. // Object library files go on the link line instead.
continue; continue;
@@ -2824,13 +2784,13 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateOrGetPBXGroup(
cmSystemTools::tokenize(sg->GetFullName(), "\\"); cmSystemTools::tokenize(sg->GetFullName(), "\\");
std::string curr_folder = target; std::string curr_folder = target;
curr_folder += "/"; curr_folder += "/";
for (std::vector<std::string>::size_type i = 0; i < folders.size(); i++) { for (auto const& folder : folders) {
curr_folder += folders[i]; curr_folder += folder;
std::map<std::string, cmXCodeObject*>::iterator i_folder = std::map<std::string, cmXCodeObject*>::iterator i_folder =
this->GroupNameMap.find(curr_folder); this->GroupNameMap.find(curr_folder);
// Create new folder // Create new folder
if (i_folder == this->GroupNameMap.end()) { if (i_folder == this->GroupNameMap.end()) {
cmXCodeObject* group = this->CreatePBXGroup(tgroup, folders[i]); cmXCodeObject* group = this->CreatePBXGroup(tgroup, folder);
this->GroupNameMap[curr_folder] = group; this->GroupNameMap[curr_folder] = group;
tgroup = group; tgroup = group;
} else { } else {
@@ -2854,10 +2814,10 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
cmXCodeObject* group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); cmXCodeObject* group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
group->AddAttribute("COPY_PHASE_STRIP", this->CreateString("NO")); group->AddAttribute("COPY_PHASE_STRIP", this->CreateString("NO"));
cmXCodeObject* listObjs = this->CreateObject(cmXCodeObject::OBJECT_LIST); cmXCodeObject* listObjs = this->CreateObject(cmXCodeObject::OBJECT_LIST);
for (unsigned int i = 0; i < this->CurrentConfigurationTypes.size(); ++i) { for (auto& CurrentConfigurationType : this->CurrentConfigurationTypes) {
cmXCodeObject* buildStyle = cmXCodeObject* buildStyle =
this->CreateObject(cmXCodeObject::PBXBuildStyle); this->CreateObject(cmXCodeObject::PBXBuildStyle);
const char* name = this->CurrentConfigurationTypes[i].c_str(); const char* name = CurrentConfigurationType.c_str();
buildStyle->AddAttribute("name", this->CreateString(name)); buildStyle->AddAttribute("name", this->CreateString(name));
buildStyle->SetComment(name); buildStyle->SetComment(name);
cmXCodeObject* sgroup = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); cmXCodeObject* sgroup = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
@@ -2939,8 +2899,8 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
config->AddAttribute("name", this->CreateString(name)); config->AddAttribute("name", this->CreateString(name));
configs.push_back(std::make_pair(name, config)); configs.push_back(std::make_pair(name, config));
} }
for (Configs::iterator c = configs.begin(); c != configs.end(); ++c) { for (auto& config : configs) {
buildConfigurations->AddObject(c->second); buildConfigurations->AddObject(config.second);
} }
configlist->AddAttribute("buildConfigurations", buildConfigurations); configlist->AddAttribute("buildConfigurations", buildConfigurations);
@@ -2998,7 +2958,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
symroot += "/build"; symroot += "/build";
buildSettings->AddAttribute("SYMROOT", this->CreateString(symroot)); buildSettings->AddAttribute("SYMROOT", this->CreateString(symroot));
for (Configs::iterator i = configs.begin(); i != configs.end(); ++i) { for (auto& config : configs) {
cmXCodeObject* buildSettingsForCfg = this->CreateFlatClone(buildSettings); cmXCodeObject* buildSettingsForCfg = this->CreateFlatClone(buildSettings);
// Put this last so it can override existing settings // Put this last so it can override existing settings
@@ -3008,43 +2968,38 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
d != vars.end(); ++d) { d != vars.end(); ++d) {
if (d->find("CMAKE_XCODE_ATTRIBUTE_") == 0) { if (d->find("CMAKE_XCODE_ATTRIBUTE_") == 0) {
std::string attribute = d->substr(22); std::string attribute = d->substr(22);
this->FilterConfigurationAttribute(i->first, attribute); this->FilterConfigurationAttribute(config.first, attribute);
if (!attribute.empty()) { if (!attribute.empty()) {
cmGeneratorExpression ge; cmGeneratorExpression ge;
std::string processed = std::string processed =
ge.Parse(this->CurrentMakefile->GetDefinition(*d)) ge.Parse(this->CurrentMakefile->GetDefinition(*d))
->Evaluate(this->CurrentLocalGenerator, i->first); ->Evaluate(this->CurrentLocalGenerator, config.first);
buildSettingsForCfg->AddAttribute(attribute, buildSettingsForCfg->AddAttribute(attribute,
this->CreateString(processed)); this->CreateString(processed));
} }
} }
} }
// store per-config buildSettings into configuration object // store per-config buildSettings into configuration object
i->second->AddAttribute("buildSettings", buildSettingsForCfg); config.second->AddAttribute("buildSettings", buildSettingsForCfg);
} }
this->RootObject->AddAttribute("buildConfigurationList", this->RootObject->AddAttribute("buildConfigurationList",
this->CreateObjectReference(configlist)); this->CreateObjectReference(configlist));
std::vector<cmXCodeObject*> targets; std::vector<cmXCodeObject*> targets;
for (std::vector<cmLocalGenerator*>::iterator i = generators.begin(); for (auto& generator : generators) {
i != generators.end(); ++i) { if (!this->CreateXCodeTargets(generator, targets)) {
if (!this->CreateXCodeTargets(*i, targets)) {
return false; return false;
} }
} }
// loop over all targets and add link and depend info // loop over all targets and add link and depend info
for (std::vector<cmXCodeObject*>::iterator i = targets.begin(); for (auto t : targets) {
i != targets.end(); ++i) {
cmXCodeObject* t = *i;
this->AddDependAndLinkInformation(t); this->AddDependAndLinkInformation(t);
} }
this->CreateXCodeDependHackTarget(targets); this->CreateXCodeDependHackTarget(targets);
// now add all targets to the root object // now add all targets to the root object
cmXCodeObject* allTargets = this->CreateObject(cmXCodeObject::OBJECT_LIST); cmXCodeObject* allTargets = this->CreateObject(cmXCodeObject::OBJECT_LIST);
for (std::vector<cmXCodeObject*>::iterator i = targets.begin(); for (auto t : targets) {
i != targets.end(); ++i) {
cmXCodeObject* t = *i;
allTargets->AddObject(t); allTargets->AddObject(t);
cmXCodeObject* productRef = t->GetObject("productReference"); cmXCodeObject* productRef = t->GetObject("productReference");
if (productRef) { if (productRef) {
@@ -3137,9 +3092,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
this->CurrentConfigurationTypes.begin(); this->CurrentConfigurationTypes.begin();
ct != this->CurrentConfigurationTypes.end(); ++ct) { ct != this->CurrentConfigurationTypes.end(); ++ct) {
std::string configName = *ct; std::string configName = *ct;
for (std::vector<cmXCodeObject*>::iterator i = targets.begin(); for (auto target : targets) {
i != targets.end(); ++i) {
cmXCodeObject* target = *i;
cmGeneratorTarget* gt = target->GetTarget(); cmGeneratorTarget* gt = target->GetTarget();
if (gt->GetType() == cmStateEnums::EXECUTABLE || if (gt->GetType() == cmStateEnums::EXECUTABLE ||
@@ -3164,9 +3117,8 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
target->GetDependTargets().find(*ct); target->GetDependTargets().find(*ct);
if (y != target->GetDependTargets().end()) { if (y != target->GetDependTargets().end()) {
std::vector<std::string> const& deptgts = y->second; std::vector<std::string> const& deptgts = y->second;
for (std::vector<std::string>::const_iterator d = deptgts.begin(); for (auto const& deptgt : deptgts) {
d != deptgts.end(); ++d) { makefileStream << this->PostBuildMakeTarget(deptgt, *ct) << ": "
makefileStream << this->PostBuildMakeTarget(*d, *ct) << ": "
<< trel << "\n"; << trel << "\n";
} }
} }
@@ -3188,9 +3140,8 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
target->GetDependLibraries().find(*ct); target->GetDependLibraries().find(*ct);
if (x != target->GetDependLibraries().end()) { if (x != target->GetDependLibraries().end()) {
std::vector<std::string> const& deplibs = x->second; std::vector<std::string> const& deplibs = x->second;
for (std::vector<std::string>::const_iterator d = deplibs.begin(); for (auto const& deplib : deplibs) {
d != deplibs.end(); ++d) { std::string file = this->ConvertToRelativeForMake(deplib.c_str());
std::string file = this->ConvertToRelativeForMake(d->c_str());
makefileStream << "\\\n\t" << file; makefileStream << "\\\n\t" << file;
dummyRules.insert(file); dummyRules.insert(file);
} }
@@ -3222,11 +3173,9 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
if (this->Architectures.size() > 1) { if (this->Architectures.size() > 1) {
std::string universal = this->GetObjectsNormalDirectory( std::string universal = this->GetObjectsNormalDirectory(
this->CurrentProject, configName, gt); this->CurrentProject, configName, gt);
for (std::vector<std::string>::iterator arch = for (auto& architecture : this->Architectures) {
this->Architectures.begin();
arch != this->Architectures.end(); ++arch) {
std::string universalFile = universal; std::string universalFile = universal;
universalFile += *arch; universalFile += architecture;
universalFile += "/"; universalFile += "/";
universalFile += gt->GetFullName(configName); universalFile += gt->GetFullName(configName);
makefileStream << "\t/bin/rm -f " makefileStream << "\t/bin/rm -f "
@@ -3243,9 +3192,8 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
makefileStream << "\n\n" makefileStream << "\n\n"
<< "# For each target create a dummy rule" << "# For each target create a dummy rule"
<< "so the target does not have to exist\n"; << "so the target does not have to exist\n";
for (std::set<std::string>::const_iterator it = dummyRules.begin(); for (auto const& dummyRule : dummyRules) {
it != dummyRules.end(); ++it) { makefileStream << dummyRule << ":\n";
makefileStream << *it << ":\n";
} }
} }
@@ -3256,9 +3204,8 @@ void cmGlobalXCodeGenerator::OutputXCodeProject(
return; return;
} }
// Skip local generators that are excluded from this project. // Skip local generators that are excluded from this project.
for (std::vector<cmLocalGenerator*>::iterator g = generators.begin(); for (auto& generator : generators) {
g != generators.end(); ++g) { if (this->IsExcluded(root, generator)) {
if (this->IsExcluded(root, *g)) {
continue; continue;
} }
} }
@@ -3511,11 +3458,10 @@ void cmGlobalXCodeGenerator::AppendDefines(
{ {
// GCC_PREPROCESSOR_DEFINITIONS is a space-separated list of definitions. // GCC_PREPROCESSOR_DEFINITIONS is a space-separated list of definitions.
std::string def; std::string def;
for (std::vector<std::string>::const_iterator di = defines.begin(); for (auto const& define : defines) {
di != defines.end(); ++di) {
// Start with -D if requested. // Start with -D if requested.
def = dflag ? "-D" : ""; def = dflag ? "-D" : "";
def += *di; def += define;
// Append the flag with needed escapes. // Append the flag with needed escapes.
std::string tmp; std::string tmp;

View File

@@ -43,9 +43,8 @@ void cmLocalXCodeGenerator::Generate()
cmLocalGenerator::Generate(); cmLocalGenerator::Generate();
const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets();
for (std::vector<cmGeneratorTarget*>::const_iterator iter = targets.begin(); for (auto target : targets) {
iter != targets.end(); ++iter) { target->HasMacOSXRpathInstallNameDir("");
(*iter)->HasMacOSXRpathInstallNameDir("");
} }
} }
@@ -54,9 +53,8 @@ void cmLocalXCodeGenerator::GenerateInstallRules()
cmLocalGenerator::GenerateInstallRules(); cmLocalGenerator::GenerateInstallRules();
const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets(); const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets();
for (std::vector<cmGeneratorTarget*>::const_iterator iter = targets.begin(); for (auto target : targets) {
iter != targets.end(); ++iter) { target->HasMacOSXRpathInstallNameDir("");
(*iter)->HasMacOSXRpathInstallNameDir("");
} }
} }
@@ -69,10 +67,8 @@ void cmLocalXCodeGenerator::ComputeObjectFilenames(
// to avoid exact duplicate file names. Note that Mac file names are not // to avoid exact duplicate file names. Note that Mac file names are not
// typically case sensitive, hence the LowerCase. // typically case sensitive, hence the LowerCase.
std::map<std::string, int> counts; std::map<std::string, int> counts;
for (std::map<cmSourceFile const*, std::string>::iterator si = for (auto& si : mapping) {
mapping.begin(); cmSourceFile const* sf = si.first;
si != mapping.end(); ++si) {
cmSourceFile const* sf = si->first;
std::string objectName = std::string objectName =
cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
objectName += ".o"; objectName += ".o";
@@ -82,6 +78,6 @@ void cmLocalXCodeGenerator::ComputeObjectFilenames(
if (2 == counts[objectNameLower]) { if (2 == counts[objectNameLower]) {
// TODO: emit warning about duplicate name? // TODO: emit warning about duplicate name?
} }
si->second = objectName; si.second = objectName;
} }
} }

View File

@@ -251,8 +251,7 @@ cmMachOInternal::cmMachOInternal(const char* fname)
} }
// parse each Mach-O file // parse each Mach-O file
for (size_t i = 0; i < this->FatArchs.size(); i++) { for (const auto& arch : this->FatArchs) {
const fat_arch& arch = this->FatArchs[i];
if (!this->read_mach_o(OSSwapBigToHostInt32(arch.offset))) { if (!this->read_mach_o(OSSwapBigToHostInt32(arch.offset))) {
return; return;
} }
@@ -265,8 +264,8 @@ cmMachOInternal::cmMachOInternal(const char* fname)
cmMachOInternal::~cmMachOInternal() cmMachOInternal::~cmMachOInternal()
{ {
for (size_t i = 0; i < this->MachOList.size(); i++) { for (auto& i : this->MachOList) {
delete this->MachOList[i]; delete i;
} }
} }

View File

@@ -34,9 +34,7 @@ void cmXCode21Object::PrintList(std::vector<cmXCodeObject*> const& v,
std::ostream& out, PBXType t) std::ostream& out, PBXType t)
{ {
bool hasOne = false; bool hasOne = false;
for (std::vector<cmXCodeObject*>::const_iterator i = v.begin(); i != v.end(); for (auto obj : v) {
++i) {
cmXCodeObject* obj = *i;
if (obj->GetType() == OBJECT && obj->GetIsA() == t) { if (obj->GetType() == OBJECT && obj->GetIsA() == t) {
hasOne = true; hasOne = true;
break; break;
@@ -46,9 +44,7 @@ void cmXCode21Object::PrintList(std::vector<cmXCodeObject*> const& v,
return; return;
} }
out << "\n/* Begin " << PBXTypeNames[t] << " section */\n"; out << "\n/* Begin " << PBXTypeNames[t] << " section */\n";
for (std::vector<cmXCodeObject*>::const_iterator i = v.begin(); i != v.end(); for (auto obj : v) {
++i) {
cmXCodeObject* obj = *i;
if (obj->GetType() == OBJECT && obj->GetIsA() == t) { if (obj->GetType() == OBJECT && obj->GetIsA() == t) {
obj->Print(out); obj->Print(out);
} }

View File

@@ -203,9 +203,9 @@ void cmXCodeObject::PrintList(std::vector<cmXCodeObject*> const& objs,
{ {
cmXCodeObject::Indent(1, out); cmXCodeObject::Indent(1, out);
out << "objects = {\n"; out << "objects = {\n";
for (unsigned int i = 0; i < objs.size(); ++i) { for (auto obj : objs) {
if (objs[i]->TypeValue == OBJECT) { if (obj->TypeValue == OBJECT) {
objs[i]->Print(out); obj->Print(out);
} }
} }
cmXCodeObject::Indent(1, out); cmXCodeObject::Indent(1, out);

View File

@@ -119,9 +119,7 @@ public:
// search the attribute list for an object of the specified type // search the attribute list for an object of the specified type
cmXCodeObject* GetObject(cmXCodeObject::PBXType t) const cmXCodeObject* GetObject(cmXCodeObject::PBXType t) const
{ {
for (std::vector<cmXCodeObject*>::const_iterator i = this->List.begin(); for (auto o : this->List) {
i != this->List.end(); ++i) {
cmXCodeObject* o = *i;
if (o->IsA == t) { if (o->IsA == t) {
return o; return o;
} }

View File

@@ -104,12 +104,11 @@ void cmXCodeScheme::WriteTestAction(cmXMLWriter& xout,
xout.Attribute("shouldUseLaunchSchemeArgsEnv", "YES"); xout.Attribute("shouldUseLaunchSchemeArgsEnv", "YES");
xout.StartElement("Testables"); xout.StartElement("Testables");
for (TestObjects::const_iterator it = this->Tests.begin(); for (auto test : this->Tests) {
it != this->Tests.end(); ++it) {
xout.StartElement("TestableReference"); xout.StartElement("TestableReference");
xout.BreakAttributes(); xout.BreakAttributes();
xout.Attribute("skipped", "NO"); xout.Attribute("skipped", "NO");
WriteBuildableReference(xout, *it, container); WriteBuildableReference(xout, test, container);
xout.EndElement(); // TestableReference xout.EndElement(); // TestableReference
} }
xout.EndElement(); xout.EndElement();