Merge topic 'source-static-analysis-cleanups'

526c34c0b0 Source: Minor static-analysis cleanups

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !12150
This commit is contained in:
Brad King
2026-06-08 10:31:36 -04:00
committed by Kitware Robot
9 changed files with 16 additions and 28 deletions
+2 -6
View File
@@ -176,9 +176,7 @@ bool cmDependsC::WriteDependencies(std::set<std::string> const& sources,
fileIt->second.Used = true;
dependencies.insert(fullName);
for (UnscannedEntry const& inc : fileIt->second.UnscannedEntries) {
if (this->Encountered.find(inc.FileName) ==
this->Encountered.end()) {
this->Encountered.insert(inc.FileName);
if (this->Encountered.insert(inc.FileName).second) {
this->Unscanned.push(inc);
}
}
@@ -382,9 +380,7 @@ void cmDependsC::Scan(std::istream& is, std::string const& directory,
// preprocessor-like implementation of this scanner is created.
if (this->IncludeRegexScan.find(entry.FileName)) {
newCacheEntry.UnscannedEntries.push_back(entry);
if (this->Encountered.find(entry.FileName) ==
this->Encountered.end()) {
this->Encountered.insert(entry.FileName);
if (this->Encountered.insert(entry.FileName).second) {
this->Unscanned.push(entry);
}
}
+1 -1
View File
@@ -87,7 +87,7 @@ cmDependsFortran::cmDependsFortran(cmLocalUnixMakefileGenerator3* lg)
for (std::string def : definitions) {
std::string::size_type assignment = def.find('=');
if (assignment != std::string::npos) {
def = def.substr(0, assignment);
def.resize(assignment);
}
this->PPDefinitions.insert(def);
}
+4 -8
View File
@@ -591,8 +591,7 @@ void cmExtraEclipseCDT4Generator::AppendIncludeDirectories(
dir = frameworkRx.match(1);
}
if (emittedDirs.find(dir) == emittedDirs.end()) {
emittedDirs.insert(dir);
if (emittedDirs.insert(dir).second) {
xml.StartElement("pathentry");
xml.Attribute("include",
cmExtraEclipseCDT4Generator::GetEclipsePath(dir));
@@ -783,8 +782,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
}
// insert the definition if not already added.
if (emitted.find(def) == emitted.end()) {
emitted.insert(def);
if (emitted.insert(def).second) {
xml.StartElement("pathentry");
xml.Attribute("kind", "mac");
xml.Attribute("name", def);
@@ -815,8 +813,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
}
// insert the definition if not already added.
if (emitted.find(def) == emitted.end()) {
emitted.insert(def);
if (emitted.insert(def).second) {
xml.StartElement("pathentry");
xml.Attribute("kind", "mac");
xml.Attribute("name", def);
@@ -847,8 +844,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
}
// insert the definition if not already added.
if (emitted.find(def) == emitted.end()) {
emitted.insert(def);
if (emitted.insert(def).second) {
xml.StartElement("pathentry");
xml.Attribute("kind", "mac");
xml.Attribute("name", def);
+1 -1
View File
@@ -5193,7 +5193,7 @@ std::string cmGeneratorTarget::CheckCMP0004(std::string const& item) const
}
pos = lib.find_last_not_of(" \t\r\n");
if (pos != std::string::npos) {
lib = lib.substr(0, pos + 1);
lib.resize(pos + 1);
}
if (lib != item) {
cmake* cm = this->LocalGenerator->GetCMakeInstance();
+1 -3
View File
@@ -134,8 +134,6 @@ void cmLinkItemGraphVisitor::GetDependencies(cmGeneratorTarget const& target,
auto const& utilityItems = target.GetUtilityItems();
for (auto const& item : utilityItems) {
auto const& name = item.AsStr();
if (dependencies.find(name) == dependencies.cend()) {
dependencies[name] = Dependency(DependencyType::Utility, item);
}
dependencies.emplace(name, Dependency(DependencyType::Utility, item));
}
}
+2 -2
View File
@@ -1360,10 +1360,10 @@ std::string cmLocalUnixMakefileGenerator3::CreateMakeVariable(
// we must shorten the combined string by 4 characters
// keep no more than 24 characters from the second string
if (static_cast<int>(str2.size()) > keep) {
str2 = str2.substr(0, keep);
str2.resize(keep);
}
if (static_cast<int>(str1.size()) + static_cast<int>(str2.size()) > size) {
str1 = str1.substr(0, size - str2.size());
str1.resize(size - str2.size());
}
char buffer[12];
int ni = 0;
+1 -1
View File
@@ -252,7 +252,7 @@ static bool RccListParseOutput(std::string const& rccStdOut,
auto StripCR = [](std::string& line) {
std::string::size_type cr = line.find('\r');
if (cr != std::string::npos) {
line = line.substr(0, cr);
line.resize(cr);
}
};
+2 -4
View File
@@ -2588,10 +2588,8 @@ bool cmQtAutoGenInitializer::GetQtExecutable(GenVarsT& genVars,
if (this->MultiConfig && this->UseBetterGraph) {
for (auto const& config : this->ConfigsList) {
if (!genVars.ExecutableFeatures.Config[config]) {
if (!genVars.ExecutableFeatures.Config[config]) {
print_err(err);
return false;
}
print_err(err);
return false;
}
}
} else {
+2 -2
View File
@@ -1824,7 +1824,7 @@ bool cmSystemTools::SimpleGlob(std::string const& glob,
}
std::string path = cmSystemTools::GetFilenamePath(glob);
std::string ppath = cmSystemTools::GetFilenameName(glob);
ppath = ppath.substr(0, ppath.size() - 1);
ppath.pop_back();
if (path.empty()) {
path = "/";
}
@@ -2148,7 +2148,7 @@ cmSystemTools::SaveRestoreEnvironment::~SaveRestoreEnvironment()
for (std::string var : currentEnv) {
std::string::size_type pos = var.find('=');
if (pos != std::string::npos) {
var = var.substr(0, pos);
var.resize(pos);
}
cmSystemTools::UnsetEnv(var.c_str());