summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2019-03-27 15:50:17 +0100
committerSebastian Holtermann <sebholt@xwmw.org>2019-03-27 18:12:43 +0100
commit87341d8328c7b3a1d50cfd534ff4cb44334a2561 (patch)
tree83479c41db2da0c4282565927d60150f5e5ac727 /Source
parent5a15c9e7cb63fb5b884271a1184607a8fa87d442 (diff)
downloadcmake-87341d8328c7b3a1d50cfd534ff4cb44334a2561.tar.gz
cmDepends: Define DependencyMap instead of DependencyVector
In `cmDepends` use `typedef std::map<std::string, std::vector<std::string>> DependencyMap` instead of defining a `class DependencyVector : public std::vector<std::string>` and using it in `std::map<std::string, DependencyVector>`. Since `std::map<std::string, std::vector<std::string>>` is used in various other places, we now reuse all of it's auto generated methods. This doesn't happen when we use `DependencyVector` in a `std::map`, because it is a different class than `std::vector<std::string>`.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmDepends.cxx10
-rw-r--r--Source/cmDepends.h15
-rw-r--r--Source/cmDependsC.cxx8
-rw-r--r--Source/cmDependsC.h5
-rw-r--r--Source/cmDependsJava.cxx3
-rw-r--r--Source/cmDependsJava.h7
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx5
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.h11
8 files changed, 28 insertions, 36 deletions
diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx
index 334f1e56dc..ed76dbf47b 100644
--- a/Source/cmDepends.cxx
+++ b/Source/cmDepends.cxx
@@ -61,7 +61,7 @@ bool cmDepends::Finalize(std::ostream& /*unused*/, std::ostream& /*unused*/)
bool cmDepends::Check(const std::string& makeFile,
const std::string& internalFile,
- std::map<std::string, DependencyVector>& validDeps)
+ DependencyMap& validDeps)
{
// Check whether dependencies must be regenerated.
bool okay = true;
@@ -101,9 +101,9 @@ bool cmDepends::WriteDependencies(const std::set<std::string>& /*unused*/,
return false;
}
-bool cmDepends::CheckDependencies(
- std::istream& internalDepends, const std::string& internalDependsFileName,
- std::map<std::string, DependencyVector>& validDeps)
+bool cmDepends::CheckDependencies(std::istream& internalDepends,
+ const std::string& internalDependsFileName,
+ DependencyMap& validDeps)
{
// Read internal depends file time
cmFileTime internalDependsTime;
@@ -124,7 +124,7 @@ bool cmDepends::CheckDependencies(
std::string dependee;
cmFileTime dependerTime;
cmFileTime dependeeTime;
- DependencyVector* currentDependencies = nullptr;
+ std::vector<std::string>* currentDependencies = nullptr;
while (std::getline(internalDepends, line)) {
// Check if this an empty or a comment line
diff --git a/Source/cmDepends.h b/Source/cmDepends.h
index d9d5c67188..b7475f0aef 100644
--- a/Source/cmDepends.h
+++ b/Source/cmDepends.h
@@ -24,6 +24,9 @@ class cmLocalGenerator;
class cmDepends
{
public:
+ typedef std::map<std::string, std::vector<std::string>> DependencyMap;
+
+public:
/** Instances need to know the build directory name and the relative
path from the build directory to the target file. */
cmDepends(cmLocalGenerator* lg = nullptr, std::string targetDir = "");
@@ -55,17 +58,13 @@ public:
/** Write dependencies for the target file. */
bool Write(std::ostream& makeDepends, std::ostream& internalDepends);
- class DependencyVector : public std::vector<std::string>
- {
- };
-
/** Check dependencies for the target file. Returns true if
dependencies are okay and false if they must be generated. If
they must be generated Clear has already been called to wipe out
the old dependencies.
Dependencies which are still valid will be stored in validDeps. */
bool Check(const std::string& makeFile, const std::string& internalFile,
- std::map<std::string, DependencyVector>& validDeps);
+ DependencyMap& validDeps);
/** Clear dependencies for the target file so they will be regenerated. */
void Clear(const std::string& file);
@@ -84,9 +83,9 @@ protected:
// Check dependencies for the target file in the given stream.
// Return false if dependencies must be regenerated and true
// otherwise.
- virtual bool CheckDependencies(
- std::istream& internalDepends, const std::string& internalDependsFileName,
- std::map<std::string, DependencyVector>& validDeps);
+ virtual bool CheckDependencies(std::istream& internalDepends,
+ const std::string& internalDependsFileName,
+ DependencyMap& validDeps);
// Finalize the dependency information for the target.
virtual bool Finalize(std::ostream& makeDepends,
diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx
index 7b78767f28..dc49c18f83 100644
--- a/Source/cmDependsC.cxx
+++ b/Source/cmDependsC.cxx
@@ -21,9 +21,8 @@
cmDependsC::cmDependsC() = default;
-cmDependsC::cmDependsC(
- cmLocalGenerator* lg, const std::string& targetDir, const std::string& lang,
- const std::map<std::string, DependencyVector>* validDeps)
+cmDependsC::cmDependsC(cmLocalGenerator* lg, const std::string& targetDir,
+ const std::string& lang, const DependencyMap* validDeps)
: cmDepends(lg, targetDir)
, ValidDeps(validDeps)
{
@@ -102,8 +101,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
this->LocalGenerator->MaybeConvertToRelativePath(binDir, obj);
if (this->ValidDeps != nullptr) {
- std::map<std::string, DependencyVector>::const_iterator tmpIt =
- this->ValidDeps->find(obj_i);
+ auto const tmpIt = this->ValidDeps->find(obj_i);
if (tmpIt != this->ValidDeps->end()) {
dependencies.insert(tmpIt->second.begin(), tmpIt->second.end());
haveDeps = true;
diff --git a/Source/cmDependsC.h b/Source/cmDependsC.h
index eee5ae15cd..3fc839e430 100644
--- a/Source/cmDependsC.h
+++ b/Source/cmDependsC.h
@@ -27,8 +27,7 @@ public:
relative path from the build directory to the target file. */
cmDependsC();
cmDependsC(cmLocalGenerator* lg, const std::string& targetDir,
- const std::string& lang,
- const std::map<std::string, DependencyVector>* validDeps);
+ const std::string& lang, const DependencyMap* validDeps);
/** Virtual destructor to cleanup subclasses properly. */
~cmDependsC() override;
@@ -81,7 +80,7 @@ public:
};
protected:
- const std::map<std::string, DependencyVector>* ValidDeps = nullptr;
+ const DependencyMap* ValidDeps = nullptr;
std::set<std::string> Encountered;
std::queue<UnscannedEntry> Unscanned;
diff --git a/Source/cmDependsJava.cxx b/Source/cmDependsJava.cxx
index 2485e15fd7..b17b2ba74f 100644
--- a/Source/cmDependsJava.cxx
+++ b/Source/cmDependsJava.cxx
@@ -24,8 +24,7 @@ bool cmDependsJava::WriteDependencies(const std::set<std::string>& sources,
bool cmDependsJava::CheckDependencies(
std::istream& /*internalDepends*/,
- const std::string& /*internalDependsFileName*/,
- std::map<std::string, DependencyVector>& /*validDeps*/)
+ const std::string& /*internalDependsFileName*/, DependencyMap& /*validDeps*/)
{
return true;
}
diff --git a/Source/cmDependsJava.h b/Source/cmDependsJava.h
index 109ef13d16..dd671a1b6b 100644
--- a/Source/cmDependsJava.h
+++ b/Source/cmDependsJava.h
@@ -8,7 +8,6 @@
#include "cmDepends.h"
#include <iosfwd>
-#include <map>
#include <set>
#include <string>
@@ -33,9 +32,9 @@ protected:
bool WriteDependencies(const std::set<std::string>& sources,
const std::string& file, std::ostream& makeDepends,
std::ostream& internalDepends) override;
- bool CheckDependencies(
- std::istream& internalDepends, const std::string& internalDependsFileName,
- std::map<std::string, DependencyVector>& validDeps) override;
+ bool CheckDependencies(std::istream& internalDepends,
+ const std::string& internalDependsFileName,
+ DependencyMap& validDeps) override;
};
#endif
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index f3d5a9429e..2857d39fe9 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -1312,7 +1312,7 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(
// The build.make file may have explicit dependencies for the object
// files but these will not affect the scanning process so they need
// not be considered.
- std::map<std::string, cmDepends::DependencyVector> validDependencies;
+ cmDepends::DependencyMap validDependencies;
bool needRescanDependencies = false;
if (!needRescanDirInfo) {
cmDependsC checker;
@@ -1352,8 +1352,7 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(
bool cmLocalUnixMakefileGenerator3::ScanDependencies(
std::string const& targetDir, std::string const& dependFile,
- std::string const& internalDependFile,
- std::map<std::string, cmDepends::DependencyVector>& validDeps)
+ std::string const& internalDependFile, cmDepends::DependencyMap& validDeps)
{
// Read the directory information file.
cmMakefile* mf = this->Makefile;
diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h
index ba882da080..7a0ea98f67 100644
--- a/Source/cmLocalUnixMakefileGenerator3.h
+++ b/Source/cmLocalUnixMakefileGenerator3.h
@@ -143,8 +143,7 @@ public:
// File pairs for implicit dependency scanning. The key of the map
// is the depender and the value is the explicit dependee.
- struct ImplicitDependFileMap
- : public std::map<std::string, cmDepends::DependencyVector>
+ struct ImplicitDependFileMap : public cmDepends::DependencyMap
{
};
struct ImplicitDependLanguageMap
@@ -230,10 +229,10 @@ protected:
const char* filename = nullptr);
// Helper methods for dependency updates.
- bool ScanDependencies(
- std::string const& targetDir, std::string const& dependFile,
- std::string const& internalDependFile,
- std::map<std::string, cmDepends::DependencyVector>& validDeps);
+ bool ScanDependencies(std::string const& targetDir,
+ std::string const& dependFile,
+ std::string const& internalDependFile,
+ cmDepends::DependencyMap& validDeps);
void CheckMultipleOutputs(bool verbose);
private: