summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.clang-tidy11
-rw-r--r--Source/CPack/IFW/cmCPackIFWCommon.cxx8
-rw-r--r--Source/CPack/IFW/cmCPackIFWCommon.h8
-rw-r--r--Source/CPack/IFW/cmCPackIFWRepository.cxx4
-rw-r--r--Source/CPack/IFW/cmCPackIFWRepository.h4
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx2
-rw-r--r--Source/CTest/cmCTestLaunch.cxx2
-rw-r--r--Source/CTest/cmCTestLaunch.h2
-rw-r--r--Source/CTest/cmCTestLaunchReporter.cxx2
-rw-r--r--Source/CTest/cmCTestLaunchReporter.h2
-rw-r--r--Source/CTest/cmCTestMemCheckHandler.cxx2
-rw-r--r--Source/CTest/cmCTestMemCheckHandler.h2
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx12
-rw-r--r--Source/CTest/cmCTestResourceGroupsLexerHelper.cxx2
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx2
-rw-r--r--Source/CTest/cmProcess.cxx14
-rw-r--r--Source/CTest/cmProcess.h4
-rw-r--r--Source/CursesDialog/cmCursesMainForm.cxx4
-rw-r--r--Source/cmAuxSourceDirectoryCommand.cxx2
-rw-r--r--Source/cmBase32.cxx2
-rw-r--r--Source/cmBase32.h3
-rw-r--r--Source/cmCMakePathCommand.cxx2
-rw-r--r--Source/cmCMakePresetsFile.cxx20
-rw-r--r--Source/cmCPluginAPI.cxx6
-rw-r--r--Source/cmCacheManager.cxx4
-rw-r--r--Source/cmCacheManager.h20
-rw-r--r--Source/cmCommandArgumentParserHelper.cxx2
-rw-r--r--Source/cmComputeLinkInformation.cxx3
-rw-r--r--Source/cmConsoleBuf.cxx2
-rw-r--r--Source/cmConsoleBuf.h2
-rw-r--r--Source/cmDepends.cxx2
-rw-r--r--Source/cmDepends.h3
-rw-r--r--Source/cmDependsJavaParserHelper.cxx2
-rw-r--r--Source/cmDependsJavaParserHelper.h2
-rw-r--r--Source/cmExecuteProcessCommand.cxx2
-rw-r--r--Source/cmExportFileGenerator.cxx2
-rw-r--r--Source/cmExprParserHelper.h2
-rw-r--r--Source/cmExtraCodeBlocksGenerator.cxx2
-rw-r--r--Source/cmExtraCodeLiteGenerator.h1
-rw-r--r--Source/cmFileAPICodemodel.cxx2
-rw-r--r--Source/cmFileCommand.cxx5
-rw-r--r--Source/cmFileLock.cxx2
-rw-r--r--Source/cmFileLock.h2
-rw-r--r--Source/cmFileLockPool.cxx11
-rw-r--r--Source/cmFileLockUnix.cxx2
-rw-r--r--Source/cmFindPackageCommand.cxx29
-rw-r--r--Source/cmFindPathCommand.cxx4
-rw-r--r--Source/cmFindPathCommand.h2
-rw-r--r--Source/cmFindProgramCommand.cxx65
-rw-r--r--Source/cmFunctionBlocker.h1
-rw-r--r--Source/cmGeneratorExpressionDAGChecker.h1
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.h1
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx6
-rw-r--r--Source/cmGeneratorExpressionEvaluator.h1
-rw-r--r--Source/cmGeneratorExpressionParser.h1
-rw-r--r--Source/cmGeneratorTarget.cxx4
-rw-r--r--Source/cmGhsMultiTargetGenerator.cxx22
-rw-r--r--Source/cmGlobalGenerator.cxx8
-rw-r--r--Source/cmGlobalGhsMultiGenerator.cxx2
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx48
-rw-r--r--Source/cmGlobalNinjaGenerator.h2
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.h4
-rw-r--r--Source/cmGraphVizWriter.cxx38
-rw-r--r--Source/cmInstallCommand.cxx88
-rw-r--r--Source/cmInstallCommandArguments.cxx13
-rw-r--r--Source/cmInstallScriptGenerator.cxx5
-rw-r--r--Source/cmInstallScriptGenerator.h2
-rw-r--r--Source/cmLinkItemGraphVisitor.cxx5
-rw-r--r--Source/cmLinkLineDeviceComputer.cxx19
-rw-r--r--Source/cmListFileCache.cxx4
-rw-r--r--Source/cmLoadCommandCommand.cxx3
-rw-r--r--Source/cmLocalGenerator.cxx54
-rw-r--r--Source/cmLocalGenerator.h2
-rw-r--r--Source/cmLocalNinjaGenerator.cxx1
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx6
-rw-r--r--Source/cmMakefile.cxx4
-rw-r--r--Source/cmNinjaNormalTargetGenerator.h1
-rw-r--r--Source/cmOSXBundleGenerator.h1
-rw-r--r--Source/cmOutputConverter.cxx41
-rw-r--r--Source/cmOutputConverter.h9
-rw-r--r--Source/cmOutputRequiredFilesCommand.cxx2
-rw-r--r--Source/cmProcessOutput.cxx2
-rw-r--r--Source/cmProcessOutput.h2
-rw-r--r--Source/cmQtAutoGen.h1
-rw-r--r--Source/cmQtAutoGenGlobalInitializer.h2
-rw-r--r--Source/cmQtAutoGenInitializer.h2
-rw-r--r--Source/cmQtAutoGenerator.cxx2
-rw-r--r--Source/cmQtAutoGenerator.h5
-rw-r--r--Source/cmQtAutoMocUic.cxx70
-rw-r--r--Source/cmQtAutoRcc.cxx1
-rw-r--r--Source/cmRuntimeDependencyArchive.cxx11
-rw-r--r--Source/cmScriptGenerator.cxx12
-rw-r--r--Source/cmSetPropertyCommand.cxx6
-rw-r--r--Source/cmSetSourceFilesPropertiesCommand.cxx2
-rw-r--r--Source/cmSourceFile.cxx2
-rw-r--r--Source/cmSourceFileLocation.cxx4
-rw-r--r--Source/cmStandardLexer.h4
-rw-r--r--Source/cmState.cxx11
-rw-r--r--Source/cmStateDirectory.h1
-rw-r--r--Source/cmString.cxx1
-rw-r--r--Source/cmStringAlgorithms.cxx4
-rw-r--r--Source/cmStringCommand.cxx1
-rw-r--r--Source/cmSystemTools.cxx2
-rw-r--r--Source/cmTarget.cxx7
-rw-r--r--Source/cmTarget.h1
-rw-r--r--Source/cmTimestamp.cxx6
-rw-r--r--Source/cmTimestamp.h4
-rw-r--r--Source/cmUVHandlePtr.cxx5
-rw-r--r--Source/cmUVHandlePtr.h4
-rw-r--r--Source/cmVersion.h8
-rw-r--r--Source/cmWorkerPool.cxx14
-rw-r--r--Source/cmWorkerPool.h2
-rw-r--r--Source/cmXMLSafe.cxx2
-rw-r--r--Source/cmXMLSafe.h2
-rw-r--r--Source/cmXMLWriter.h2
-rw-r--r--Source/cmcmd.cxx4
-rw-r--r--Tests/CMakeLib/run_compile_commands.cxx2
117 files changed, 426 insertions, 481 deletions
diff --git a/.clang-tidy b/.clang-tidy
index 11e1726..5e513fb 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -4,9 +4,6 @@ bugprone-*,\
-bugprone-macro-parentheses,\
-bugprone-misplaced-widening-cast,\
-bugprone-narrowing-conversions,\
--bugprone-reserved-identifier,\
--bugprone-signed-char-misuse,\
--bugprone-suspicious-include,\
-bugprone-too-small-loop-variable,\
google-readability-casting,\
misc-*,\
@@ -20,8 +17,6 @@ modernize-*,\
-modernize-use-trailing-return-type,\
-modernize-use-transparent-functors,\
performance-*,\
--performance-no-automatic-move,\
--performance-trivially-destructible,\
readability-*,\
-readability-convert-member-functions-to-static,\
-readability-function-size,\
@@ -29,15 +24,9 @@ readability-*,\
-readability-implicit-bool-conversion,\
-readability-inconsistent-declaration-parameter-name,\
-readability-magic-numbers,\
--readability-make-member-function-const,\
-readability-named-parameter,\
--readability-qualified-auto,\
--readability-redundant-access-specifiers,\
-readability-redundant-declaration,\
--readability-redundant-string-init,\
--readability-simplify-boolean-expr,\
-readability-uppercase-literal-suffix,\
--readability-use-anyofallof,\
"
HeaderFilterRegex: 'Source/cm[^/]*\.(h|hxx|cxx)$'
CheckOptions:
diff --git a/Source/CPack/IFW/cmCPackIFWCommon.cxx b/Source/CPack/IFW/cmCPackIFWCommon.cxx
index 20d392d..87ebbfe 100644
--- a/Source/CPack/IFW/cmCPackIFWCommon.cxx
+++ b/Source/CPack/IFW/cmCPackIFWCommon.cxx
@@ -44,7 +44,7 @@ bool cmCPackIFWCommon::IsSetToEmpty(const std::string& op) const
: false;
}
-bool cmCPackIFWCommon::IsVersionLess(const char* version)
+bool cmCPackIFWCommon::IsVersionLess(const char* version) const
{
if (!this->Generator) {
return false;
@@ -54,7 +54,7 @@ bool cmCPackIFWCommon::IsVersionLess(const char* version)
cmSystemTools::OP_LESS, this->Generator->FrameworkVersion.data(), version);
}
-bool cmCPackIFWCommon::IsVersionGreater(const char* version)
+bool cmCPackIFWCommon::IsVersionGreater(const char* version) const
{
if (!this->Generator) {
return false;
@@ -65,7 +65,7 @@ bool cmCPackIFWCommon::IsVersionGreater(const char* version)
version);
}
-bool cmCPackIFWCommon::IsVersionEqual(const char* version)
+bool cmCPackIFWCommon::IsVersionEqual(const char* version) const
{
if (!this->Generator) {
return false;
@@ -118,7 +118,7 @@ void cmCPackIFWCommon::ExpandListArgument(
}
}
-void cmCPackIFWCommon::WriteGeneratedByToStrim(cmXMLWriter& xout)
+void cmCPackIFWCommon::WriteGeneratedByToStrim(cmXMLWriter& xout) const
{
if (!this->Generator) {
return;
diff --git a/Source/CPack/IFW/cmCPackIFWCommon.h b/Source/CPack/IFW/cmCPackIFWCommon.h
index 95ed213..42deda4 100644
--- a/Source/CPack/IFW/cmCPackIFWCommon.h
+++ b/Source/CPack/IFW/cmCPackIFWCommon.h
@@ -34,17 +34,17 @@ public:
/**
* Compare \a version with QtIFW framework version
*/
- bool IsVersionLess(const char* version);
+ bool IsVersionLess(const char* version) const;
/**
* Compare \a version with QtIFW framework version
*/
- bool IsVersionGreater(const char* version);
+ bool IsVersionGreater(const char* version) const;
/**
* Compare \a version with QtIFW framework version
*/
- bool IsVersionEqual(const char* version);
+ bool IsVersionEqual(const char* version) const;
/** Expand the list argument containing the map of the key-value pairs.
* If the number of elements is odd, then the first value is used as the
@@ -64,7 +64,7 @@ public:
cmCPackIFWGenerator* Generator;
protected:
- void WriteGeneratedByToStrim(cmXMLWriter& xout);
+ void WriteGeneratedByToStrim(cmXMLWriter& xout) const;
};
#define cmCPackIFWLogger(logType, msg) \
diff --git a/Source/CPack/IFW/cmCPackIFWRepository.cxx b/Source/CPack/IFW/cmCPackIFWRepository.cxx
index 1287907..7ec2256 100644
--- a/Source/CPack/IFW/cmCPackIFWRepository.cxx
+++ b/Source/CPack/IFW/cmCPackIFWRepository.cxx
@@ -199,7 +199,7 @@ bool cmCPackIFWRepository::PatchUpdatesXml()
return cmSystemTools::RenameFile(updatesPatchXml, updatesXml);
}
-void cmCPackIFWRepository::WriteRepositoryConfig(cmXMLWriter& xout)
+void cmCPackIFWRepository::WriteRepositoryConfig(cmXMLWriter& xout) const
{
xout.StartElement("Repository");
@@ -225,7 +225,7 @@ void cmCPackIFWRepository::WriteRepositoryConfig(cmXMLWriter& xout)
xout.EndElement();
}
-void cmCPackIFWRepository::WriteRepositoryUpdate(cmXMLWriter& xout)
+void cmCPackIFWRepository::WriteRepositoryUpdate(cmXMLWriter& xout) const
{
xout.StartElement("Repository");
diff --git a/Source/CPack/IFW/cmCPackIFWRepository.h b/Source/CPack/IFW/cmCPackIFWRepository.h
index 21afd8b..0153452 100644
--- a/Source/CPack/IFW/cmCPackIFWRepository.h
+++ b/Source/CPack/IFW/cmCPackIFWRepository.h
@@ -76,8 +76,8 @@ public:
bool PatchUpdatesXml();
- void WriteRepositoryConfig(cmXMLWriter& xout);
- void WriteRepositoryUpdate(cmXMLWriter& xout);
+ void WriteRepositoryConfig(cmXMLWriter& xout) const;
+ void WriteRepositoryUpdate(cmXMLWriter& xout) const;
void WriteRepositoryUpdates(cmXMLWriter& xout);
RepositoriesVector RepositoryUpdate;
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index 5fb52bf..3d7d031 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -107,7 +107,7 @@ public:
this->PipeState = cmsysProcess_WaitForExit(this->Process, timeout);
return this->PipeState;
}
- int GetProcessState() { return this->PipeState; }
+ int GetProcessState() const { return this->PipeState; }
private:
int PipeState;
diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx
index b9ed033..15c443a 100644
--- a/Source/CTest/cmCTestLaunch.cxx
+++ b/Source/CTest/cmCTestLaunch.cxx
@@ -265,7 +265,7 @@ void cmCTestLaunch::LoadScrapeRules()
}
void cmCTestLaunch::LoadScrapeRules(
- const char* purpose, std::vector<cmsys::RegularExpression>& regexps)
+ const char* purpose, std::vector<cmsys::RegularExpression>& regexps) const
{
std::string fname =
cmStrCat(this->Reporter.LogDir, "Custom", purpose, ".txt");
diff --git a/Source/CTest/cmCTestLaunch.h b/Source/CTest/cmCTestLaunch.h
index d18f66d..eabb608 100644
--- a/Source/CTest/cmCTestLaunch.h
+++ b/Source/CTest/cmCTestLaunch.h
@@ -60,7 +60,7 @@ private:
bool ScrapeRulesLoaded;
void LoadScrapeRules();
void LoadScrapeRules(const char* purpose,
- std::vector<cmsys::RegularExpression>& regexps);
+ std::vector<cmsys::RegularExpression>& regexps) const;
bool ScrapeLog(std::string const& fname);
// Helper class to generate the xml fragment.
diff --git a/Source/CTest/cmCTestLaunchReporter.cxx b/Source/CTest/cmCTestLaunchReporter.cxx
index f89fc9b..5334a93 100644
--- a/Source/CTest/cmCTestLaunchReporter.cxx
+++ b/Source/CTest/cmCTestLaunchReporter.cxx
@@ -150,7 +150,7 @@ void cmCTestLaunchReporter::WriteXML()
this->WriteXMLLabels(e2);
}
-void cmCTestLaunchReporter::WriteXMLAction(cmXMLElement& e2)
+void cmCTestLaunchReporter::WriteXMLAction(cmXMLElement& e2) const
{
e2.Comment("Meta-information about the build action");
cmXMLElement e3(e2, "Action");
diff --git a/Source/CTest/cmCTestLaunchReporter.h b/Source/CTest/cmCTestLaunchReporter.h
index 675a878..4be0d9b 100644
--- a/Source/CTest/cmCTestLaunchReporter.h
+++ b/Source/CTest/cmCTestLaunchReporter.h
@@ -70,7 +70,7 @@ public:
// Methods to generate the xml fragment.
void WriteXML();
- void WriteXMLAction(cmXMLElement&);
+ void WriteXMLAction(cmXMLElement&) const;
void WriteXMLCommand(cmXMLElement&);
void WriteXMLResult(cmXMLElement&);
void WriteXMLLabels(cmXMLElement&);
diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx
index 6e8091b..125d003 100644
--- a/Source/CTest/cmCTestMemCheckHandler.cxx
+++ b/Source/CTest/cmCTestMemCheckHandler.cxx
@@ -300,7 +300,7 @@ void cmCTestMemCheckHandler::PopulateCustomVectors(cmMakefile* mf)
this->CustomTestsIgnore);
}
-int cmCTestMemCheckHandler::GetDefectCount()
+int cmCTestMemCheckHandler::GetDefectCount() const
{
return this->DefectCount;
}
diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h
index 7ab00db..b200c43 100644
--- a/Source/CTest/cmCTestMemCheckHandler.h
+++ b/Source/CTest/cmCTestMemCheckHandler.h
@@ -29,7 +29,7 @@ public:
void Initialize() override;
- int GetDefectCount();
+ int GetDefectCount() const;
protected:
int PreProcessHandler() override;
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index 9793c5b..852f9d9 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -621,7 +621,7 @@ void cmCTestMultiProcessHandler::StartNextTests()
void cmCTestMultiProcessHandler::OnTestLoadRetryCB(uv_timer_t* timer)
{
- auto self = static_cast<cmCTestMultiProcessHandler*>(timer->data);
+ auto* self = static_cast<cmCTestMultiProcessHandler*>(timer->data);
self->StartNextTests();
}
@@ -631,7 +631,7 @@ void cmCTestMultiProcessHandler::FinishTestProcess(
this->Completed++;
int test = runner->GetIndex();
- auto properties = runner->GetTestProperties();
+ auto* properties = runner->GetTestProperties();
bool testResult = runner->EndTest(this->Completed, this->Total, started);
if (runner->TimedOutForStopTime()) {
@@ -920,7 +920,7 @@ void cmCTestMultiProcessHandler::MarkFinished()
static Json::Value DumpToJsonArray(const std::set<std::string>& values)
{
Json::Value jsonArray = Json::arrayValue;
- for (auto& it : values) {
+ for (const auto& it : values) {
jsonArray.append(it);
}
return jsonArray;
@@ -929,7 +929,7 @@ static Json::Value DumpToJsonArray(const std::set<std::string>& values)
static Json::Value DumpToJsonArray(const std::vector<std::string>& values)
{
Json::Value jsonArray = Json::arrayValue;
- for (auto& it : values) {
+ for (const auto& it : values) {
jsonArray.append(it);
}
return jsonArray;
@@ -939,7 +939,7 @@ static Json::Value DumpRegExToJsonArray(
const std::vector<std::pair<cmsys::RegularExpression, std::string>>& values)
{
Json::Value jsonArray = Json::arrayValue;
- for (auto& it : values) {
+ for (const auto& it : values) {
jsonArray.append(it.second);
}
return jsonArray;
@@ -949,7 +949,7 @@ static Json::Value DumpMeasurementToJsonArray(
const std::map<std::string, std::string>& values)
{
Json::Value jsonArray = Json::arrayValue;
- for (auto& it : values) {
+ for (const auto& it : values) {
Json::Value measurement = Json::objectValue;
measurement["measurement"] = it.first;
measurement["value"] = it.second;
diff --git a/Source/CTest/cmCTestResourceGroupsLexerHelper.cxx b/Source/CTest/cmCTestResourceGroupsLexerHelper.cxx
index 072af42..4c26b3f 100644
--- a/Source/CTest/cmCTestResourceGroupsLexerHelper.cxx
+++ b/Source/CTest/cmCTestResourceGroupsLexerHelper.cxx
@@ -17,7 +17,7 @@ bool cmCTestResourceGroupsLexerHelper::ParseString(const std::string& value)
yyscan_t lexer;
cmCTestResourceGroups_yylex_init_extra(this, &lexer);
- auto state = cmCTestResourceGroups_yy_scan_string(value.c_str(), lexer);
+ auto* state = cmCTestResourceGroups_yy_scan_string(value.c_str(), lexer);
int retval = cmCTestResourceGroups_yylex(lexer);
cmCTestResourceGroups_yy_delete_buffer(state, lexer);
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index a8c9df6..1cb5d00 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -1675,7 +1675,7 @@ std::string cmCTestTestHandler::FindExecutable(
// if everything else failed, check the users path, but only if a full path
// wasn't specified
if (fullPath.empty() && filepath.empty()) {
- std::string const path = cmSystemTools::FindProgram(filename.c_str());
+ std::string path = cmSystemTools::FindProgram(filename.c_str());
if (!path.empty()) {
resultingConfig.clear();
return path;
diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx
index c7cbd34..16bca01 100644
--- a/Source/CTest/cmProcess.cxx
+++ b/Source/CTest/cmProcess.cxx
@@ -152,7 +152,7 @@ bool cmProcess::StartProcess(uv_loop_t& loop, std::vector<size_t>* affinity)
void cmProcess::StartTimer()
{
- auto properties = this->Runner->GetTestProperties();
+ auto* properties = this->Runner->GetTestProperties();
auto msec =
std::chrono::duration_cast<std::chrono::milliseconds>(this->Timeout);
@@ -209,7 +209,7 @@ bool cmProcess::Buffer::GetLast(std::string& line)
void cmProcess::OnReadCB(uv_stream_t* stream, ssize_t nread,
const uv_buf_t* buf)
{
- auto self = static_cast<cmProcess*>(stream->data);
+ auto* self = static_cast<cmProcess*>(stream->data);
self->OnRead(nread, buf);
}
@@ -256,7 +256,7 @@ void cmProcess::OnRead(ssize_t nread, const uv_buf_t* buf)
void cmProcess::OnAllocateCB(uv_handle_t* handle, size_t suggested_size,
uv_buf_t* buf)
{
- auto self = static_cast<cmProcess*>(handle->data);
+ auto* self = static_cast<cmProcess*>(handle->data);
self->OnAllocate(suggested_size, buf);
}
@@ -272,7 +272,7 @@ void cmProcess::OnAllocate(size_t /*suggested_size*/, uv_buf_t* buf)
void cmProcess::OnTimeoutCB(uv_timer_t* timer)
{
- auto self = static_cast<cmProcess*>(timer->data);
+ auto* self = static_cast<cmProcess*>(timer->data);
self->OnTimeout();
}
@@ -298,7 +298,7 @@ void cmProcess::OnTimeout()
void cmProcess::OnExitCB(uv_process_t* process, int64_t exit_status,
int term_signal)
{
- auto self = static_cast<cmProcess*>(process->data);
+ auto* self = static_cast<cmProcess*>(process->data);
self->OnExit(exit_status, term_signal);
}
@@ -358,7 +358,7 @@ void cmProcess::ResetStartTime()
this->StartTime = std::chrono::steady_clock::now();
}
-cmProcess::Exception cmProcess::GetExitException()
+cmProcess::Exception cmProcess::GetExitException() const
{
auto exception = Exception::None;
#if defined(_WIN32) && !defined(__CYGWIN__)
@@ -430,7 +430,7 @@ cmProcess::Exception cmProcess::GetExitException()
return exception;
}
-std::string cmProcess::GetExitExceptionString()
+std::string cmProcess::GetExitExceptionString() const
{
std::string exception_str;
#if defined(_WIN32)
diff --git a/Source/CTest/cmProcess.h b/Source/CTest/cmProcess.h
index 9eec952..a44aeb0 100644
--- a/Source/CTest/cmProcess.h
+++ b/Source/CTest/cmProcess.h
@@ -67,8 +67,8 @@ public:
Other
};
- Exception GetExitException();
- std::string GetExitExceptionString();
+ Exception GetExitException() const;
+ std::string GetExitExceptionString() const;
std::unique_ptr<cmCTestRunTest> GetRunner()
{
diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx
index 6fc556c..069c02e 100644
--- a/Source/CursesDialog/cmCursesMainForm.cxx
+++ b/Source/CursesDialog/cmCursesMainForm.cxx
@@ -405,7 +405,7 @@ void cmCursesMainForm::UpdateStatusBar(cm::optional<std::string> message)
// Get the help string of the current entry
// and add it to the help string
- auto cmakeState = this->CMakeInstance->GetState();
+ auto* cmakeState = this->CMakeInstance->GetState();
cmProp existingValue = cmakeState->GetCacheEntryValue(labelValue);
if (existingValue) {
cmProp help =
@@ -1000,7 +1000,7 @@ void cmCursesMainForm::DisplayOutputs(std::string const& newOutput)
getmaxyx(stdscr, yi, xi);
if (CurrentForm != this->LogForm.get()) {
- auto newLogForm = new cmCursesLongMessageForm(
+ auto* newLogForm = new cmCursesLongMessageForm(
this->Outputs, this->LastProgress.c_str(),
cmCursesLongMessageForm::ScrollBehavior::ScrollDown);
CurrentForm = newLogForm;
diff --git a/Source/cmAuxSourceDirectoryCommand.cxx b/Source/cmAuxSourceDirectoryCommand.cxx
index 15edcc5..35f4c88 100644
--- a/Source/cmAuxSourceDirectoryCommand.cxx
+++ b/Source/cmAuxSourceDirectoryCommand.cxx
@@ -51,7 +51,7 @@ bool cmAuxSourceDirectoryCommand(std::vector<std::string> const& args,
if (dotpos != std::string::npos) {
auto ext = cm::string_view(file).substr(dotpos + 1);
// Process only source files
- auto cm = mf.GetCMakeInstance();
+ auto* cm = mf.GetCMakeInstance();
if (dotpos > 0 && cm->IsACLikeSourceExtension(ext)) {
std::string fullname = cmStrCat(templateDirectory, '/', file);
// add the file as a class file so
diff --git a/Source/cmBase32.cxx b/Source/cmBase32.cxx
index 80ada47..a9c15c2 100644
--- a/Source/cmBase32.cxx
+++ b/Source/cmBase32.cxx
@@ -36,8 +36,6 @@ void Base32Encode5(const unsigned char src[5], char dst[8])
cmBase32Encoder::cmBase32Encoder() = default;
-cmBase32Encoder::~cmBase32Encoder() = default;
-
std::string cmBase32Encoder::encodeString(const unsigned char* input,
size_t len, bool padding)
{
diff --git a/Source/cmBase32.h b/Source/cmBase32.h
index 726f45d..d70a062 100644
--- a/Source/cmBase32.h
+++ b/Source/cmBase32.h
@@ -17,9 +17,8 @@ class cmBase32Encoder
public:
static const char paddingChar = '=';
-public:
cmBase32Encoder();
- ~cmBase32Encoder();
+ ~cmBase32Encoder() = default;
// Encodes the given input byte sequence into a string
// @arg input Input data pointer
diff --git a/Source/cmCMakePathCommand.cxx b/Source/cmCMakePathCommand.cxx
index 5662a2f..e14dce0 100644
--- a/Source/cmCMakePathCommand.cxx
+++ b/Source/cmCMakePathCommand.cxx
@@ -149,7 +149,7 @@ public:
bool getInputPath(const std::string& arg, cmExecutionStatus& status,
std::string& path)
{
- auto def = status.GetMakefile().GetDefinition(arg);
+ const auto* def = status.GetMakefile().GetDefinition(arg);
if (def == nullptr) {
status.SetError("undefined variable for input path.");
return false;
diff --git a/Source/cmCMakePresetsFile.cxx b/Source/cmCMakePresetsFile.cxx
index cf5db6e..8762158 100644
--- a/Source/cmCMakePresetsFile.cxx
+++ b/Source/cmCMakePresetsFile.cxx
@@ -2,8 +2,10 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCMakePresetsFile.h"
+#include <algorithm>
#include <cstdlib>
#include <functional>
+#include <iterator>
#include <utility>
#include <cmext/string_view>
@@ -461,22 +463,16 @@ constexpr const char* ValidPrefixes[] = {
bool PrefixesValidMacroNamespace(const std::string& str)
{
- for (auto const& prefix : ValidPrefixes) {
- if (cmHasPrefix(prefix, str)) {
- return true;
- }
- }
- return false;
+ return std::any_of(
+ std::begin(ValidPrefixes), std::end(ValidPrefixes),
+ [&str](const char* prefix) -> bool { return cmHasPrefix(prefix, str); });
}
bool IsValidMacroNamespace(const std::string& str)
{
- for (auto const& prefix : ValidPrefixes) {
- if (str == prefix) {
- return true;
- }
- }
- return false;
+ return std::any_of(
+ std::begin(ValidPrefixes), std::end(ValidPrefixes),
+ [&str](const char* prefix) -> bool { return str == prefix; });
}
enum class ExpandMacroResult
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index 9e3582c..0295b33 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -221,8 +221,8 @@ void CCONV cmAddUtilityCommand(void* arg, const char* utilityName,
// Pass the call to the makefile instance.
std::vector<std::string> no_byproducts;
- mf->AddUtilityCommand(utilityName, (all ? false : true), nullptr,
- no_byproducts, depends2, commandLines);
+ mf->AddUtilityCommand(utilityName, !all, nullptr, no_byproducts, depends2,
+ commandLines);
}
void CCONV cmAddCustomCommand(void* arg, const char* source,
@@ -567,7 +567,7 @@ void* CCONV cmAddSource(void* arg, void* arg2)
sf->SourceExtension = osf->SourceExtension;
// Store the proxy in the map so it can be re-used and deleted later.
- auto value = sf.get();
+ auto* value = sf.get();
cmCPluginAPISourceFiles[rsf] = std::move(sf);
return value;
}
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index 8d1a5fd..1a950df 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -183,7 +183,7 @@ bool cmCacheManager::ReadPropertyEntry(const std::string& entryKey,
if (entryKey.size() > plen && *(end - plen) == '-' &&
strcmp(end - plen + 1, p) == 0) {
std::string key = entryKey.substr(0, entryKey.size() - plen);
- if (auto entry = this->GetCacheEntry(key)) {
+ if (auto* entry = this->GetCacheEntry(key)) {
// Store this property on its entry.
entry->SetProperty(p, e.Value.c_str());
} else {
@@ -498,7 +498,7 @@ const cmCacheManager::CacheEntry* cmCacheManager::GetCacheEntry(
cmProp cmCacheManager::GetInitializedCacheValue(const std::string& key) const
{
- if (auto entry = this->GetCacheEntry(key)) {
+ if (const auto* entry = this->GetCacheEntry(key)) {
if (entry->Initialized) {
return &entry->GetValue();
}
diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h
index 9aebffc..7a9a7dc 100644
--- a/Source/cmCacheManager.h
+++ b/Source/cmCacheManager.h
@@ -74,7 +74,7 @@ public:
cmProp GetCacheEntryValue(const std::string& key) const
{
- if (auto entry = this->GetCacheEntry(key)) {
+ if (const auto* entry = this->GetCacheEntry(key)) {
return &entry->GetValue();
}
return nullptr;
@@ -82,14 +82,14 @@ public:
void SetCacheEntryValue(std::string const& key, std::string const& value)
{
- if (auto entry = this->GetCacheEntry(key)) {
+ if (auto* entry = this->GetCacheEntry(key)) {
entry->SetValue(value.c_str());
}
}
cmStateEnums::CacheEntryType GetCacheEntryType(std::string const& key) const
{
- if (auto entry = this->GetCacheEntry(key)) {
+ if (const auto* entry = this->GetCacheEntry(key)) {
return entry->GetType();
}
return cmStateEnums::UNINITIALIZED;
@@ -98,7 +98,7 @@ public:
std::vector<std::string> GetCacheEntryPropertyList(
std::string const& key) const
{
- if (auto entry = this->GetCacheEntry(key)) {
+ if (const auto* entry = this->GetCacheEntry(key)) {
return entry->GetPropertyList();
}
return {};
@@ -107,7 +107,7 @@ public:
cmProp GetCacheEntryProperty(std::string const& key,
std::string const& propName) const
{
- if (auto entry = this->GetCacheEntry(key)) {
+ if (const auto* entry = this->GetCacheEntry(key)) {
return entry->GetProperty(propName);
}
return nullptr;
@@ -116,7 +116,7 @@ public:
bool GetCacheEntryPropertyAsBool(std::string const& key,
std::string const& propName) const
{
- if (auto entry = this->GetCacheEntry(key)) {
+ if (const auto* entry = this->GetCacheEntry(key)) {
return entry->GetPropertyAsBool(propName);
}
return false;
@@ -126,7 +126,7 @@ public:
std::string const& propName,
std::string const& value)
{
- if (auto entry = this->GetCacheEntry(key)) {
+ if (auto* entry = this->GetCacheEntry(key)) {
entry->SetProperty(propName, value.c_str());
}
}
@@ -134,7 +134,7 @@ public:
void SetCacheEntryBoolProperty(std::string const& key,
std::string const& propName, bool value)
{
- if (auto entry = this->GetCacheEntry(key)) {
+ if (auto* entry = this->GetCacheEntry(key)) {
entry->SetProperty(propName, value);
}
}
@@ -142,7 +142,7 @@ public:
void RemoveCacheEntryProperty(std::string const& key,
std::string const& propName)
{
- if (auto entry = this->GetCacheEntry(key)) {
+ if (auto* entry = this->GetCacheEntry(key)) {
entry->SetProperty(propName, nullptr);
}
}
@@ -152,7 +152,7 @@ public:
std::string const& value,
bool asString = false)
{
- if (auto entry = this->GetCacheEntry(key)) {
+ if (auto* entry = this->GetCacheEntry(key)) {
entry->AppendProperty(propName, value, asString);
}
}
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index 6d5e064..deddba8 100644
--- a/Source/cmCommandArgumentParserHelper.cxx
+++ b/Source/cmCommandArgumentParserHelper.cxx
@@ -228,7 +228,7 @@ int cmCommandArgumentParserHelper::ParseString(std::string const& str,
yyscan_t yyscanner;
cmCommandArgument_yylex_init(&yyscanner);
- auto scanBuf = cmCommandArgument_yy_scan_string(str.c_str(), yyscanner);
+ auto* scanBuf = cmCommandArgument_yy_scan_string(str.c_str(), yyscanner);
cmCommandArgument_yyset_extra(this, yyscanner);
cmCommandArgument_SetupEscapes(yyscanner, this->NoEscapeMode);
int res = cmCommandArgument_yyparse(yyscanner);
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 6e1fac0..f32f9e9 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -951,6 +951,9 @@ void cmComputeLinkInformation::AddLinkExtension(std::string const& e,
}
}
+// XXX(clang-tidy): This method's const-ness is platform dependent, so we
+// cannot make it `const` as `clang-tidy` wants us to.
+// NOLINTNEXTLINE(readability-make-member-function-const)
std::string cmComputeLinkInformation::CreateExtensionRegex(
std::vector<std::string> const& exts, LinkType type)
{
diff --git a/Source/cmConsoleBuf.cxx b/Source/cmConsoleBuf.cxx
index 70be481..8ce9ebc 100644
--- a/Source/cmConsoleBuf.cxx
+++ b/Source/cmConsoleBuf.cxx
@@ -12,8 +12,6 @@ cmConsoleBuf::cmConsoleBuf()
cmConsoleBuf::cmConsoleBuf() = default;
#endif
-cmConsoleBuf::~cmConsoleBuf() = default;
-
void cmConsoleBuf::SetUTF8Pipes()
{
#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP)
diff --git a/Source/cmConsoleBuf.h b/Source/cmConsoleBuf.h
index 3564598..0a6d3b5 100644
--- a/Source/cmConsoleBuf.h
+++ b/Source/cmConsoleBuf.h
@@ -16,7 +16,7 @@ class cmConsoleBuf
#endif
public:
cmConsoleBuf();
- ~cmConsoleBuf();
+ ~cmConsoleBuf() = default;
cmConsoleBuf(cmConsoleBuf const&) = delete;
cmConsoleBuf& operator=(cmConsoleBuf const&) = delete;
void SetUTF8Pipes();
diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx
index d092f4f..566c3bf 100644
--- a/Source/cmDepends.cxx
+++ b/Source/cmDepends.cxx
@@ -77,7 +77,7 @@ bool cmDepends::Check(const std::string& makeFile,
return okay;
}
-void cmDepends::Clear(const std::string& file)
+void cmDepends::Clear(const std::string& file) const
{
// Print verbose output.
if (this->Verbose) {
diff --git a/Source/cmDepends.h b/Source/cmDepends.h
index 0240da9..76af4db 100644
--- a/Source/cmDepends.h
+++ b/Source/cmDepends.h
@@ -25,7 +25,6 @@ class cmDepends
public:
using DependencyMap = std::map<std::string, std::vector<std::string>>;
-public:
/** Instances need to know the build directory name and the relative
path from the build directory to the target file. */
cmDepends(cmLocalUnixMakefileGenerator3* lg = nullptr,
@@ -70,7 +69,7 @@ public:
DependencyMap& validDeps);
/** Clear dependencies for the target file so they will be regenerated. */
- void Clear(const std::string& file);
+ void Clear(const std::string& file) const;
/** Set the file comparison object */
void SetFileTimeCache(cmFileTimeCache* fc) { this->FileTimeCache = fc; }
diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx
index fc1bbdd..0c5d310 100644
--- a/Source/cmDependsJavaParserHelper.cxx
+++ b/Source/cmDependsJavaParserHelper.cxx
@@ -103,7 +103,7 @@ void cmDependsJavaParserHelper::SafePrintMissing(const char* str, int line,
std::cout << "- " << strlen(str) << std::endl;
}
}
-void cmDependsJavaParserHelper::Print(const char* place, const char* str)
+void cmDependsJavaParserHelper::Print(const char* place, const char* str) const
{
if (this->Verbose) {
std::cout << "[" << place << "=" << str << "]" << std::endl;
diff --git a/Source/cmDependsJavaParserHelper.h b/Source/cmDependsJavaParserHelper.h
index 869b7d4..4057bb7 100644
--- a/Source/cmDependsJavaParserHelper.h
+++ b/Source/cmDependsJavaParserHelper.h
@@ -85,7 +85,7 @@ private:
void PrintClasses();
- void Print(const char* place, const char* str);
+ void Print(const char* place, const char* str) const;
void CombineUnions(char** out, const char* in1, char** in2, const char* sep);
void SafePrintMissing(const char* str, int line, int cnt);
diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx
index 5a85b7d..ffcc415 100644
--- a/Source/cmExecuteProcessCommand.cxx
+++ b/Source/cmExecuteProcessCommand.cxx
@@ -231,7 +231,7 @@ bool cmExecuteProcessCommand(std::vector<std::string> const& args,
}
if (echo_stdout || echo_stderr) {
std::string command;
- for (auto& cmd : arguments.Commands) {
+ for (const auto& cmd : arguments.Commands) {
command += "'";
command += cmJoin(cmd, "' '");
command += "'";
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 113751a..7015a01 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -1214,7 +1214,7 @@ bool cmExportFileGenerator::PopulateExportProperties(
cmGeneratorTarget* gte, ImportPropertyMap& properties,
std::string& errorMessage)
{
- auto& targetProperties = gte->Target->GetProperties();
+ const auto& targetProperties = gte->Target->GetProperties();
if (cmProp exportProperties =
targetProperties.GetPropertyValue("EXPORT_PROPERTIES")) {
for (auto& prop : cmExpandedList(*exportProperties)) {
diff --git a/Source/cmExprParserHelper.h b/Source/cmExprParserHelper.h
index 54dd6a4..919e492 100644
--- a/Source/cmExprParserHelper.h
+++ b/Source/cmExprParserHelper.h
@@ -27,7 +27,7 @@ public:
void SetResult(KWIML_INT_int64_t value);
- KWIML_INT_int64_t GetResult() { return this->Result; }
+ KWIML_INT_int64_t GetResult() const { return this->Result; }
const char* GetError() { return this->ErrorString.c_str(); }
diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx
index 800db8a..f217201 100644
--- a/Source/cmExtraCodeBlocksGenerator.cxx
+++ b/Source/cmExtraCodeBlocksGenerator.cxx
@@ -341,7 +341,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
all_files_map_t allFiles;
std::vector<std::string> cFiles;
- auto cm = this->GlobalGenerator->GetCMakeInstance();
+ auto* cm = this->GlobalGenerator->GetCMakeInstance();
for (cmLocalGenerator* lg : lgs) {
cmMakefile* makefile = lg->GetMakefile();
diff --git a/Source/cmExtraCodeLiteGenerator.h b/Source/cmExtraCodeLiteGenerator.h
index 2478585..2bb1c04 100644
--- a/Source/cmExtraCodeLiteGenerator.h
+++ b/Source/cmExtraCodeLiteGenerator.h
@@ -24,7 +24,6 @@ protected:
std::string WorkspacePath;
unsigned int CpuCount = 2;
-protected:
std::string GetCodeLiteCompilerName(const cmMakefile* mf) const;
std::string GetConfigurationName(const cmMakefile* mf) const;
std::string GetBuildCommand(const cmMakefile* mf,
diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx
index 7fcc3dc..9061109 100644
--- a/Source/cmFileAPICodemodel.cxx
+++ b/Source/cmFileAPICodemodel.cxx
@@ -1324,7 +1324,7 @@ Json::Value Target::DumpInstallDestinations()
{
Json::Value destinations = Json::arrayValue;
auto installGens = this->GT->Target->GetInstallGenerators();
- for (auto itGen : installGens) {
+ for (auto* itGen : installGens) {
destinations.append(this->DumpInstallDestination(itGen));
}
return destinations;
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 9815d9d..576f015 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -334,7 +334,7 @@ bool HandleStringsCommand(std::vector<std::string> const& args,
arg_limit_count,
arg_length_minimum,
arg_length_maximum,
- arg__maximum,
+ arg_maximum,
arg_regex,
arg_encoding
};
@@ -558,8 +558,7 @@ bool HandleStringsCommand(std::vector<std::string> const& args,
// back subsequent characters
if ((current_str.length() != num_utf8_bytes)) {
for (unsigned int j = 0; j < current_str.size() - 1; j++) {
- c = current_str[current_str.size() - 1 - j];
- fin.putback(static_cast<char>(c));
+ fin.putback(current_str[current_str.size() - 1 - j]);
}
current_str.clear();
}
diff --git a/Source/cmFileLock.cxx b/Source/cmFileLock.cxx
index 6010233..5d197d2 100644
--- a/Source/cmFileLock.cxx
+++ b/Source/cmFileLock.cxx
@@ -80,7 +80,9 @@ bool cmFileLock::IsLocked(const std::string& filename) const
}
#if defined(_WIN32)
+// NOLINTNEXTLINE(bugprone-suspicious-include)
# include "cmFileLockWin32.cxx"
#else
+// NOLINTNEXTLINE(bugprone-suspicious-include)
# include "cmFileLockUnix.cxx"
#endif
diff --git a/Source/cmFileLock.h b/Source/cmFileLock.h
index 2b125af..94baea1 100644
--- a/Source/cmFileLock.h
+++ b/Source/cmFileLock.h
@@ -57,7 +57,7 @@ private:
BOOL LockFile(DWORD flags);
#else
int File = -1;
- int LockFile(int cmd, int type);
+ int LockFile(int cmd, int type) const;
#endif
std::string Filename;
diff --git a/Source/cmFileLockPool.cxx b/Source/cmFileLockPool.cxx
index e1f6e94..99f6885 100644
--- a/Source/cmFileLockPool.cxx
+++ b/Source/cmFileLockPool.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmFileLockPool.h"
+#include <algorithm>
#include <cassert>
#include <utility>
@@ -145,10 +146,8 @@ cmFileLockResult cmFileLockPool::ScopePool::Release(
bool cmFileLockPool::ScopePool::IsAlreadyLocked(
const std::string& filename) const
{
- for (auto const& lock : this->Locks) {
- if (lock.IsLocked(filename)) {
- return true;
- }
- }
- return false;
+ return std::any_of(this->Locks.begin(), this->Locks.end(),
+ [&filename](cmFileLock const& lock) -> bool {
+ return lock.IsLocked(filename);
+ });
}
diff --git a/Source/cmFileLockUnix.cxx b/Source/cmFileLockUnix.cxx
index 1456ea8..613c6ee 100644
--- a/Source/cmFileLockUnix.cxx
+++ b/Source/cmFileLockUnix.cxx
@@ -64,7 +64,7 @@ cmFileLockResult cmFileLock::LockWithTimeout(unsigned long seconds)
}
}
-int cmFileLock::LockFile(int cmd, int type)
+int cmFileLock::LockFile(int cmd, int type) const
{
struct ::flock lock;
lock.l_start = 0;
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 3b7cf4c..3719fe1 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -1145,34 +1145,27 @@ bool cmFindPackageCommand::FindConfig()
bool cmFindPackageCommand::FindPrefixedConfig()
{
std::vector<std::string> const& prefixes = this->SearchPaths;
- for (std::string const& p : prefixes) {
- if (this->SearchPrefix(p)) {
- return true;
- }
- }
- return false;
+ return std::any_of(
+ prefixes.begin(), prefixes.end(),
+ [this](std::string const& p) -> bool { return this->SearchPrefix(p); });
}
bool cmFindPackageCommand::FindFrameworkConfig()
{
std::vector<std::string> const& prefixes = this->SearchPaths;
- for (std::string const& p : prefixes) {
- if (this->SearchFrameworkPrefix(p)) {
- return true;
- }
- }
- return false;
+ return std::any_of(prefixes.begin(), prefixes.end(),
+ [this](std::string const& p) -> bool {
+ return this->SearchFrameworkPrefix(p);
+ });
}
bool cmFindPackageCommand::FindAppBundleConfig()
{
std::vector<std::string> const& prefixes = this->SearchPaths;
- for (std::string const& p : prefixes) {
- if (this->SearchAppBundlePrefix(p)) {
- return true;
- }
- }
- return false;
+ return std::any_of(prefixes.begin(), prefixes.end(),
+ [this](std::string const& p) -> bool {
+ return this->SearchAppBundlePrefix(p);
+ });
}
bool cmFindPackageCommand::ReadListFile(const std::string& f,
diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx
index bece33b..3fb0826 100644
--- a/Source/cmFindPathCommand.cxx
+++ b/Source/cmFindPathCommand.cxx
@@ -80,8 +80,8 @@ std::string cmFindPathCommand::FindHeader()
return header;
}
-std::string cmFindPathCommand::FindHeaderInFramework(std::string const& file,
- std::string const& dir)
+std::string cmFindPathCommand::FindHeaderInFramework(
+ std::string const& file, std::string const& dir) const
{
std::string fileName = file;
std::string frameWorkName;
diff --git a/Source/cmFindPathCommand.h b/Source/cmFindPathCommand.h
index b9fe673..6101ea1 100644
--- a/Source/cmFindPathCommand.h
+++ b/Source/cmFindPathCommand.h
@@ -29,7 +29,7 @@ public:
private:
std::string FindHeaderInFramework(std::string const& file,
- std::string const& dir);
+ std::string const& dir) const;
std::string FindHeader();
std::string FindNormalHeader(cmFindBaseDebugState& debug);
std::string FindFrameworkHeader(cmFindBaseDebugState& debug);
diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx
index 5bb4234..c22462e 100644
--- a/Source/cmFindProgramCommand.cxx
+++ b/Source/cmFindProgramCommand.cxx
@@ -2,6 +2,9 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmFindProgramCommand.h"
+#include <algorithm>
+#include <string>
+
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmPolicies.h"
@@ -60,44 +63,42 @@ struct cmFindProgramHelper
}
bool CheckCompoundNames()
{
- for (std::string const& n : this->Names) {
- // Only perform search relative to current directory if the file name
- // contains a directory separator.
- if (n.find('/') != std::string::npos) {
- if (this->CheckDirectoryForName("", n)) {
- return true;
- }
- }
- }
- return false;
+ return std::any_of(this->Names.begin(), this->Names.end(),
+ [this](std::string const& n) -> bool {
+ // Only perform search relative to current directory
+ // if the file name contains a directory separator.
+ return n.find('/') != std::string::npos &&
+ this->CheckDirectoryForName("", n);
+ });
}
bool CheckDirectory(std::string const& path)
{
- for (std::string const& n : this->Names) {
- if (this->CheckDirectoryForName(path, n)) {
- return true;
- }
- }
- return false;
+ return std::any_of(this->Names.begin(), this->Names.end(),
+ [this, &path](std::string const& n) -> bool {
+ // Only perform search relative to current directory
+ // if the file name contains a directory separator.
+ return this->CheckDirectoryForName(path, n);
+ });
}
bool CheckDirectoryForName(std::string const& path, std::string const& name)
{
- for (std::string const& ext : this->Extensions) {
- if (!ext.empty() && cmHasSuffix(name, ext)) {
- continue;
- }
- this->TestNameExt = cmStrCat(name, ext);
- this->TestPath =
- cmSystemTools::CollapseFullPath(this->TestNameExt, path);
- bool exists = this->FileIsExecutable(this->TestPath);
- exists ? this->DebugSearches.FoundAt(this->TestPath)
- : this->DebugSearches.FailedAt(this->TestPath);
- if (exists) {
- this->BestPath = this->TestPath;
- return true;
- }
- }
- return false;
+ return std::any_of(this->Extensions.begin(), this->Extensions.end(),
+ [this, &path, &name](std::string const& ext) -> bool {
+ if (!ext.empty() && cmHasSuffix(name, ext)) {
+ return false;
+ }
+ this->TestNameExt = cmStrCat(name, ext);
+ this->TestPath = cmSystemTools::CollapseFullPath(
+ this->TestNameExt, path);
+ bool exists = this->FileIsExecutable(this->TestPath);
+ exists ? this->DebugSearches.FoundAt(this->TestPath)
+ : this->DebugSearches.FailedAt(this->TestPath);
+ if (exists) {
+ this->BestPath = this->TestPath;
+ return true;
+ }
+ return false;
+ });
}
bool FileIsExecutable(std::string const& file) const
{
diff --git a/Source/cmFunctionBlocker.h b/Source/cmFunctionBlocker.h
index b4b493b..38abeba 100644
--- a/Source/cmFunctionBlocker.h
+++ b/Source/cmFunctionBlocker.h
@@ -44,7 +44,6 @@ private:
virtual bool Replay(std::vector<cmListFileFunction> functions,
cmExecutionStatus& status) = 0;
-private:
cmListFileContext StartingContext;
std::vector<cmListFileFunction> Functions;
unsigned int ScopeDepth = 1;
diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h
index 53225cd..93b44db 100644
--- a/Source/cmGeneratorExpressionDAGChecker.h
+++ b/Source/cmGeneratorExpressionDAGChecker.h
@@ -89,7 +89,6 @@ private:
Result CheckGraph() const;
void Initialize();
-private:
const cmGeneratorExpressionDAGChecker* const Parent;
cmGeneratorTarget const* Target;
const std::string Property;
diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h
index 5ad5e23..9a870ac 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.h
+++ b/Source/cmGeneratorExpressionEvaluationFile.h
@@ -52,7 +52,6 @@ private:
std::string FixRelativePath(std::string const& filePath, PathRole role,
cmLocalGenerator* lg);
-private:
const std::string Input;
const std::string Target;
const std::unique_ptr<cmCompiledGeneratorExpression> OutputFileExpr;
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index 4129a0c..fec309c 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -31,7 +31,7 @@ std::string GeneratorExpressionContent::ProcessArbitraryContent(
const auto pend = this->ParamChildren.end();
for (; pit != pend; ++pit) {
- for (auto& pExprEval : *pit) {
+ for (const auto& pExprEval : *pit) {
if (node->RequiresLiteralInput()) {
if (pExprEval->GetType() != cmGeneratorExpressionEvaluator::Text) {
reportError(context, this->GetOriginalExpression(),
@@ -63,7 +63,7 @@ std::string GeneratorExpressionContent::Evaluate(
{
std::string identifier;
{
- for (auto& pExprEval : this->IdentifierChildren) {
+ for (const auto& pExprEval : this->IdentifierChildren) {
identifier += pExprEval->Evaluate(context, dagChecker);
if (context->HadError) {
return std::string();
@@ -124,7 +124,7 @@ std::string GeneratorExpressionContent::EvaluateParameters(
return std::string();
}
std::string parameter;
- for (auto& pExprEval : *pit) {
+ for (const auto& pExprEval : *pit) {
parameter += pExprEval->Evaluate(context, dagChecker);
if (context->HadError) {
return std::string();
diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h
index af2afd6..8f47c0b 100644
--- a/Source/cmGeneratorExpressionEvaluator.h
+++ b/Source/cmGeneratorExpressionEvaluator.h
@@ -108,7 +108,6 @@ private:
std::vector<cmGeneratorExpressionEvaluatorVector>::const_iterator pit)
const;
-private:
cmGeneratorExpressionEvaluatorVector IdentifierChildren;
std::vector<cmGeneratorExpressionEvaluatorVector> ParamChildren;
const char* StartContent;
diff --git a/Source/cmGeneratorExpressionParser.h b/Source/cmGeneratorExpressionParser.h
index d49bf3e..efaef3e 100644
--- a/Source/cmGeneratorExpressionParser.h
+++ b/Source/cmGeneratorExpressionParser.h
@@ -24,7 +24,6 @@ private:
void ParseContent(cmGeneratorExpressionEvaluatorVector&);
void ParseGeneratorExpression(cmGeneratorExpressionEvaluatorVector&);
-private:
std::vector<cmGeneratorExpressionToken>::const_iterator it;
const std::vector<cmGeneratorExpressionToken> Tokens;
unsigned int NestingLevel;
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index a96103a..aaefe9c 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -4051,7 +4051,7 @@ std::string cmGeneratorTarget::GetPchFileObject(const std::string& config,
}
std::string& filename = inserted.first->second;
- auto pchSf = this->Makefile->GetOrCreateSource(
+ auto* pchSf = this->Makefile->GetOrCreateSource(
pchSource, false, cmSourceFileLocationKind::Known);
filename = cmStrCat(this->ObjectDirectory, this->GetObjectName(pchSf));
@@ -7359,7 +7359,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
std::string name = this->CheckCMP0004(lib);
if (this->GetPolicyStatusCMP0108() == cmPolicies::NEW) {
// resolve alias name
- auto target = this->Makefile->FindTargetToUse(name);
+ auto* target = this->Makefile->FindTargetToUse(name);
if (target) {
name = target->GetName();
}
diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx
index a7658f2..ed5bff5 100644
--- a/Source/cmGhsMultiTargetGenerator.cxx
+++ b/Source/cmGhsMultiTargetGenerator.cxx
@@ -356,7 +356,7 @@ void cmGhsMultiTargetGenerator::WriteBuildEventsHelper(
} else {
fout << fname << "\n :outputName=\"" << fname << ".rule\"\n";
}
- for (auto& byp : ccg.GetByproducts()) {
+ for (const auto& byp : ccg.GetByproducts()) {
fout << " :extraOutputFile=\"" << byp << "\"\n";
}
}
@@ -528,7 +528,7 @@ void cmGhsMultiTargetGenerator::WriteSources(std::ostream& fout_proj)
}
}
- for (auto& n : groupNames) {
+ for (const auto& n : groupNames) {
groupFilesList[i] = n;
i += 1;
}
@@ -691,14 +691,14 @@ void cmGhsMultiTargetGenerator::WriteCustomCommandLine(
* the outputs is manually deleted.
*/
bool specifyExtra = true;
- for (auto& out : ccg.GetOutputs()) {
+ for (const auto& out : ccg.GetOutputs()) {
fout << fname << '\n';
fout << " :outputName=\"" << out << "\"\n";
if (specifyExtra) {
- for (auto& byp : ccg.GetByproducts()) {
+ for (const auto& byp : ccg.GetByproducts()) {
fout << " :extraOutputFile=\"" << byp << "\"\n";
}
- for (auto& dep : ccg.GetDepends()) {
+ for (const auto& dep : ccg.GetDepends()) {
fout << " :depends=\"" << dep << "\"\n";
}
specifyExtra = false;
@@ -726,12 +726,10 @@ bool cmGhsMultiTargetGenerator::DetermineIfIntegrityApp()
}
std::vector<cmSourceFile*> sources;
this->GeneratorTarget->GetSourceFiles(sources, this->ConfigName);
- for (const cmSourceFile* sf : sources) {
- if ("int" == sf->GetExtension()) {
- return true;
- }
- }
- return false;
+ return std::any_of(sources.begin(), sources.end(),
+ [](cmSourceFile const* sf) -> bool {
+ return "int" == sf->GetExtension();
+ });
}
bool cmGhsMultiTargetGenerator::ComputeCustomCommandOrder(
@@ -761,7 +759,7 @@ bool cmGhsMultiTargetGenerator::VisitCustomCommand(
if (perm.find(si) == perm.end()) {
/* set temporary mark; check if revisit*/
if (temp.insert(si).second) {
- for (auto& di : si->GetCustomCommand()->GetDepends()) {
+ for (const auto& di : si->GetCustomCommand()->GetDepends()) {
cmSourceFile const* sf =
this->GeneratorTarget->GetLocalGenerator()->GetSourceFileWithOutput(
di);
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 63aaf27..9230091 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1229,7 +1229,7 @@ void cmGlobalGenerator::Configure()
this->CMakeInstance->GetHomeOutputDirectory());
auto dirMfu = cm::make_unique<cmMakefile>(this, snapshot);
- auto dirMf = dirMfu.get();
+ auto* dirMf = dirMfu.get();
this->Makefiles.push_back(std::move(dirMfu));
dirMf->SetRecursionDepth(this->RecursionDepth);
this->IndexMakefile(dirMf);
@@ -1627,8 +1627,8 @@ void cmGlobalGenerator::ComputeTargetOrder(cmGeneratorTarget const* gt,
}
auto entry = insertion.first;
- auto& deps = this->GetTargetDirectDepends(gt);
- for (auto& d : deps) {
+ const auto& deps = this->GetTargetDirectDepends(gt);
+ for (const auto& d : deps) {
this->ComputeTargetOrder(d, index);
}
@@ -2928,7 +2928,7 @@ void cmGlobalGenerator::GetTargetSets(
cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators)
{
// loop over all local generators
- for (auto generator : generators) {
+ for (auto* generator : generators) {
// check to make sure generator is not excluded
if (this->IsExcluded(root, generator)) {
continue;
diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx
index 0ddfe77..172cf3f 100644
--- a/Source/cmGlobalGhsMultiGenerator.cxx
+++ b/Source/cmGlobalGhsMultiGenerator.cxx
@@ -704,7 +704,7 @@ bool cmGlobalGhsMultiGenerator::ComputeTargetBuildOrder(
std::set<cmGeneratorTarget const*> temp;
std::set<cmGeneratorTarget const*> perm;
- for (auto const ti : tgt) {
+ for (const auto* const ti : tgt) {
bool r = this->VisitTarget(temp, perm, build, ti);
if (r) {
return r;
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 4f17408..7eac169 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -2675,33 +2675,35 @@ bool cmGlobalNinjaMultiGenerator::OpenBuildFileStreams()
<< "# This file contains build statements common to all "
"configurations.\n\n";
- for (auto const& config : this->Makefiles[0]->GetGeneratorConfigs(
- cmMakefile::IncludeEmptyConfig)) {
- // Open impl file.
- if (!this->OpenFileStream(this->ImplFileStreams[config],
- GetNinjaImplFilename(config))) {
- return false;
- }
+ auto const& configs =
+ this->Makefiles[0]->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
+ return std::all_of(
+ configs.begin(), configs.end(), [this](std::string const& config) -> bool {
+ // Open impl file.
+ if (!this->OpenFileStream(this->ImplFileStreams[config],
+ GetNinjaImplFilename(config))) {
+ return false;
+ }
- // Write a comment about this file.
- *this->ImplFileStreams[config]
- << "# This file contains build statements specific to the \"" << config
- << "\"\n# configuration.\n\n";
+ // Write a comment about this file.
+ *this->ImplFileStreams[config]
+ << "# This file contains build statements specific to the \"" << config
+ << "\"\n# configuration.\n\n";
- // Open config file.
- if (!this->OpenFileStream(this->ConfigFileStreams[config],
- GetNinjaConfigFilename(config))) {
- return false;
- }
+ // Open config file.
+ if (!this->OpenFileStream(this->ConfigFileStreams[config],
+ GetNinjaConfigFilename(config))) {
+ return false;
+ }
- // Write a comment about this file.
- *this->ConfigFileStreams[config]
- << "# This file contains aliases specific to the \"" << config
- << "\"\n# configuration.\n\n"
- << "include " << GetNinjaImplFilename(config) << "\n\n";
- }
+ // Write a comment about this file.
+ *this->ConfigFileStreams[config]
+ << "# This file contains aliases specific to the \"" << config
+ << "\"\n# configuration.\n\n"
+ << "include " << GetNinjaImplFilename(config) << "\n\n";
- return true;
+ return true;
+ });
}
void cmGlobalNinjaMultiGenerator::CloseBuildFileStreams()
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index fd8542f..78fcb49 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -152,7 +152,6 @@ public:
bool IsGCCOnWindows() const { return this->UsingGCCOnWindows; }
-public:
cmGlobalNinjaGenerator(cmake* cm);
static std::unique_ptr<cmGlobalGeneratorFactory> NewFactory()
@@ -570,7 +569,6 @@ private:
bool DiagnosedCxxModuleSupport = false;
-private:
void InitOutputPathPrefix();
std::string OutputPathPrefix;
diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h
index c15f491..7c950cc 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.h
+++ b/Source/cmGlobalUnixMakefileGenerator3.h
@@ -134,13 +134,13 @@ public:
std::set<std::string>& emitted);
// Make tool supports dependency files generated by compiler
- bool SupportsCompilerDependencies()
+ bool SupportsCompilerDependencies() const
{
return this->ToolSupportsCompilerDependencies;
}
// Make tool supports long line dependencies
- bool SupportsLongLineDependencies()
+ bool SupportsLongLineDependencies() const
{
return this->ToolSupportsLongLineDependencies;
}
diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx
index 92ffe29..122bda5 100644
--- a/Source/cmGraphVizWriter.cxx
+++ b/Source/cmGraphVizWriter.cxx
@@ -230,7 +230,7 @@ void cmGraphVizWriter::ReadSettings(
std::cout << "Reading GraphViz options file: " << inFileName << std::endl;
-#define __set_if_set(var, cmakeDefinition) \
+#define set_if_set(var, cmakeDefinition) \
do { \
cmProp value = mf.GetDefinition(cmakeDefinition); \
if (value) { \
@@ -238,11 +238,11 @@ void cmGraphVizWriter::ReadSettings(
} \
} while (false)
- __set_if_set(this->GraphName, "GRAPHVIZ_GRAPH_NAME");
- __set_if_set(this->GraphHeader, "GRAPHVIZ_GRAPH_HEADER");
- __set_if_set(this->GraphNodePrefix, "GRAPHVIZ_NODE_PREFIX");
+ set_if_set(this->GraphName, "GRAPHVIZ_GRAPH_NAME");
+ set_if_set(this->GraphHeader, "GRAPHVIZ_GRAPH_HEADER");
+ set_if_set(this->GraphNodePrefix, "GRAPHVIZ_NODE_PREFIX");
-#define __set_bool_if_set(var, cmakeDefinition) \
+#define set_bool_if_set(var, cmakeDefinition) \
do { \
cmProp value = mf.GetDefinition(cmakeDefinition); \
if (value) { \
@@ -250,20 +250,20 @@ void cmGraphVizWriter::ReadSettings(
} \
} while (false)
- __set_bool_if_set(this->GenerateForExecutables, "GRAPHVIZ_EXECUTABLES");
- __set_bool_if_set(this->GenerateForStaticLibs, "GRAPHVIZ_STATIC_LIBS");
- __set_bool_if_set(this->GenerateForSharedLibs, "GRAPHVIZ_SHARED_LIBS");
- __set_bool_if_set(this->GenerateForModuleLibs, "GRAPHVIZ_MODULE_LIBS");
- __set_bool_if_set(this->GenerateForInterfaceLibs, "GRAPHVIZ_INTERFACE_LIBS");
- __set_bool_if_set(this->GenerateForObjectLibs, "GRAPHVIZ_OBJECT_LIBS");
- __set_bool_if_set(this->GenerateForUnknownLibs, "GRAPHVIZ_UNKNOWN_LIBS");
- __set_bool_if_set(this->GenerateForCustomTargets, "GRAPHVIZ_CUSTOM_TARGETS");
- __set_bool_if_set(this->GenerateForExternals, "GRAPHVIZ_EXTERNAL_LIBS");
- __set_bool_if_set(this->GeneratePerTarget, "GRAPHVIZ_GENERATE_PER_TARGET");
- __set_bool_if_set(this->GenerateDependers, "GRAPHVIZ_GENERATE_DEPENDERS");
+ set_bool_if_set(this->GenerateForExecutables, "GRAPHVIZ_EXECUTABLES");
+ set_bool_if_set(this->GenerateForStaticLibs, "GRAPHVIZ_STATIC_LIBS");
+ set_bool_if_set(this->GenerateForSharedLibs, "GRAPHVIZ_SHARED_LIBS");
+ set_bool_if_set(this->GenerateForModuleLibs, "GRAPHVIZ_MODULE_LIBS");
+ set_bool_if_set(this->GenerateForInterfaceLibs, "GRAPHVIZ_INTERFACE_LIBS");
+ set_bool_if_set(this->GenerateForObjectLibs, "GRAPHVIZ_OBJECT_LIBS");
+ set_bool_if_set(this->GenerateForUnknownLibs, "GRAPHVIZ_UNKNOWN_LIBS");
+ set_bool_if_set(this->GenerateForCustomTargets, "GRAPHVIZ_CUSTOM_TARGETS");
+ set_bool_if_set(this->GenerateForExternals, "GRAPHVIZ_EXTERNAL_LIBS");
+ set_bool_if_set(this->GeneratePerTarget, "GRAPHVIZ_GENERATE_PER_TARGET");
+ set_bool_if_set(this->GenerateDependers, "GRAPHVIZ_GENERATE_DEPENDERS");
std::string ignoreTargetsRegexes;
- __set_if_set(ignoreTargetsRegexes, "GRAPHVIZ_IGNORE_TARGETS");
+ set_if_set(ignoreTargetsRegexes, "GRAPHVIZ_IGNORE_TARGETS");
this->TargetsToIgnoreRegex.clear();
if (!ignoreTargetsRegexes.empty()) {
@@ -282,7 +282,7 @@ void cmGraphVizWriter::ReadSettings(
void cmGraphVizWriter::Write()
{
- auto gg = this->GlobalGenerator;
+ const auto* gg = this->GlobalGenerator;
this->VisitGraph(gg->GetName());
@@ -303,7 +303,7 @@ void cmGraphVizWriter::Write()
}
// write global data and collect all connection data for per target graphs
- for (auto const gt : sortedGeneratorTargets) {
+ for (const auto* const gt : sortedGeneratorTargets) {
auto item = cmLinkItem(gt, false, gt->GetBacktrace());
this->VisitItem(item);
}
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index ff08ee4..b04ad0c 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -57,28 +57,38 @@ public:
bool MakeFilesFullPath(const char* modeName,
const std::vector<std::string>& relFiles,
std::vector<std::string>& absFiles);
- bool CheckCMP0006(bool& failure);
+ bool CheckCMP0006(bool& failure) const;
std::string GetDestination(const cmInstallCommandArguments* args,
const std::string& varName,
- const std::string& guess);
- std::string GetRuntimeDestination(const cmInstallCommandArguments* args);
- std::string GetSbinDestination(const cmInstallCommandArguments* args);
- std::string GetArchiveDestination(const cmInstallCommandArguments* args);
- std::string GetLibraryDestination(const cmInstallCommandArguments* args);
- std::string GetIncludeDestination(const cmInstallCommandArguments* args);
- std::string GetSysconfDestination(const cmInstallCommandArguments* args);
- std::string GetSharedStateDestination(const cmInstallCommandArguments* args);
- std::string GetLocalStateDestination(const cmInstallCommandArguments* args);
- std::string GetRunStateDestination(const cmInstallCommandArguments* args);
- std::string GetDataRootDestination(const cmInstallCommandArguments* args);
- std::string GetDataDestination(const cmInstallCommandArguments* args);
- std::string GetInfoDestination(const cmInstallCommandArguments* args);
- std::string GetLocaleDestination(const cmInstallCommandArguments* args);
- std::string GetManDestination(const cmInstallCommandArguments* args);
- std::string GetDocDestination(const cmInstallCommandArguments* args);
+ const std::string& guess) const;
+ std::string GetRuntimeDestination(
+ const cmInstallCommandArguments* args) const;
+ std::string GetSbinDestination(const cmInstallCommandArguments* args) const;
+ std::string GetArchiveDestination(
+ const cmInstallCommandArguments* args) const;
+ std::string GetLibraryDestination(
+ const cmInstallCommandArguments* args) const;
+ std::string GetIncludeDestination(
+ const cmInstallCommandArguments* args) const;
+ std::string GetSysconfDestination(
+ const cmInstallCommandArguments* args) const;
+ std::string GetSharedStateDestination(
+ const cmInstallCommandArguments* args) const;
+ std::string GetLocalStateDestination(
+ const cmInstallCommandArguments* args) const;
+ std::string GetRunStateDestination(
+ const cmInstallCommandArguments* args) const;
+ std::string GetDataRootDestination(
+ const cmInstallCommandArguments* args) const;
+ std::string GetDataDestination(const cmInstallCommandArguments* args) const;
+ std::string GetInfoDestination(const cmInstallCommandArguments* args) const;
+ std::string GetLocaleDestination(
+ const cmInstallCommandArguments* args) const;
+ std::string GetManDestination(const cmInstallCommandArguments* args) const;
+ std::string GetDocDestination(const cmInstallCommandArguments* args) const;
std::string GetDestinationForType(const cmInstallCommandArguments* args,
- const std::string& type);
+ const std::string& type) const;
cmExecutionStatus& Status;
cmMakefile* Makefile;
@@ -1477,7 +1487,7 @@ bool Helper::MakeFilesFullPath(const char* modeName,
return true;
}
-bool Helper::CheckCMP0006(bool& failure)
+bool Helper::CheckCMP0006(bool& failure) const
{
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0006)) {
case cmPolicies::WARN:
@@ -1504,7 +1514,7 @@ bool Helper::CheckCMP0006(bool& failure)
std::string Helper::GetDestination(const cmInstallCommandArguments* args,
const std::string& varName,
- const std::string& guess)
+ const std::string& guess) const
{
if (args && !args->GetDestination().empty()) {
return args->GetDestination();
@@ -1517,54 +1527,55 @@ std::string Helper::GetDestination(const cmInstallCommandArguments* args,
}
std::string Helper::GetRuntimeDestination(
- const cmInstallCommandArguments* args)
+ const cmInstallCommandArguments* args) const
{
return this->GetDestination(args, "CMAKE_INSTALL_BINDIR", "bin");
}
-std::string Helper::GetSbinDestination(const cmInstallCommandArguments* args)
+std::string Helper::GetSbinDestination(
+ const cmInstallCommandArguments* args) const
{
return this->GetDestination(args, "CMAKE_INSTALL_SBINDIR", "sbin");
}
std::string Helper::GetArchiveDestination(
- const cmInstallCommandArguments* args)
+ const cmInstallCommandArguments* args) const
{
return this->GetDestination(args, "CMAKE_INSTALL_LIBDIR", "lib");
}
std::string Helper::GetLibraryDestination(
- const cmInstallCommandArguments* args)
+ const cmInstallCommandArguments* args) const
{
return this->GetDestination(args, "CMAKE_INSTALL_LIBDIR", "lib");
}
std::string Helper::GetIncludeDestination(
- const cmInstallCommandArguments* args)
+ const cmInstallCommandArguments* args) const
{
return this->GetDestination(args, "CMAKE_INSTALL_INCLUDEDIR", "include");
}
std::string Helper::GetSysconfDestination(
- const cmInstallCommandArguments* args)
+ const cmInstallCommandArguments* args) const
{
return this->GetDestination(args, "CMAKE_INSTALL_SYSCONFDIR", "etc");
}
std::string Helper::GetSharedStateDestination(
- const cmInstallCommandArguments* args)
+ const cmInstallCommandArguments* args) const
{
return this->GetDestination(args, "CMAKE_INSTALL_SHAREDSTATEDIR", "com");
}
std::string Helper::GetLocalStateDestination(
- const cmInstallCommandArguments* args)
+ const cmInstallCommandArguments* args) const
{
return this->GetDestination(args, "CMAKE_INSTALL_LOCALSTATEDIR", "var");
}
std::string Helper::GetRunStateDestination(
- const cmInstallCommandArguments* args)
+ const cmInstallCommandArguments* args) const
{
return this->GetDestination(args, "CMAKE_INSTALL_RUNSTATEDIR",
this->GetLocalStateDestination(nullptr) +
@@ -1572,44 +1583,49 @@ std::string Helper::GetRunStateDestination(
}
std::string Helper::GetDataRootDestination(
- const cmInstallCommandArguments* args)
+ const cmInstallCommandArguments* args) const
{
return this->GetDestination(args, "CMAKE_INSTALL_DATAROOTDIR", "share");
}
-std::string Helper::GetDataDestination(const cmInstallCommandArguments* args)
+std::string Helper::GetDataDestination(
+ const cmInstallCommandArguments* args) const
{
return this->GetDestination(args, "CMAKE_INSTALL_DATADIR",
this->GetDataRootDestination(nullptr));
}
-std::string Helper::GetInfoDestination(const cmInstallCommandArguments* args)
+std::string Helper::GetInfoDestination(
+ const cmInstallCommandArguments* args) const
{
return this->GetDestination(args, "CMAKE_INSTALL_INFODIR",
this->GetDataRootDestination(nullptr) + "/info");
}
-std::string Helper::GetLocaleDestination(const cmInstallCommandArguments* args)
+std::string Helper::GetLocaleDestination(
+ const cmInstallCommandArguments* args) const
{
return this->GetDestination(args, "CMAKE_INSTALL_LOCALEDIR",
this->GetDataRootDestination(nullptr) +
"/locale");
}
-std::string Helper::GetManDestination(const cmInstallCommandArguments* args)
+std::string Helper::GetManDestination(
+ const cmInstallCommandArguments* args) const
{
return this->GetDestination(args, "CMAKE_INSTALL_MANDIR",
this->GetDataRootDestination(nullptr) + "/man");
}
-std::string Helper::GetDocDestination(const cmInstallCommandArguments* args)
+std::string Helper::GetDocDestination(
+ const cmInstallCommandArguments* args) const
{
return this->GetDestination(args, "CMAKE_INSTALL_DOCDIR",
this->GetDataRootDestination(nullptr) + "/doc");
}
std::string Helper::GetDestinationForType(
- const cmInstallCommandArguments* args, const std::string& type)
+ const cmInstallCommandArguments* args, const std::string& type) const
{
if (args && !args->GetDestination().empty()) {
return args->GetDestination();
diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx
index a034689..cc3df2a 100644
--- a/Source/cmInstallCommandArguments.cxx
+++ b/Source/cmInstallCommandArguments.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstallCommandArguments.h"
+#include <algorithm>
#include <utility>
#include <cmext/string_view>
@@ -176,13 +177,11 @@ bool cmInstallCommandArguments::Finalize()
bool cmInstallCommandArguments::CheckPermissions()
{
this->PermissionsString.clear();
- for (std::string const& perm : this->Permissions) {
- if (!cmInstallCommandArguments::CheckPermissions(
- perm, this->PermissionsString)) {
- return false;
- }
- }
- return true;
+ return std::all_of(this->Permissions.begin(), this->Permissions.end(),
+ [this](std::string const& perm) -> bool {
+ return cmInstallCommandArguments::CheckPermissions(
+ perm, this->PermissionsString);
+ });
}
bool cmInstallCommandArguments::CheckPermissions(
diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx
index ce2472d..5b01791 100644
--- a/Source/cmInstallScriptGenerator.cxx
+++ b/Source/cmInstallScriptGenerator.cxx
@@ -53,9 +53,8 @@ bool cmInstallScriptGenerator::Compute(cmLocalGenerator* lg)
return true;
}
-void cmInstallScriptGenerator::AddScriptInstallRule(std::ostream& os,
- Indent indent,
- std::string const& script)
+void cmInstallScriptGenerator::AddScriptInstallRule(
+ std::ostream& os, Indent indent, std::string const& script) const
{
if (this->Code) {
os << indent << script << "\n";
diff --git a/Source/cmInstallScriptGenerator.h b/Source/cmInstallScriptGenerator.h
index 338d866..f7ee3f9 100644
--- a/Source/cmInstallScriptGenerator.h
+++ b/Source/cmInstallScriptGenerator.h
@@ -30,7 +30,7 @@ protected:
void GenerateScriptForConfig(std::ostream& os, const std::string& config,
Indent indent) override;
void AddScriptInstallRule(std::ostream& os, Indent indent,
- std::string const& script);
+ std::string const& script) const;
std::string const Script;
bool const Code;
diff --git a/Source/cmLinkItemGraphVisitor.cxx b/Source/cmLinkItemGraphVisitor.cxx
index dfdd3ff..7ad8690 100644
--- a/Source/cmLinkItemGraphVisitor.cxx
+++ b/Source/cmLinkItemGraphVisitor.cxx
@@ -98,7 +98,8 @@ void cmLinkItemGraphVisitor::GetDependencies(cmGeneratorTarget const& target,
std::string const& config,
DependencyMap& dependencies)
{
- auto implementationLibraries = target.GetLinkImplementationLibraries(config);
+ const auto* implementationLibraries =
+ target.GetLinkImplementationLibraries(config);
if (implementationLibraries != nullptr) {
for (auto const& lib : implementationLibraries->Libraries) {
auto const& name = lib.AsStr();
@@ -106,7 +107,7 @@ void cmLinkItemGraphVisitor::GetDependencies(cmGeneratorTarget const& target,
}
}
- auto interfaceLibraries =
+ const auto* interfaceLibraries =
target.GetLinkInterfaceLibraries(config, &target, true);
if (interfaceLibraries != nullptr) {
for (auto const& lib : interfaceLibraries->Libraries) {
diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx
index 5739fec..9cae926 100644
--- a/Source/cmLinkLineDeviceComputer.cxx
+++ b/Source/cmLinkLineDeviceComputer.cxx
@@ -3,6 +3,7 @@
#include "cmLinkLineDeviceComputer.h"
+#include <algorithm>
#include <set>
#include <utility>
@@ -57,17 +58,15 @@ bool cmLinkLineDeviceComputer::ComputeRequiresDeviceLinking(
using ItemVector = cmComputeLinkInformation::ItemVector;
ItemVector const& items = cli.GetItems();
std::string config = cli.GetConfig();
- for (auto const& item : items) {
- if (item.Target &&
- item.Target->GetType() == cmStateEnums::STATIC_LIBRARY) {
- if ((!item.Target->GetPropertyAsBool("CUDA_RESOLVE_DEVICE_SYMBOLS")) &&
- item.Target->GetPropertyAsBool("CUDA_SEPARABLE_COMPILATION")) {
+ return std::any_of(
+ items.begin(), items.end(),
+ [](cmComputeLinkInformation::Item const& item) -> bool {
+ return item.Target &&
+ item.Target->GetType() == cmStateEnums::STATIC_LIBRARY &&
// this dependency requires us to device link it
- return true;
- }
- }
- }
- return false;
+ !item.Target->GetPropertyAsBool("CUDA_RESOLVE_DEVICE_SYMBOLS") &&
+ item.Target->GetPropertyAsBool("CUDA_SEPARABLE_COMPILATION");
+ });
}
void cmLinkLineDeviceComputer::ComputeLinkLibraries(
diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index 36a1372..1464a14 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -30,7 +30,7 @@ struct cmListFileParser
bool ParseFunction(const char* name, long line);
bool AddArgument(cmListFileLexer_Token* token,
cmListFileArgument::Delimiter delim);
- cm::optional<cmListFileContext> CheckNesting();
+ cm::optional<cmListFileContext> CheckNesting() const;
cmListFile* ListFile;
cmListFileBacktrace Backtrace;
cmMessenger* Messenger;
@@ -352,7 +352,7 @@ bool TopIs(std::vector<NestingState>& stack, NestingStateEnum state)
}
}
-cm::optional<cmListFileContext> cmListFileParser::CheckNesting()
+cm::optional<cmListFileContext> cmListFileParser::CheckNesting() const
{
std::vector<NestingState> stack;
diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx
index adebe02..5a7b30f 100644
--- a/Source/cmLoadCommandCommand.cxx
+++ b/Source/cmLoadCommandCommand.cxx
@@ -3,10 +3,12 @@
#if !defined(_WIN32) && !defined(__sun)
// POSIX APIs are needed
+// NOLINTNEXTLINE(bugprone-reserved-identifier)
# define _POSIX_C_SOURCE 200809L
#endif
#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__)
// For isascii
+// NOLINTNEXTLINE(bugprone-reserved-identifier)
# define _XOPEN_SOURCE 700
#endif
@@ -31,6 +33,7 @@
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
+// NOLINTNEXTLINE(bugprone-suspicious-include)
#include "cmCPluginAPI.cxx"
#ifdef __QNX__
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index a6d898d..349b53b 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1853,17 +1853,12 @@ bool cmLocalGenerator::AllAppleArchSysrootsAreTheSame(
return false;
}
- for (std::string const& arch : archs) {
- std::string const& archSysroot = this->AppleArchSysroots[arch];
- if (cmIsOff(archSysroot)) {
- continue;
- }
- if (archSysroot != sysroot) {
- return false;
- }
- }
-
- return true;
+ return std::all_of(archs.begin(), archs.end(),
+ [this, &sysroot](std::string const& arch) -> bool {
+ std::string const& archSysroot =
+ this->AppleArchSysroots[arch];
+ return cmIsOff(archSysroot) || archSysroot == sysroot;
+ });
}
void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
@@ -2553,7 +2548,7 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
cmProp ReuseFrom =
target->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM");
- auto pch_sf = this->Makefile->GetOrCreateSource(
+ auto* pch_sf = this->Makefile->GetOrCreateSource(
pchSource, false, cmSourceFileLocationKind::Known);
if (!this->GetGlobalGenerator()->IsXcode()) {
@@ -2570,7 +2565,7 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
"OBJECT_OUTPUTS",
cmStrCat("$<$<CONFIG:", config, ">:", pchFile, ">"));
} else {
- auto reuseTarget =
+ auto* reuseTarget =
this->GlobalGenerator->FindGeneratorTarget(*ReuseFrom);
if (this->Makefile->IsOn("CMAKE_PCH_COPY_COMPILE_PDB")) {
@@ -2633,7 +2628,7 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
// Add pchHeader to source files, which will
// be grouped as "Precompile Header File"
- auto pchHeader_sf = this->Makefile->GetOrCreateSource(
+ auto* pchHeader_sf = this->Makefile->GetOrCreateSource(
pchHeader, false, cmSourceFileLocationKind::Known);
std::string err;
pchHeader_sf->ResolveFullPath(&err);
@@ -2772,7 +2767,7 @@ inline void RegisterUnitySources(cmGeneratorTarget* target, cmSourceFile* sf,
void cmLocalGenerator::IncludeFileInUnitySources(
cmGeneratedFileStream& unity_file, std::string const& sf_full_path,
- cmProp beforeInclude, cmProp afterInclude, cmProp uniqueIdName)
+ cmProp beforeInclude, cmProp afterInclude, cmProp uniqueIdName) const
{
if (uniqueIdName && !uniqueIdName->empty()) {
std::string pathToHash;
@@ -2961,7 +2956,7 @@ void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target)
}
for (auto const& file : unity_files) {
- auto unity = this->GetMakefile()->GetOrCreateSource(file);
+ auto* unity = this->GetMakefile()->GetOrCreateSource(file);
target->AddSource(file, true);
unity->SetProperty("SKIP_UNITY_BUILD_INCLUSION", "ON");
unity->SetProperty("UNITY_SOURCE_FILE", file.c_str());
@@ -4039,26 +4034,23 @@ cmSourceFile* AddCustomCommand(
bool AnyOutputMatches(const std::string& name,
const std::vector<std::string>& outputs)
{
- for (std::string const& output : outputs) {
- std::string::size_type pos = output.rfind(name);
- // If the output matches exactly
- if (pos != std::string::npos && pos == output.size() - name.size() &&
- (pos == 0 || output[pos - 1] == '/')) {
- return true;
- }
- }
- return false;
+ return std::any_of(outputs.begin(), outputs.end(),
+ [&name](std::string const& output) -> bool {
+ std::string::size_type pos = output.rfind(name);
+ // If the output matches exactly
+ return (pos != std::string::npos &&
+ pos == output.size() - name.size() &&
+ (pos == 0 || output[pos - 1] == '/'));
+ });
}
bool AnyTargetCommandOutputMatches(
const std::string& name, const std::vector<cmCustomCommand>& commands)
{
- for (cmCustomCommand const& command : commands) {
- if (AnyOutputMatches(name, command.GetByproducts())) {
- return true;
- }
- }
- return false;
+ return std::any_of(commands.begin(), commands.end(),
+ [&name](cmCustomCommand const& command) -> bool {
+ return AnyOutputMatches(name, command.GetByproducts());
+ });
}
}
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index a3610fd..7e4d590 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -656,7 +656,7 @@ private:
void IncludeFileInUnitySources(cmGeneratedFileStream& unity_file,
std::string const& sf_full_path,
cmProp beforeInclude, cmProp afterInclude,
- cmProp uniqueIdName);
+ cmProp uniqueIdName) const;
std::vector<std::string> AddUnityFilesModeAuto(
cmGeneratorTarget* target, std::string const& lang,
std::vector<cmSourceFile*> const& filtered_sources, cmProp beforeInclude,
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index 7229101..b8ad1a0 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -40,7 +40,6 @@
cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg,
cmMakefile* mf)
: cmLocalCommonGenerator(gg, mf, mf->GetState()->GetBinaryDirectory())
- , HomeRelativeOutputPath("")
{
}
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index df7952c..464df68 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -151,8 +151,8 @@ void cmLocalUnixMakefileGenerator3::Generate()
}
auto& gtVisited = this->GetCommandsVisited(gt);
- auto& deps = this->GlobalGenerator->GetTargetDirectDepends(gt);
- for (auto& d : deps) {
+ const auto& deps = this->GlobalGenerator->GetTargetDirectDepends(gt);
+ for (const auto& d : deps) {
// Take the union of visited source files of custom commands
auto depVisited = this->GetCommandsVisited(d);
gtVisited.insert(depVisited.begin(), depVisited.end());
@@ -718,7 +718,7 @@ void cmLocalUnixMakefileGenerator3::WriteSpecialTargetsTop(
constexpr const char* vcs_rules[] = {
"%,v", "RCS/%", "RCS/%,v", "SCCS/s.%", "s.%",
};
- for (auto vcs_rule : vcs_rules) {
+ for (const auto* vcs_rule : vcs_rules) {
std::vector<std::string> vcs_depend;
vcs_depend.emplace_back(vcs_rule);
this->WriteMakeRule(makefileStream, "Disable VCS-based implicit rules.",
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index cea20ad..0fc8fa3 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1824,7 +1824,7 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath,
auto subMfu =
cm::make_unique<cmMakefile>(this->GlobalGenerator, newSnapshot);
- auto subMf = subMfu.get();
+ auto* subMf = subMfu.get();
this->GetGlobalGenerator()->AddMakefile(std::move(subMfu));
if (excludeFromAll) {
@@ -3370,7 +3370,7 @@ cmSourceFile* cmMakefile::GetSource(const std::string& sourceName,
#endif
auto sfsi = this->SourceFileSearchIndex.find(name);
if (sfsi != this->SourceFileSearchIndex.end()) {
- for (auto sf : sfsi->second) {
+ for (auto* sf : sfsi->second) {
if (sf->Matches(sfl)) {
return sf;
}
diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h
index ffc405c..30127fe 100644
--- a/Source/cmNinjaNormalTargetGenerator.h
+++ b/Source/cmNinjaNormalTargetGenerator.h
@@ -52,7 +52,6 @@ private:
std::vector<std::string> ComputeLinkCmd(const std::string& config);
std::vector<std::string> ComputeDeviceLinkCmd();
-private:
// Target name info.
cmGeneratorTarget::Names TargetNames(const std::string& config) const;
std::string TargetLinkLanguage(const std::string& config) const;
diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h
index 4c33fcc..a3b6f98 100644
--- a/Source/cmOSXBundleGenerator.h
+++ b/Source/cmOSXBundleGenerator.h
@@ -62,7 +62,6 @@ public:
private:
bool MustSkip();
-private:
cmGeneratorTarget* GT;
cmMakefile* Makefile;
cmLocalGenerator* LocalGenerator;
diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx
index 359e9f5..ec54537 100644
--- a/Source/cmOutputConverter.cxx
+++ b/Source/cmOutputConverter.cxx
@@ -121,7 +121,7 @@ std::string cmOutputConverter::EscapeForShell(
flags |= Shell_Flag_IsUnix;
}
- return Shell__GetArgument(str, flags);
+ return Shell_GetArgument(str, flags);
}
std::string cmOutputConverter::EscapeForCMake(cm::string_view str)
@@ -150,7 +150,7 @@ std::string cmOutputConverter::EscapeForCMake(cm::string_view str)
std::string cmOutputConverter::EscapeWindowsShellArgument(cm::string_view arg,
int shell_flags)
{
- return Shell__GetArgument(arg, shell_flags);
+ return Shell_GetArgument(arg, shell_flags);
}
cmOutputConverter::FortranFormat cmOutputConverter::GetFortranFormat(
@@ -226,12 +226,12 @@ use the caret character itself (^), use two in a row (^^).
*/
/* Some helpers to identify character classes */
-static bool Shell__CharIsWhitespace(char c)
+static bool Shell_CharIsWhitespace(char c)
{
return ((c == ' ') || (c == '\t'));
}
-static bool Shell__CharNeedsQuotesOnUnix(char c)
+static bool Shell_CharNeedsQuotesOnUnix(char c)
{
return ((c == '\'') || (c == '`') || (c == ';') || (c == '#') ||
(c == '&') || (c == '$') || (c == '(') || (c == ')') || (c == '~') ||
@@ -239,18 +239,18 @@ static bool Shell__CharNeedsQuotesOnUnix(char c)
(c == '\\'));
}
-static bool Shell__CharNeedsQuotesOnWindows(char c)
+static bool Shell_CharNeedsQuotesOnWindows(char c)
{
return ((c == '\'') || (c == '#') || (c == '&') || (c == '<') ||
(c == '>') || (c == '|') || (c == '^'));
}
-static bool Shell__CharIsMakeVariableName(char c)
+static bool Shell_CharIsMakeVariableName(char c)
{
return c && (c == '_' || isalpha((static_cast<int>(c))));
}
-bool cmOutputConverter::Shell__CharNeedsQuotes(char c, int flags)
+bool cmOutputConverter::Shell_CharNeedsQuotes(char c, int flags)
{
/* On Windows the built-in command shell echo never needs quotes. */
if (!(flags & Shell_Flag_IsUnix) && (flags & Shell_Flag_EchoWindows)) {
@@ -258,30 +258,30 @@ bool cmOutputConverter::Shell__CharNeedsQuotes(char c, int flags)
}
/* On all platforms quotes are needed to preserve whitespace. */
- if (Shell__CharIsWhitespace(c)) {
+ if (Shell_CharIsWhitespace(c)) {
return true;
}
if (flags & Shell_Flag_IsUnix) {
/* On UNIX several special characters need quotes to preserve them. */
- if (Shell__CharNeedsQuotesOnUnix(c)) {
+ if (Shell_CharNeedsQuotesOnUnix(c)) {
return true;
}
} else {
/* On Windows several special characters need quotes to preserve them. */
- if (Shell__CharNeedsQuotesOnWindows(c)) {
+ if (Shell_CharNeedsQuotesOnWindows(c)) {
return true;
}
}
return false;
}
-cm::string_view::iterator cmOutputConverter::Shell__SkipMakeVariables(
+cm::string_view::iterator cmOutputConverter::Shell_SkipMakeVariables(
cm::string_view::iterator c, cm::string_view::iterator end)
{
while ((c != end && (c + 1) != end) && (*c == '$' && *(c + 1) == '(')) {
cm::string_view::iterator skip = c + 2;
- while ((skip != end) && Shell__CharIsMakeVariableName(*skip)) {
+ while ((skip != end) && Shell_CharIsMakeVariableName(*skip)) {
++skip;
}
if ((skip != end) && *skip == ')') {
@@ -316,8 +316,8 @@ flag later when we understand applications of this better.
*/
#define KWSYS_SYSTEM_SHELL_QUOTE_MAKE_VARIABLES 0
-bool cmOutputConverter::Shell__ArgumentNeedsQuotes(cm::string_view in,
- int flags)
+bool cmOutputConverter::Shell_ArgumentNeedsQuotes(cm::string_view in,
+ int flags)
{
/* The empty string needs quotes. */
if (in.empty()) {
@@ -330,7 +330,7 @@ bool cmOutputConverter::Shell__ArgumentNeedsQuotes(cm::string_view in,
/* Look for $(MAKEVAR) syntax if requested. */
if (flags & Shell_Flag_AllowMakeVariables) {
#if KWSYS_SYSTEM_SHELL_QUOTE_MAKE_VARIABLES
- cm::string_view::iterator skip = Shell__SkipMakeVariables(cit, cend);
+ cm::string_view::iterator skip = Shell_SkipMakeVariables(cit, cend);
if (skip != cit) {
/* We need to quote make variable references to preserve the
string with contents substituted in its place. */
@@ -338,7 +338,7 @@ bool cmOutputConverter::Shell__ArgumentNeedsQuotes(cm::string_view in,
}
#else
/* Skip over the make variable references if any are present. */
- cit = Shell__SkipMakeVariables(cit, cend);
+ cit = Shell_SkipMakeVariables(cit, cend);
/* Stop if we have reached the end of the string. */
if (cit == cend) {
@@ -348,7 +348,7 @@ bool cmOutputConverter::Shell__ArgumentNeedsQuotes(cm::string_view in,
}
/* Check whether this character needs quotes. */
- if (Shell__CharNeedsQuotes(*cit, flags)) {
+ if (Shell_CharNeedsQuotes(*cit, flags)) {
return true;
}
}
@@ -364,8 +364,7 @@ bool cmOutputConverter::Shell__ArgumentNeedsQuotes(cm::string_view in,
return false;
}
-std::string cmOutputConverter::Shell__GetArgument(cm::string_view in,
- int flags)
+std::string cmOutputConverter::Shell_GetArgument(cm::string_view in, int flags)
{
/* Output will be at least as long as input string. */
std::string out;
@@ -375,7 +374,7 @@ std::string cmOutputConverter::Shell__GetArgument(cm::string_view in,
int windows_backslashes = 0;
/* Whether the argument must be quoted. */
- int needQuotes = Shell__ArgumentNeedsQuotes(in, flags);
+ int needQuotes = Shell_ArgumentNeedsQuotes(in, flags);
if (needQuotes) {
/* Add the opening quote for this argument. */
if (flags & Shell_Flag_WatcomQuote) {
@@ -393,7 +392,7 @@ std::string cmOutputConverter::Shell__GetArgument(cm::string_view in,
cit != cend; ++cit) {
/* Look for $(MAKEVAR) syntax if requested. */
if (flags & Shell_Flag_AllowMakeVariables) {
- cm::string_view::iterator skip = Shell__SkipMakeVariables(cit, cend);
+ cm::string_view::iterator skip = Shell_SkipMakeVariables(cit, cend);
if (skip != cit) {
/* Copy to the end of the make variable references. */
while (cit != skip) {
diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h
index 655bc87..f1a8041 100644
--- a/Source/cmOutputConverter.h
+++ b/Source/cmOutputConverter.h
@@ -105,13 +105,12 @@ public:
private:
cmState* GetState() const;
- static bool Shell__CharNeedsQuotes(char c, int flags);
- static cm::string_view::iterator Shell__SkipMakeVariables(
+ static bool Shell_CharNeedsQuotes(char c, int flags);
+ static cm::string_view::iterator Shell_SkipMakeVariables(
cm::string_view::iterator begin, cm::string_view::iterator end);
- static bool Shell__ArgumentNeedsQuotes(cm::string_view in, int flags);
- static std::string Shell__GetArgument(cm::string_view in, int flags);
+ static bool Shell_ArgumentNeedsQuotes(cm::string_view in, int flags);
+ static std::string Shell_GetArgument(cm::string_view in, int flags);
-private:
cmStateSnapshot StateSnapshot;
bool LinkScriptShell;
diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx
index aa5abcb..d589614 100644
--- a/Source/cmOutputRequiredFilesCommand.cxx
+++ b/Source/cmOutputRequiredFilesCommand.cxx
@@ -376,7 +376,7 @@ protected:
}
// Didn't find an instance. Create a new one and save it.
auto info = cm::make_unique<cmDependInformation>();
- auto ptr = info.get();
+ auto* ptr = info.get();
info->FullPath = fullPath;
info->PathOnly = cmSystemTools::GetFilenamePath(fullPath);
info->IncludeName = file;
diff --git a/Source/cmProcessOutput.cxx b/Source/cmProcessOutput.cxx
index 2d2676e..10c4215 100644
--- a/Source/cmProcessOutput.cxx
+++ b/Source/cmProcessOutput.cxx
@@ -51,8 +51,6 @@ cmProcessOutput::cmProcessOutput(Encoding encoding, unsigned int maxSize)
#endif
}
-cmProcessOutput::~cmProcessOutput() = default;
-
bool cmProcessOutput::DecodeText(std::string raw, std::string& decoded,
size_t id)
{
diff --git a/Source/cmProcessOutput.h b/Source/cmProcessOutput.h
index a1f73bd..8cee987 100644
--- a/Source/cmProcessOutput.h
+++ b/Source/cmProcessOutput.h
@@ -47,7 +47,7 @@ public:
* 0 as \a maxSize.
*/
cmProcessOutput(Encoding encoding = Auto, unsigned int maxSize = 1024);
- ~cmProcessOutput();
+ ~cmProcessOutput() = default;
/**
* Decode \a raw string using external encoding to internal
* encoding in \a decoded.
diff --git a/Source/cmQtAutoGen.h b/Source/cmQtAutoGen.h
index e12a653..466a954 100644
--- a/Source/cmQtAutoGen.h
+++ b/Source/cmQtAutoGen.h
@@ -64,7 +64,6 @@ public:
/// @brief Maximum number of parallel threads/processes in a generator
static unsigned int const ParallelMax;
-public:
/// @brief Returns the generator name
static cm::string_view GeneratorName(GenT genType);
/// @brief Returns the generator name in upper case
diff --git a/Source/cmQtAutoGenGlobalInitializer.h b/Source/cmQtAutoGenGlobalInitializer.h
index ea3821d..afcb4a2 100644
--- a/Source/cmQtAutoGenGlobalInitializer.h
+++ b/Source/cmQtAutoGenGlobalInitializer.h
@@ -45,7 +45,6 @@ public:
std::string ui;
};
-public:
cmQtAutoGenGlobalInitializer(
std::vector<std::unique_ptr<cmLocalGenerator>> const& localGenerators);
~cmQtAutoGenGlobalInitializer();
@@ -73,7 +72,6 @@ private:
std::string const& generator, std::string const& executable,
std::string& error);
-private:
std::vector<std::unique_ptr<cmQtAutoGenInitializer>> Initializers_;
std::map<cmLocalGenerator*, std::string> GlobalAutoGenTargets_;
std::map<cmLocalGenerator*, std::string> GlobalAutoRccTargets_;
diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h
index e0e66f1..f7e126d 100644
--- a/Source/cmQtAutoGenInitializer.h
+++ b/Source/cmQtAutoGenInitializer.h
@@ -98,7 +98,6 @@ public:
, GenNameUpper(cmQtAutoGen::GeneratorNameUpper(gen)){};
};
-public:
/** @return The detected Qt version and the required Qt major version. */
static std::pair<IntegerVersion, unsigned int> GetQtVersion(
cmGeneratorTarget const* genTarget);
@@ -149,7 +148,6 @@ private:
bool GetQtExecutable(GenVarsT& genVars, const std::string& executable,
bool ignoreMissingTarget) const;
-private:
cmQtAutoGenGlobalInitializer* GlobalInitializer = nullptr;
cmGeneratorTarget* GenTarget = nullptr;
cmGlobalGenerator* GlobalGen = nullptr;
diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx
index ebb6bd7..6e88e26 100644
--- a/Source/cmQtAutoGenerator.cxx
+++ b/Source/cmQtAutoGenerator.cxx
@@ -36,8 +36,6 @@ cmQtAutoGenerator::Logger::Logger()
}
}
-cmQtAutoGenerator::Logger::~Logger() = default;
-
void cmQtAutoGenerator::Logger::RaiseVerbosity(unsigned int value)
{
if (this->Verbosity_ < value) {
diff --git a/Source/cmQtAutoGenerator.h b/Source/cmQtAutoGenerator.h
index 53fbd69..5c3a8ad 100644
--- a/Source/cmQtAutoGenerator.h
+++ b/Source/cmQtAutoGenerator.h
@@ -31,7 +31,7 @@ public:
public:
// -- Construction
Logger();
- ~Logger();
+ ~Logger() = default;
// -- Verbosity
unsigned int Verbosity() const { return this->Verbosity_; }
void SetVerbosity(unsigned int value) { this->Verbosity_ = value; }
@@ -54,7 +54,6 @@ public:
private:
static std::string HeadLine(cm::string_view title);
- private:
mutable std::mutex Mutex_;
unsigned int Verbosity_ = 0;
bool ColorOutput_ = false;
@@ -79,7 +78,6 @@ public:
static bool FileDiffers(std::string const& filename,
std::string const& content);
-public:
// -- Constructors
cmQtAutoGenerator(GenT genType);
virtual ~cmQtAutoGenerator();
@@ -140,7 +138,6 @@ public:
private:
std::string ConfigKey(cm::string_view key) const;
- private:
Json::Value Json_;
cmQtAutoGenerator& Gen_;
};
diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx
index 3556051..68d3c6c 100644
--- a/Source/cmQtAutoMocUic.cxx
+++ b/Source/cmQtAutoMocUic.cxx
@@ -55,7 +55,6 @@ public:
cmQtAutoMocUicT(cmQtAutoMocUicT const&) = delete;
cmQtAutoMocUicT& operator=(cmQtAutoMocUicT const&) = delete;
-public:
// -- Types
/** Include string with sub parts. */
@@ -112,7 +111,6 @@ public:
using FileHandleT = std::shared_ptr<FileT>;
using GetOrInsertT = std::pair<FileHandleT, bool>;
- public:
ParseCacheT();
~ParseCacheT();
@@ -135,7 +133,6 @@ public:
{
}
- public:
std::string FileName;
cmFileTime FileTime;
ParseCacheT::FileHandleT ParseData;
@@ -266,7 +263,6 @@ public:
std::vector<std::string> Options;
};
- public:
UicSettingsT();
~UicSettingsT();
@@ -379,7 +375,6 @@ public:
void MocIncludes();
void UicIncludes();
- protected:
SourceFileHandleT FileHandle;
std::string Content;
};
@@ -572,7 +567,6 @@ private:
static std::vector<std::string> dependenciesFromDepFile(
const char* filePath);
-private:
// -- Settings
BaseSettingsT BaseConst_;
BaseEvalT BaseEval_;
@@ -1432,13 +1426,12 @@ bool cmQtAutoMocUicT::JobEvalCacheMocT::FindIncludedHeader(
return true;
}
// Search in include directories
- for (std::string const& path : this->MocConst().IncludePaths) {
- if (findHeader(cmStrCat(path, '/', includeBase))) {
- return true;
- }
- }
- // Return without success
- return false;
+ auto const& includePaths = this->MocConst().IncludePaths;
+ return std::any_of(
+ includePaths.begin(), includePaths.end(),
+ [&findHeader, &includeBase](std::string const& path) -> bool {
+ return findHeader(cmStrCat(path, '/', includeBase));
+ });
}
bool cmQtAutoMocUicT::JobEvalCacheMocT::RegisterIncluded(
@@ -1544,31 +1537,30 @@ bool cmQtAutoMocUicT::JobEvalCacheUicT::EvalFile(
}
std::string const sourceDirPrefix = SubDirPrefix(sourceFile.FileName);
- for (IncludeKeyT const& incKey : Include) {
- // Find .ui file
- this->UiName = cmStrCat(incKey.Base, ".ui");
- if (!this->FindIncludedUi(sourceDirPrefix, incKey.Dir)) {
- this->LogError(
- GenT::UIC,
- cmStrCat(this->MessagePath(sourceFile.FileName),
- "\nincludes the uic file ", this->MessagePath(incKey.Key),
- ",\nbut the user interface file ",
- this->MessagePath(this->UiName),
- "\ncould not be found in the following directories\n",
- this->MessageSearchLocations()));
- return false;
- }
- // Check if the file is skipped
- if (this->UicConst().skipped(this->UiFileHandle->FileName)) {
- continue;
- }
- // Register mapping
- if (!this->RegisterMapping(incKey.Key, sourceFileHandle)) {
- return false;
- }
- }
-
- return true;
+ return std::all_of(
+ Include.begin(), Include.end(),
+ [this, &sourceDirPrefix, &sourceFile,
+ &sourceFileHandle](IncludeKeyT const& incKey) -> bool {
+ // Find .ui file
+ this->UiName = cmStrCat(incKey.Base, ".ui");
+ if (!this->FindIncludedUi(sourceDirPrefix, incKey.Dir)) {
+ this->LogError(
+ GenT::UIC,
+ cmStrCat(this->MessagePath(sourceFile.FileName),
+ "\nincludes the uic file ", this->MessagePath(incKey.Key),
+ ",\nbut the user interface file ",
+ this->MessagePath(this->UiName),
+ "\ncould not be found in the following directories\n",
+ this->MessageSearchLocations()));
+ return false;
+ }
+ // Check if the file is skipped
+ if (this->UicConst().skipped(this->UiFileHandle->FileName)) {
+ return true;
+ }
+ // Register mapping
+ return this->RegisterMapping(incKey.Key, sourceFileHandle);
+ });
}
bool cmQtAutoMocUicT::JobEvalCacheUicT::FindIncludedUi(
@@ -2708,7 +2700,7 @@ void cmQtAutoMocUicT::CreateParseJobs(SourceFileMapT const& sourceMap)
{
cmFileTime const parseCacheTime = this->BaseEval().ParseCacheTime;
ParseCacheT& parseCache = this->BaseEval().ParseCache;
- for (auto& src : sourceMap) {
+ for (const auto& src : sourceMap) {
// Get or create the file parse data reference
ParseCacheT::GetOrInsertT cacheEntry = parseCache.GetOrInsert(src.first);
src.second->ParseData = std::move(cacheEntry.first);
diff --git a/Source/cmQtAutoRcc.cxx b/Source/cmQtAutoRcc.cxx
index 943cc93..414a692 100644
--- a/Source/cmQtAutoRcc.cxx
+++ b/Source/cmQtAutoRcc.cxx
@@ -52,7 +52,6 @@ private:
bool GenerateRcc();
bool GenerateWrapper();
-private:
// -- Config settings
bool MultiConfig_ = false;
// -- Directories
diff --git a/Source/cmRuntimeDependencyArchive.cxx b/Source/cmRuntimeDependencyArchive.cxx
index 0781d29..472f234 100644
--- a/Source/cmRuntimeDependencyArchive.cxx
+++ b/Source/cmRuntimeDependencyArchive.cxx
@@ -181,13 +181,10 @@ bool cmRuntimeDependencyArchive::GetRuntimeDependencies(
return false;
}
}
- for (auto const& mod : modules) {
- if (!this->Linker->ScanDependencies(mod, cmStateEnums::MODULE_LIBRARY)) {
- return false;
- }
- }
-
- return true;
+ return std::all_of(
+ modules.begin(), modules.end(), [this](std::string const& mod) -> bool {
+ return this->Linker->ScanDependencies(mod, cmStateEnums::MODULE_LIBRARY);
+ });
}
void cmRuntimeDependencyArchive::SetError(const std::string& e)
diff --git a/Source/cmScriptGenerator.cxx b/Source/cmScriptGenerator.cxx
index adc0679..5ac7be9 100644
--- a/Source/cmScriptGenerator.cxx
+++ b/Source/cmScriptGenerator.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmScriptGenerator.h"
+#include <algorithm>
#include <utility>
#include "cmStringAlgorithms.h"
@@ -11,7 +12,6 @@ cmScriptGenerator::cmScriptGenerator(std::string config_var,
std::vector<std::string> configurations)
: RuntimeConfigVariable(std::move(config_var))
, Configurations(std::move(configurations))
- , ConfigurationName("")
, ConfigurationTypes(nullptr)
, ActionsPerConfig(false)
{
@@ -120,12 +120,10 @@ bool cmScriptGenerator::GeneratesForConfig(const std::string& config)
// This is a configuration-specific rule. Check if the config
// matches this rule.
std::string config_upper = cmSystemTools::UpperCase(config);
- for (std::string const& cfg : this->Configurations) {
- if (cmSystemTools::UpperCase(cfg) == config_upper) {
- return true;
- }
- }
- return false;
+ return std::any_of(this->Configurations.begin(), this->Configurations.end(),
+ [&config_upper](std::string const& cfg) -> bool {
+ return cmSystemTools::UpperCase(cfg) == config_upper;
+ });
}
void cmScriptGenerator::GenerateScriptActionsOnce(std::ostream& os,
diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx
index 970564d..c899053 100644
--- a/Source/cmSetPropertyCommand.cxx
+++ b/Source/cmSetPropertyCommand.cxx
@@ -189,7 +189,7 @@ std::string MakeSourceFilePathAbsoluteIfNeeded(
if (!needed) {
return source_file_path;
}
- const std::string absolute_file_path = cmSystemTools::CollapseFullPath(
+ std::string absolute_file_path = cmSystemTools::CollapseFullPath(
source_file_path, status.GetMakefile().GetCurrentSourceDirectory());
return absolute_file_path;
}
@@ -223,7 +223,7 @@ void MakeSourceFilePathsAbsoluteIfNeeded(
bool HandleAndValidateSourceFilePropertyGENERATED(
cmSourceFile* sf, std::string const& propertyValue, PropertyOp op)
{
- auto& mf = *sf->GetLocation().GetMakefile();
+ const auto& mf = *sf->GetLocation().GetMakefile();
auto policyStatus = mf.GetPolicyStatus(cmPolicies::CMP0118);
const bool policyWARN = policyStatus == cmPolicies::WARN;
@@ -589,7 +589,7 @@ bool HandleSourceMode(cmExecutionStatus& status,
status, files_absolute, unique_files.begin(), unique_files.end(),
source_file_paths_should_be_absolute);
- for (const auto mf : directory_makefiles) {
+ for (auto* const mf : directory_makefiles) {
for (std::string const& name : files_absolute) {
// Get the source file.
if (cmSourceFile* sf = mf->GetOrCreateSource(name)) {
diff --git a/Source/cmSetSourceFilesPropertiesCommand.cxx b/Source/cmSetSourceFilesPropertiesCommand.cxx
index 742aa96..237b67f 100644
--- a/Source/cmSetSourceFilesPropertiesCommand.cxx
+++ b/Source/cmSetSourceFilesPropertiesCommand.cxx
@@ -101,7 +101,7 @@ bool cmSetSourceFilesPropertiesCommand(std::vector<std::string> const& args,
// Now call the worker function for each directory scope represented by a
// cmMakefile instance.
std::string errors;
- for (const auto mf : source_file_directory_makefiles) {
+ for (auto* const mf : source_file_directory_makefiles) {
bool ret = RunCommandForScope(mf, files.begin(), files.end(), props_begin,
args.end(), errors);
if (!ret) {
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index 9d9a7c3..72bc972 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -427,7 +427,7 @@ bool cmSourceFile::GetPropertyAsBool(const std::string& prop) const
void cmSourceFile::MarkAsGenerated()
{
this->IsGenerated = true;
- auto& mf = *this->Location.GetMakefile();
+ const auto& mf = *this->Location.GetMakefile();
mf.GetGlobalGenerator()->MarkAsGeneratedFile(this->ResolveFullPath());
}
diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx
index 921eb0e..8c7154d 100644
--- a/Source/cmSourceFileLocation.cxx
+++ b/Source/cmSourceFileLocation.cxx
@@ -98,7 +98,7 @@ void cmSourceFileLocation::UpdateExtension(const std::string& name)
// The global generator checks extensions of enabled languages.
cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
cmMakefile const* mf = this->Makefile;
- auto cm = mf->GetCMakeInstance();
+ auto* cm = mf->GetCMakeInstance();
if (!gg->GetLanguageFromExtension(ext.c_str()).empty() ||
cm->IsAKnownExtension(ext)) {
// This is a known extension. Use the given filename with extension.
@@ -155,7 +155,7 @@ bool cmSourceFileLocation::MatchesAmbiguousExtension(
// disk. One of these must match if loc refers to this source file.
auto ext = cm::string_view(this->Name).substr(loc.Name.size() + 1);
cmMakefile const* mf = this->Makefile;
- auto cm = mf->GetCMakeInstance();
+ auto* cm = mf->GetCMakeInstance();
return cm->IsAKnownExtension(ext);
}
diff --git a/Source/cmStandardLexer.h b/Source/cmStandardLexer.h
index 0203779..2689ba1 100644
--- a/Source/cmStandardLexer.h
+++ b/Source/cmStandardLexer.h
@@ -4,18 +4,22 @@
#if defined(__linux)
/* Needed for glibc < 2.12 */
+// NOLINTNEXTLINE(bugprone-reserved-identifier)
# define _XOPEN_SOURCE 600
#endif
#if !defined(_WIN32) && !defined(__sun)
/* POSIX APIs are needed */
+// NOLINTNEXTLINE(bugprone-reserved-identifier)
# define _POSIX_C_SOURCE 200809L
#endif
#if defined(__sun) && defined(__GNUC__) && !defined(__cplusplus)
/* C sources: for fileno and strdup */
+// NOLINTNEXTLINE(bugprone-reserved-identifier)
# define _XOPEN_SOURCE 600
#endif
#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__)
/* For isascii */
+// NOLINTNEXTLINE(bugprone-reserved-identifier)
# define _XOPEN_SOURCE 700
#endif
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 0fd7901..d97762b 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -110,12 +110,9 @@ bool cmState::StringToCacheEntryType(const std::string& s,
bool cmState::IsCacheEntryType(std::string const& key)
{
- for (const std::string& i : cmCacheEntryTypes) {
- if (key == i) {
- return true;
- }
- }
- return false;
+ return std::any_of(
+ cmCacheEntryTypes.begin(), cmCacheEntryTypes.end(),
+ [&key](std::string const& i) -> bool { return key == i; });
}
bool cmState::LoadCache(const std::string& path, bool internal,
@@ -347,7 +344,7 @@ cmPropertyDefinition const* cmState::GetPropertyDefinition(
bool cmState::IsPropertyChained(const std::string& name,
cmProperty::ScopeType scope) const
{
- if (auto def = this->GetPropertyDefinition(name, scope)) {
+ if (const auto* def = this->GetPropertyDefinition(name, scope)) {
return def->IsChained();
}
return false;
diff --git a/Source/cmStateDirectory.h b/Source/cmStateDirectory.h
index 56a262d..70c19bc 100644
--- a/Source/cmStateDirectory.h
+++ b/Source/cmStateDirectory.h
@@ -97,7 +97,6 @@ private:
void ComputeRelativePathTopSource();
void ComputeRelativePathTopBinary();
-private:
cmLinkedTree<cmStateDetail::BuildsystemDirectoryStateType>::iterator
DirectoryState;
cmStateSnapshot Snapshot_;
diff --git a/Source/cmString.cxx b/Source/cmString.cxx
index 8721242..aefaa64 100644
--- a/Source/cmString.cxx
+++ b/Source/cmString.cxx
@@ -1,5 +1,6 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
+// NOLINTNEXTLINE(bugprone-reserved-identifier)
#define _SCL_SECURE_NO_WARNINGS
#include "cmString.hxx"
diff --git a/Source/cmStringAlgorithms.cxx b/Source/cmStringAlgorithms.cxx
index fb0b705..5bb6e7b 100644
--- a/Source/cmStringAlgorithms.cxx
+++ b/Source/cmStringAlgorithms.cxx
@@ -11,6 +11,9 @@
std::string cmTrimWhitespace(cm::string_view str)
{
+ // XXX(clang-tidy): This declaration and the next cannot be `const auto*`
+ // because the qualification of `auto` is platform-dependent.
+ // NOLINTNEXTLINE(readability-qualified-auto)
auto start = str.begin();
while (start != str.end() && cmIsSpace(*start)) {
++start;
@@ -18,6 +21,7 @@ std::string cmTrimWhitespace(cm::string_view str)
if (start == str.end()) {
return std::string();
}
+ // NOLINTNEXTLINE(readability-qualified-auto)
auto stop = str.end() - 1;
while (cmIsSpace(*stop)) {
--stop;
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index 0c8adc7..23fc3e0 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -1,5 +1,6 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
+// NOLINTNEXTLINE(bugprone-reserved-identifier)
#define _SCL_SECURE_NO_WARNINGS
#include "cmStringCommand.h"
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 024356f..18c266f 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -3,11 +3,13 @@
#if !defined(_WIN32) && !defined(__sun)
// POSIX APIs are needed
+// NOLINTNEXTLINE(bugprone-reserved-identifier)
# define _POSIX_C_SOURCE 200809L
#endif
#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
defined(__QNX__)
// For isascii
+// NOLINTNEXTLINE(bugprone-reserved-identifier)
# define _XOPEN_SOURCE 700
#endif
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 1fd2355..91dcd0e 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -209,7 +209,6 @@ public:
TLLCommands;
cmListFileBacktrace Backtrace;
-public:
bool CheckImportedLibName(std::string const& prop,
std::string const& value) const;
@@ -1328,9 +1327,9 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
this->impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
return;
}
- auto reusedTarget = this->impl->Makefile->GetCMakeInstance()
- ->GetGlobalGenerator()
- ->FindTarget(value);
+ auto* reusedTarget = this->impl->Makefile->GetCMakeInstance()
+ ->GetGlobalGenerator()
+ ->FindTarget(value);
if (!reusedTarget) {
const std::string e(
"PRECOMPILE_HEADERS_REUSE_FROM set with non existing target");
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 3066eb2..30d9f5d 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -288,6 +288,5 @@ private:
const char* GetPrefixVariableInternal(
cmStateEnums::ArtifactType artifact) const;
-private:
std::unique_ptr<cmTargetInternals> impl;
};
diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx
index 7fb69bf..b016530 100644
--- a/Source/cmTimestamp.cxx
+++ b/Source/cmTimestamp.cxx
@@ -3,11 +3,13 @@
#if !defined(_WIN32) && !defined(__sun)
// POSIX APIs are needed
+// NOLINTNEXTLINE(bugprone-reserved-identifier)
# define _POSIX_C_SOURCE 200809L
#endif
#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
defined(__QNX__)
// For isascii
+// NOLINTNEXTLINE(bugprone-reserved-identifier)
# define _XOPEN_SOURCE 700
#endif
@@ -21,7 +23,7 @@
#include "cmSystemTools.h"
std::string cmTimestamp::CurrentTime(const std::string& formatString,
- bool utcFlag)
+ bool utcFlag) const
{
time_t currentTimeT = time(nullptr);
std::string source_date_epoch;
@@ -43,7 +45,7 @@ std::string cmTimestamp::CurrentTime(const std::string& formatString,
std::string cmTimestamp::FileModificationTime(const char* path,
const std::string& formatString,
- bool utcFlag)
+ bool utcFlag) const
{
std::string real_path =
cmSystemTools::GetRealPathResolvingWindowsSubst(path);
diff --git a/Source/cmTimestamp.h b/Source/cmTimestamp.h
index 8941abe..0e2c200 100644
--- a/Source/cmTimestamp.h
+++ b/Source/cmTimestamp.h
@@ -14,11 +14,11 @@
class cmTimestamp
{
public:
- std::string CurrentTime(const std::string& formatString, bool utcFlag);
+ std::string CurrentTime(const std::string& formatString, bool utcFlag) const;
std::string FileModificationTime(const char* path,
const std::string& formatString,
- bool utcFlag);
+ bool utcFlag) const;
std::string CreateTimestampFromTimeT(time_t timeT, std::string formatString,
bool utcFlag) const;
diff --git a/Source/cmUVHandlePtr.cxx b/Source/cmUVHandlePtr.cxx
index e556a11..8ea1942 100644
--- a/Source/cmUVHandlePtr.cxx
+++ b/Source/cmUVHandlePtr.cxx
@@ -59,7 +59,7 @@ uv_loop_t* uv_loop_ptr::get() const
template <typename T>
static void handle_default_delete(T* type_handle)
{
- auto handle = reinterpret_cast<uv_handle_t*>(type_handle);
+ auto* handle = reinterpret_cast<uv_handle_t*>(type_handle);
if (handle) {
assert(!uv_is_closing(handle));
if (!uv_is_closing(handle)) {
@@ -154,7 +154,8 @@ struct uv_handle_deleter<uv_async_t>
void uv_async_ptr::send()
{
- auto deleter = std::get_deleter<uv_handle_deleter<uv_async_t>>(this->handle);
+ auto* deleter =
+ std::get_deleter<uv_handle_deleter<uv_async_t>>(this->handle);
assert(deleter);
std::lock_guard<std::mutex> lock(*deleter->handleMutex);
diff --git a/Source/cmUVHandlePtr.h b/Source/cmUVHandlePtr.h
index 356e227..8c5ad59 100644
--- a/Source/cmUVHandlePtr.h
+++ b/Source/cmUVHandlePtr.h
@@ -78,7 +78,7 @@ template <typename T>
class uv_handle_ptr_base_
{
protected:
- template <typename _T>
+ template <typename U>
friend class uv_handle_ptr_base_;
/**
@@ -160,7 +160,7 @@ inline uv_handle_ptr_base_<T>& uv_handle_ptr_base_<T>::operator=(
template <typename T>
class uv_handle_ptr_ : public uv_handle_ptr_base_<T>
{
- template <typename _T>
+ template <typename U>
friend class uv_handle_ptr_;
public:
diff --git a/Source/cmVersion.h b/Source/cmVersion.h
index 9072c9f..456428c 100644
--- a/Source/cmVersion.h
+++ b/Source/cmVersion.h
@@ -24,8 +24,8 @@ public:
/* Encode with room for up to 1000 minor releases between major releases
and to encode dates until the year 10000 in the patch level. */
-#define CMake_VERSION_ENCODE__BASE KWIML_INT_UINT64_C(100000000)
+#define CMake_VERSION_ENCODE_BASE KWIML_INT_UINT64_C(100000000)
#define CMake_VERSION_ENCODE(major, minor, patch) \
- ((((major)*1000u) * CMake_VERSION_ENCODE__BASE) + \
- (((minor) % 1000u) * CMake_VERSION_ENCODE__BASE) + \
- (((patch) % CMake_VERSION_ENCODE__BASE)))
+ ((((major)*1000u) * CMake_VERSION_ENCODE_BASE) + \
+ (((minor) % 1000u) * CMake_VERSION_ENCODE_BASE) + \
+ (((patch) % CMake_VERSION_ENCODE_BASE)))
diff --git a/Source/cmWorkerPool.cxx b/Source/cmWorkerPool.cxx
index f2c091f..1d15c27 100644
--- a/Source/cmWorkerPool.cxx
+++ b/Source/cmWorkerPool.cxx
@@ -31,7 +31,6 @@ public:
/// On error the ssize_t argument is a non zero libuv error code
using EndFunction = std::function<void(ssize_t)>;
-public:
/**
* Reset to construction state
*/
@@ -65,7 +64,6 @@ private:
uv_buf_t* buf);
static void UVData(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf);
-private:
cm::uv_pipe_ptr UVPipe_;
std::vector<char> Buffer_;
DataFunction DataFunction_;
@@ -154,7 +152,6 @@ public:
bool MergedOutput = false;
};
-public:
// -- Const accessors
SetupT const& Setup() const { return this->Setup_; }
cmWorkerPool::ProcessResultT* Result() const { return this->Setup_.Result; }
@@ -170,13 +167,12 @@ public:
private:
// -- Libuv callbacks
static void UVExit(uv_process_t* handle, int64_t exitStatus, int termSignal);
- void UVPipeOutData(cmUVPipeBuffer::DataRange data);
+ void UVPipeOutData(cmUVPipeBuffer::DataRange data) const;
void UVPipeOutEnd(ssize_t error);
- void UVPipeErrData(cmUVPipeBuffer::DataRange data);
+ void UVPipeErrData(cmUVPipeBuffer::DataRange data) const;
void UVPipeErrEnd(ssize_t error);
void UVTryFinish();
-private:
// -- Setup
SetupT Setup_;
// -- Runtime
@@ -330,7 +326,7 @@ void cmUVReadOnlyProcess::UVExit(uv_process_t* handle, int64_t exitStatus,
}
}
-void cmUVReadOnlyProcess::UVPipeOutData(cmUVPipeBuffer::DataRange data)
+void cmUVReadOnlyProcess::UVPipeOutData(cmUVPipeBuffer::DataRange data) const
{
this->Result()->StdOut.append(data.begin(), data.end());
}
@@ -346,7 +342,7 @@ void cmUVReadOnlyProcess::UVPipeOutEnd(ssize_t error)
this->UVTryFinish();
}
-void cmUVReadOnlyProcess::UVPipeErrData(cmUVPipeBuffer::DataRange data)
+void cmUVReadOnlyProcess::UVPipeErrData(cmUVPipeBuffer::DataRange data) const
{
std::string* str = this->Setup_.MergedOutput ? &this->Result()->StdOut
: &this->Result()->StdErr;
@@ -407,7 +403,6 @@ private:
static void UVProcessStart(uv_async_t* handle);
void UVProcessFinished();
-private:
// -- Process management
struct
{
@@ -520,7 +515,6 @@ public:
static void UVSlotBegin(uv_async_t* handle);
static void UVSlotEnd(uv_async_t* handle);
-public:
// -- UV loop
#ifdef CMAKE_UV_SIGNAL_HACK
std::unique_ptr<cmUVSignalHackRAII> UVHackRAII;
diff --git a/Source/cmWorkerPool.h b/Source/cmWorkerPool.h
index 9082d7f..ff25526 100644
--- a/Source/cmWorkerPool.h
+++ b/Source/cmWorkerPool.h
@@ -117,7 +117,6 @@ public:
this->Process();
}
- private:
cmWorkerPool* Pool_ = nullptr;
unsigned int WorkerIndex_ = 0;
bool Fence_ = false;
@@ -154,7 +153,6 @@ public:
void Process() override { this->Pool()->Abort(); }
};
-public:
// -- Methods
cmWorkerPool();
~cmWorkerPool();
diff --git a/Source/cmXMLSafe.cxx b/Source/cmXMLSafe.cxx
index 8cd5f6e..d31a239 100644
--- a/Source/cmXMLSafe.cxx
+++ b/Source/cmXMLSafe.cxx
@@ -28,7 +28,7 @@ cmXMLSafe& cmXMLSafe::Quotes(bool b)
return *this;
}
-std::string cmXMLSafe::str()
+std::string cmXMLSafe::str() const
{
std::ostringstream ss;
ss << *this;
diff --git a/Source/cmXMLSafe.h b/Source/cmXMLSafe.h
index 9b4c539..21bd19a 100644
--- a/Source/cmXMLSafe.h
+++ b/Source/cmXMLSafe.h
@@ -24,7 +24,7 @@ public:
cmXMLSafe& Quotes(bool b = true);
/** Get the escaped data as a string. */
- std::string str();
+ std::string str() const;
private:
char const* Data;
diff --git a/Source/cmXMLWriter.h b/Source/cmXMLWriter.h
index 8a32377..6e8eeb7 100644
--- a/Source/cmXMLWriter.h
+++ b/Source/cmXMLWriter.h
@@ -75,7 +75,6 @@ private:
void CloseStartElement();
-private:
static cmXMLSafe SafeAttribute(const char* value) { return { value }; }
static cmXMLSafe SafeAttribute(std::string const& value)
@@ -121,7 +120,6 @@ private:
return value;
}
-private:
std::ostream& Output;
std::stack<std::string, std::vector<std::string>> Elements;
std::string IndentationElement;
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index f6d8901..5791c05 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -1885,7 +1885,7 @@ int cmcmd::RunPreprocessor(const std::vector<std::string>& command,
}
auto status = process.GetStatus();
if (!status[0] || status[0]->ExitStatus != 0) {
- auto errorStream = process.ErrorStream();
+ auto* errorStream = process.ErrorStream();
if (errorStream) {
std::cerr << errorStream->rdbuf();
}
@@ -2013,7 +2013,7 @@ int cmcmd::RunLLVMRC(std::vector<std::string> const& args)
}
auto status = process.GetStatus();
if (!status[0] || status[0]->ExitStatus != 0) {
- auto errorStream = process.ErrorStream();
+ auto* errorStream = process.ErrorStream();
if (errorStream) {
std::cerr << errorStream->rdbuf();
}
diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx
index 0fd6cfb..0ebe00e 100644
--- a/Tests/CMakeLib/run_compile_commands.cxx
+++ b/Tests/CMakeLib/run_compile_commands.cxx
@@ -127,7 +127,7 @@ private:
exit(1);
}
- bool IsWhitespace()
+ bool IsWhitespace() const
{
return (this->C == ' ' || this->C == '\t' || this->C == '\n' ||
this->C == '\r');