Commit 9b96fbc3 authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic 'clang-tidy-fixes'

ef935b17 clang-tidy: fix `readability-use-anyofallof` warnings
9ac8dbbb clang-tidy: fix `readability-simplify-boolean-expr` warnings
ca505718 clang-tidy: fix `readability-redundant-string-init` warnings
b3b6ede6 clang-tidy: fix `readability-redundant-access-specifiers` warnings
cdfc4e31 clang-tidy: fix `readability-qualified-auto` warnings
808b17b1 clang-tidy: fix `readability-make-member-function-const` warnings
4470eb51 clang-tidy: fix `performance-trivially-destructible` warnings
4f396e65

 clang-tidy: fix `performance-no-automatic-move` warnings
...
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !5731
parents a0e44fc1 ef935b17
......@@ -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:
......
......@@ -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;
......
......@@ -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) \
......
......@@ -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");
......
......@@ -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;
......
......@@ -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;
......
......@@ -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");
......
......@@ -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.
......
......@@ -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");
......
......@@ -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&);
......
......@@ -300,7 +300,7 @@ void cmCTestMemCheckHandler::PopulateCustomVectors(cmMakefile* mf)
this->CustomTestsIgnore);
}
int cmCTestMemCheckHandler::GetDefectCount()
int cmCTestMemCheckHandler::GetDefectCount() const
{
return this->DefectCount;
}
......
......@@ -29,7 +29,7 @@ public:
void Initialize() override;
int GetDefectCount();
int GetDefectCount() const;
protected:
int PreProcessHandler() override;
......
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
......@@ -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)
......
......@@ -67,8 +67,8 @@ public:
Other
};
Exception GetExitException();
std::string GetExitExceptionString();
Exception GetExitException() const;
std::string GetExitExceptionString() const;
std::unique_ptr<cmCTestRunTest> GetRunner()
{
......
......@@ -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;
......
......@@ -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
......
......@@ -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)
{
......
......@@ -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
......
......@@ -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;
......
......@@ -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
......
......@@ -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;
}
......
......@@ -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();
}
......
......@@ -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);
}
}
......
......@@ -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);
......
......@@ -951,6 +951,9 @@ void cmComputeLinkInformation::AddLinkExtension(std::string const& e,