summaryrefslogtreecommitdiff
path: root/Source/cmDependsC.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmDependsC.cxx')
-rw-r--r--Source/cmDependsC.cxx52
1 files changed, 22 insertions, 30 deletions
diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx
index dc49c18f8..e30d9597d 100644
--- a/Source/cmDependsC.cxx
+++ b/Source/cmDependsC.cxx
@@ -2,13 +2,14 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmDependsC.h"
-#include "cmsys/FStream.hxx"
#include <utility>
-#include "cmAlgorithms.h"
+#include "cmsys/FStream.hxx"
+
#include "cmFileTime.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#define INCLUDE_REGEX_LINE \
@@ -35,15 +36,12 @@ cmDependsC::cmDependsC(cmLocalGenerator* lg, const std::string& targetDir,
std::string scanRegex = "^.*$";
std::string complainRegex = "^$";
{
- std::string scanRegexVar = "CMAKE_";
- scanRegexVar += lang;
- scanRegexVar += "_INCLUDE_REGEX_SCAN";
+ std::string scanRegexVar = cmStrCat("CMAKE_", lang, "_INCLUDE_REGEX_SCAN");
if (const char* sr = mf->GetDefinition(scanRegexVar)) {
scanRegex = sr;
}
- std::string complainRegexVar = "CMAKE_";
- complainRegexVar += lang;
- complainRegexVar += "_INCLUDE_REGEX_COMPLAIN";
+ std::string complainRegexVar =
+ cmStrCat("CMAKE_", lang, "_INCLUDE_REGEX_COMPLAIN");
if (const char* cr = mf->GetDefinition(complainRegexVar)) {
complainRegex = cr;
}
@@ -53,17 +51,15 @@ cmDependsC::cmDependsC(cmLocalGenerator* lg, const std::string& targetDir,
this->IncludeRegexScan.compile(scanRegex);
this->IncludeRegexComplain.compile(complainRegex);
this->IncludeRegexLineString = INCLUDE_REGEX_LINE_MARKER INCLUDE_REGEX_LINE;
- this->IncludeRegexScanString = INCLUDE_REGEX_SCAN_MARKER;
- this->IncludeRegexScanString += scanRegex;
- this->IncludeRegexComplainString = INCLUDE_REGEX_COMPLAIN_MARKER;
- this->IncludeRegexComplainString += complainRegex;
+ this->IncludeRegexScanString =
+ cmStrCat(INCLUDE_REGEX_SCAN_MARKER, scanRegex);
+ this->IncludeRegexComplainString =
+ cmStrCat(INCLUDE_REGEX_COMPLAIN_MARKER, complainRegex);
this->SetupTransforms();
- this->CacheFileName = this->TargetDirectory;
- this->CacheFileName += "/";
- this->CacheFileName += lang;
- this->CacheFileName += ".includecache";
+ this->CacheFileName =
+ cmStrCat(this->TargetDirectory, '/', lang, ".includecache");
this->ReadCacheFile();
}
@@ -71,7 +67,6 @@ cmDependsC::cmDependsC(cmLocalGenerator* lg, const std::string& targetDir,
cmDependsC::~cmDependsC()
{
this->WriteCacheFile();
- cmDeleteAll(this->FileCache);
}
bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
@@ -176,9 +171,9 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
// Check whether this file is already in the cache
auto fileIt = this->FileCache.find(fullName);
if (fileIt != this->FileCache.end()) {
- fileIt->second->Used = true;
+ fileIt->second.Used = true;
dependencies.insert(fullName);
- for (UnscannedEntry const& inc : fileIt->second->UnscannedEntries) {
+ for (UnscannedEntry const& inc : fileIt->second.UnscannedEntries) {
if (this->Encountered.find(inc.FileName) ==
this->Encountered.end()) {
this->Encountered.insert(inc.FileName);
@@ -264,8 +259,7 @@ void cmDependsC::ReadCacheFile()
if (res && newer) // cache is newer than the parsed file
{
- cacheEntry = new cmIncludeLines;
- this->FileCache[line] = cacheEntry;
+ cacheEntry = &this->FileCache[line];
}
// file doesn't exist, check that the regular expressions
// haven't changed
@@ -317,10 +311,10 @@ void cmDependsC::WriteCacheFile() const
cacheOut << this->IncludeRegexTransformString << "\n\n";
for (auto const& fileIt : this->FileCache) {
- if (fileIt.second->Used) {
+ if (fileIt.second.Used) {
cacheOut << fileIt.first << std::endl;
- for (UnscannedEntry const& inc : fileIt.second->UnscannedEntries) {
+ for (UnscannedEntry const& inc : fileIt.second.UnscannedEntries) {
cacheOut << inc.FileName << std::endl;
if (inc.QuotedLocation.empty()) {
cacheOut << "-" << std::endl;
@@ -336,9 +330,8 @@ void cmDependsC::WriteCacheFile() const
void cmDependsC::Scan(std::istream& is, const std::string& directory,
const std::string& fullName)
{
- cmIncludeLines* newCacheEntry = new cmIncludeLines;
- newCacheEntry->Used = true;
- this->FileCache[fullName] = newCacheEntry;
+ cmIncludeLines& newCacheEntry = this->FileCache[fullName];
+ newCacheEntry.Used = true;
// Read one line at a time.
std::string line;
@@ -374,7 +367,7 @@ void cmDependsC::Scan(std::istream& is, const std::string& directory,
// This kind of problem will be fixed when a more
// preprocessor-like implementation of this scanner is created.
if (this->IncludeRegexScan.find(entry.FileName)) {
- newCacheEntry->UnscannedEntries.push_back(entry);
+ newCacheEntry.UnscannedEntries.push_back(entry);
if (this->Encountered.find(entry.FileName) ==
this->Encountered.end()) {
this->Encountered.insert(entry.FileName);
@@ -391,7 +384,7 @@ void cmDependsC::SetupTransforms()
std::vector<std::string> transformRules;
cmMakefile* mf = this->LocalGenerator->GetMakefile();
if (const char* xform = mf->GetDefinition("CMAKE_INCLUDE_TRANSFORMS")) {
- cmSystemTools::ExpandListArgument(xform, transformRules, true);
+ cmExpandList(xform, transformRules, true);
}
for (std::string const& tr : transformRules) {
this->ParseTransform(tr);
@@ -442,8 +435,7 @@ void cmDependsC::TransformLine(std::string& line)
if (!this->IncludeRegexTransform.find(line)) {
return;
}
- TransformRulesType::const_iterator tri =
- this->TransformRules.find(this->IncludeRegexTransform.match(3));
+ auto tri = this->TransformRules.find(this->IncludeRegexTransform.match(3));
if (tri == this->TransformRules.end()) {
return;
}