summaryrefslogtreecommitdiffstats
path: root/Source/cmDependsFortran.cxx
diff options
context:
space:
mode:
authorPavel Solodovnikov <hellyeahdominate@gmail.com>2017-09-11 10:40:26 (GMT)
committerPavel Solodovnikov <hellyeahdominate@gmail.com>2017-09-12 13:22:47 (GMT)
commit7d5095796ab616cf9b709036387bb95ab9984141 (patch)
treec010e922adad95ef86ab4a3ac2a3abd63e9f33ef /Source/cmDependsFortran.cxx
parent00975e926199eea21763470e2ab876246e36669a (diff)
downloadCMake-7d5095796ab616cf9b709036387bb95ab9984141.zip
CMake-7d5095796ab616cf9b709036387bb95ab9984141.tar.gz
CMake-7d5095796ab616cf9b709036387bb95ab9984141.tar.bz2
Meta: modernize old-fashioned loops to range-based `for`.
Changes done via `clang-tidy` with some manual fine-tuning for the variable naming and `auto` type deduction where appropriate.
Diffstat (limited to 'Source/cmDependsFortran.cxx')
-rw-r--r--Source/cmDependsFortran.cxx91
1 files changed, 37 insertions, 54 deletions
diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx
index e149a19..f209f3c 100644
--- a/Source/cmDependsFortran.cxx
+++ b/Source/cmDependsFortran.cxx
@@ -73,12 +73,10 @@ cmDependsFortran::cmDependsFortran(cmLocalGenerator* lg)
// translate i.e. FOO=BAR to FOO and add it to the list of defined
// preprocessor symbols
- for (std::vector<std::string>::const_iterator it = definitions.begin();
- it != definitions.end(); ++it) {
- std::string def = *it;
+ for (std::string def : definitions) {
std::string::size_type assignment = def.find('=');
if (assignment != std::string::npos) {
- def = it->substr(0, assignment);
+ def = def.substr(0, assignment);
}
this->PPDefinitions.insert(def);
}
@@ -105,9 +103,7 @@ bool cmDependsFortran::WriteDependencies(const std::set<std::string>& sources,
}
bool okay = true;
- for (std::set<std::string>::const_iterator it = sources.begin();
- it != sources.end(); ++it) {
- const std::string& src = *it;
+ for (std::string const& src : sources) {
// Get the information object for this source.
cmFortranSourceInfo& info =
this->Internal->CreateObjectInfo(obj.c_str(), src.c_str());
@@ -154,9 +150,8 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
// Actually write dependencies to the streams.
typedef cmDependsFortranInternals::ObjectInfoMap ObjectInfoMap;
ObjectInfoMap const& objInfo = this->Internal->ObjectInfo;
- for (ObjectInfoMap::const_iterator i = objInfo.begin(); i != objInfo.end();
- ++i) {
- if (!this->WriteDependenciesReal(i->first.c_str(), i->second, mod_dir,
+ for (auto const& i : objInfo) {
+ if (!this->WriteDependenciesReal(i.first.c_str(), i.second, mod_dir,
stamp_dir, makeDepends,
internalDepends)) {
return false;
@@ -170,9 +165,8 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
fiStream << "# The fortran modules provided by this target.\n";
fiStream << "provides\n";
std::set<std::string> const& provides = this->Internal->TargetProvides;
- for (std::set<std::string>::const_iterator i = provides.begin();
- i != provides.end(); ++i) {
- fiStream << " " << *i << "\n";
+ for (std::string const& i : provides) {
+ fiStream << " " << i << "\n";
}
// Create a script to clean the modules.
@@ -184,19 +178,18 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
fcStream << "FILE(REMOVE";
std::string currentBinDir =
this->LocalGenerator->GetCurrentBinaryDirectory();
- for (std::set<std::string>::const_iterator i = provides.begin();
- i != provides.end(); ++i) {
+ for (std::string const& i : provides) {
std::string mod_upper = mod_dir;
mod_upper += "/";
- mod_upper += cmSystemTools::UpperCase(*i);
+ mod_upper += cmSystemTools::UpperCase(i);
mod_upper += ".mod";
std::string mod_lower = mod_dir;
mod_lower += "/";
- mod_lower += *i;
+ mod_lower += i;
mod_lower += ".mod";
std::string stamp = stamp_dir;
stamp += "/";
- stamp += *i;
+ stamp += i;
stamp += ".mod.stamp";
fcStream << "\n";
fcStream << " \""
@@ -219,16 +212,14 @@ void cmDependsFortran::LocateModules()
// Collect the set of modules provided and required by all sources.
typedef cmDependsFortranInternals::ObjectInfoMap ObjectInfoMap;
ObjectInfoMap const& objInfo = this->Internal->ObjectInfo;
- for (ObjectInfoMap::const_iterator infoI = objInfo.begin();
- infoI != objInfo.end(); ++infoI) {
- cmFortranSourceInfo const& info = infoI->second;
+ for (auto const& infoI : objInfo) {
+ cmFortranSourceInfo const& info = infoI.second;
// Include this module in the set provided by this target.
this->Internal->TargetProvides.insert(info.Provides.begin(),
info.Provides.end());
- for (std::set<std::string>::const_iterator i = info.Requires.begin();
- i != info.Requires.end(); ++i) {
- this->Internal->TargetRequires[*i] = "";
+ for (std::string const& r : info.Requires) {
+ this->Internal->TargetRequires[r] = "";
}
}
@@ -247,9 +238,8 @@ void cmDependsFortran::LocateModules()
mf->GetDefinition("CMAKE_TARGET_LINKED_INFO_FILES")) {
cmSystemTools::ExpandListArgument(infoFilesValue, infoFiles);
}
- for (std::vector<std::string>::const_iterator i = infoFiles.begin();
- i != infoFiles.end(); ++i) {
- std::string targetDir = cmSystemTools::GetFilenamePath(*i);
+ for (std::string const& i : infoFiles) {
+ std::string targetDir = cmSystemTools::GetFilenamePath(i);
std::string fname = targetDir + "/fortran.internal";
cmsys::ifstream fin(fname.c_str());
if (fin) {
@@ -262,9 +252,8 @@ void cmDependsFortran::MatchLocalModules()
{
const char* stampDir = this->TargetDirectory.c_str();
std::set<std::string> const& provides = this->Internal->TargetProvides;
- for (std::set<std::string>::const_iterator i = provides.begin();
- i != provides.end(); ++i) {
- this->ConsiderModule(i->c_str(), stampDir);
+ for (std::string const& i : provides) {
+ this->ConsiderModule(i.c_str(), stampDir);
}
}
@@ -326,35 +315,32 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
std::string obj_m = cmSystemTools::ConvertToOutputPath(obj_i.c_str());
internalDepends << obj_i << std::endl;
internalDepends << " " << src << std::endl;
- for (std::set<std::string>::const_iterator i = info.Includes.begin();
- i != info.Includes.end(); ++i) {
+ for (std::string const& i : info.Includes) {
makeDepends << obj_m << ": "
<< cmSystemTools::ConvertToOutputPath(
- this->MaybeConvertToRelativePath(binDir, *i).c_str())
+ this->MaybeConvertToRelativePath(binDir, i).c_str())
<< std::endl;
- internalDepends << " " << *i << std::endl;
+ internalDepends << " " << i << std::endl;
}
makeDepends << std::endl;
// Write module requirements to the output stream.
- for (std::set<std::string>::const_iterator i = info.Requires.begin();
- i != info.Requires.end(); ++i) {
+ for (std::string const& i : info.Requires) {
// Require only modules not provided in the same source.
- if (std::set<std::string>::const_iterator(info.Provides.find(*i)) !=
- info.Provides.end()) {
+ if (info.Provides.find(i) != info.Provides.cend()) {
continue;
}
// If the module is provided in this target special handling is
// needed.
- if (this->Internal->TargetProvides.find(*i) !=
+ if (this->Internal->TargetProvides.find(i) !=
this->Internal->TargetProvides.end()) {
// The module is provided by a different source in the same
// target. Add the proxy dependency to make sure the other
// source builds first.
std::string proxy = stamp_dir;
proxy += "/";
- proxy += *i;
+ proxy += i;
proxy += ".mod.proxy";
proxy = cmSystemTools::ConvertToOutputPath(
this->MaybeConvertToRelativePath(binDir, proxy).c_str());
@@ -366,7 +352,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
// The object file should depend on timestamped files for the
// modules it uses.
TargetRequiresMap::const_iterator required =
- this->Internal->TargetRequires.find(*i);
+ this->Internal->TargetRequires.find(i);
if (required == this->Internal->TargetRequires.end()) {
abort();
}
@@ -379,7 +365,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
// This module is not known to CMake. Try to locate it where
// the compiler will and depend on that.
std::string module;
- if (this->FindModule(*i, module)) {
+ if (this->FindModule(i, module)) {
module = cmSystemTools::ConvertToOutputPath(
this->MaybeConvertToRelativePath(binDir, module).c_str());
makeDepends << obj_m << ": " << module << "\n";
@@ -388,11 +374,10 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
}
// Write provided modules to the output stream.
- for (std::set<std::string>::const_iterator i = info.Provides.begin();
- i != info.Provides.end(); ++i) {
+ for (std::string const& i : info.Provides) {
std::string proxy = stamp_dir;
proxy += "/";
- proxy += *i;
+ proxy += i;
proxy += ".mod.proxy";
proxy = cmSystemTools::ConvertToOutputPath(
this->MaybeConvertToRelativePath(binDir, proxy).c_str());
@@ -404,18 +389,17 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
// Create a target to copy the module after the object file
// changes.
makeDepends << obj_m << ".provides.build:\n";
- for (std::set<std::string>::const_iterator i = info.Provides.begin();
- i != info.Provides.end(); ++i) {
+ for (std::string const& i : info.Provides) {
// Include this module in the set provided by this target.
- this->Internal->TargetProvides.insert(*i);
+ this->Internal->TargetProvides.insert(i);
// Always use lower case for the mod stamp file name. The
// cmake_copy_f90_mod will call back to this class, which will
// try various cases for the real mod file name.
- std::string m = cmSystemTools::LowerCase(*i);
+ std::string m = cmSystemTools::LowerCase(i);
std::string modFile = mod_dir;
modFile += "/";
- modFile += *i;
+ modFile += i;
modFile = this->LocalGenerator->ConvertToOutputFormat(
this->MaybeConvertToRelativePath(binDir, modFile),
cmOutputConverter::SHELL);
@@ -462,10 +446,9 @@ bool cmDependsFortran::FindModule(std::string const& name, std::string& module)
// Search the include path for the module.
std::string fullName;
- for (std::vector<std::string>::const_iterator i = this->IncludePath.begin();
- i != this->IncludePath.end(); ++i) {
+ for (std::string const& ip : this->IncludePath) {
// Try the lower-case name.
- fullName = *i;
+ fullName = ip;
fullName += "/";
fullName += mod_lower;
if (cmSystemTools::FileExists(fullName.c_str(), true)) {
@@ -474,7 +457,7 @@ bool cmDependsFortran::FindModule(std::string const& name, std::string& module)
}
// Try the upper-case name.
- fullName = *i;
+ fullName = ip;
fullName += "/";
fullName += mod_upper;
if (cmSystemTools::FileExists(fullName.c_str(), true)) {