clang-tidy: fix readability-redundant-* warnings

This commit is contained in:
Daniel Pfeifer
2024-10-10 00:51:03 +02:00
parent 8bb0281896
commit 58c5f77837
22 changed files with 50 additions and 72 deletions
-9
View File
@@ -7,7 +7,6 @@ bugprone-*,\
-bugprone-implicit-widening-of-multiplication-result,\
-bugprone-inc-dec-in-conditions,\
-bugprone-macro-parentheses,\
-bugprone-misplaced-widening-cast,\
-bugprone-multi-level-implicit-pointer-conversion,\
-bugprone-narrowing-conversions,\
-bugprone-switch-missing-default-case,\
@@ -36,11 +35,8 @@ modernize-*,\
performance-*,\
-performance-avoid-endl,\
-performance-enum-size,\
-performance-inefficient-vector-operation,\
-performance-noexcept-swap,\
readability-*,\
-readability-avoid-nested-conditional-operator,\
-readability-avoid-return-with-void-value,\
-readability-avoid-unconditional-preprocessor-if,\
-readability-convert-member-functions-to-static,\
-readability-function-cognitive-complexity,\
@@ -52,11 +48,6 @@ readability-*,\
-readability-magic-numbers,\
-readability-make-member-function-const,\
-readability-named-parameter,\
-readability-redundant-casting,\
-readability-redundant-declaration,\
-readability-redundant-inline-specifier,\
-readability-redundant-member-init,\
-readability-reference-to-constructed-temporary,\
-readability-simplify-boolean-expr,\
-readability-static-accessed-through-instance,\
-readability-suspicious-call-argument,\
+1 -1
View File
@@ -501,7 +501,7 @@ void cmCTestMultiProcessHandler::UnlockResources(int index)
inline size_t cmCTestMultiProcessHandler::GetProcessorsUsed(int test)
{
size_t processors = static_cast<int>(this->Properties[test]->Processors);
size_t processors = this->Properties[test]->Processors;
size_t const parallelLevel = this->GetParallelLevel();
// If processors setting is set higher than the -j
// setting, we default to using all of the process slots.
+2 -2
View File
@@ -189,7 +189,7 @@ QCMakeCacheModel::~QCMakeCacheModel() = default;
static uint qHash(const QCMakeProperty& p)
{
return static_cast<uint>(qHash(p.Key));
return qHash(p.Key);
}
void QCMakeCacheModel::setShowNewProperties(bool f)
@@ -242,7 +242,7 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props)
bool b = this->blockSignals(true);
this->clear();
this->NewPropertyCount = static_cast<int>(newProps.size());
this->NewPropertyCount = newProps.size();
if (View == FlatView) {
QCMakePropertyList newP = newProps.values();
+2 -2
View File
@@ -83,7 +83,7 @@ int QCMakePresetItemModel::rowCount(const QModelIndex& parent) const
if (this->m_presets.empty()) {
return 1;
}
return static_cast<int>(this->m_presets.size() + 2);
return this->m_presets.size() + 2;
}
int QCMakePresetItemModel::columnCount(const QModelIndex& parent) const
@@ -144,5 +144,5 @@ int QCMakePresetItemModel::presetNameToRow(const QString& name) const
index++;
}
return static_cast<int>(this->m_presets.size() + 1);
return this->m_presets.size() + 1;
}
+5 -6
View File
@@ -617,19 +617,18 @@ public:
// Non-members
// ===========
friend inline bool operator==(const cmCMakePath& lhs,
const cmCMakePath& rhs) noexcept
friend bool operator==(const cmCMakePath& lhs,
const cmCMakePath& rhs) noexcept
{
return lhs.Compare(rhs) == 0;
}
friend inline bool operator!=(const cmCMakePath& lhs,
const cmCMakePath& rhs) noexcept
friend bool operator!=(const cmCMakePath& lhs,
const cmCMakePath& rhs) noexcept
{
return lhs.Compare(rhs) != 0;
}
friend inline cmCMakePath operator/(const cmCMakePath& lhs,
const cmCMakePath& rhs)
friend cmCMakePath operator/(const cmCMakePath& lhs, const cmCMakePath& rhs)
{
cmCMakePath result(lhs);
result /= rhs;
+1 -1
View File
@@ -168,7 +168,7 @@ static int CCONV cmIsOn(void* arg, const char* name)
static int CCONV cmCommandExists(void* arg, const char* name)
{
cmMakefile* mf = static_cast<cmMakefile*>(arg);
return static_cast<int>(mf->GetState()->GetCommand(name) ? 1 : 0);
return mf->GetState()->GetCommand(name) ? 1 : 0;
}
static void CCONV cmAddDefineFlag(void* arg, const char* definition)
+2 -2
View File
@@ -70,7 +70,7 @@ public:
{
}
inline void Notify()
void Notify()
{
std::unique_lock<std::mutex> lock(Mutex);
Count++;
@@ -78,7 +78,7 @@ public:
Cv.notify_one();
}
inline void Wait()
void Wait()
{
std::unique_lock<std::mutex> lock(Mutex);
while (Count == 0) {
+6 -12
View File
@@ -102,22 +102,16 @@ public:
std::shared_ptr<cmDebuggerVariablesManager> variablesManager,
std::string name, bool supportsVariableType,
std::function<std::vector<cmDebuggerVariableEntry>()> getKeyValuesFunc);
inline int64_t GetId() const noexcept { return this->Id; }
inline std::string GetName() const noexcept { return this->Name; }
inline std::string GetValue() const noexcept { return this->Value; }
inline void SetValue(std::string const& value) noexcept
{
this->Value = value;
}
int64_t GetId() const noexcept { return this->Id; }
std::string GetName() const noexcept { return this->Name; }
std::string GetValue() const noexcept { return this->Value; }
void SetValue(std::string const& value) noexcept { this->Value = value; }
void AddSubVariables(std::shared_ptr<cmDebuggerVariables> const& variables);
inline void SetIgnoreEmptyStringEntries(bool value) noexcept
void SetIgnoreEmptyStringEntries(bool value) noexcept
{
this->IgnoreEmptyStringEntries = value;
}
inline void SetEnableSorting(bool value) noexcept
{
this->EnableSorting = value;
}
void SetEnableSorting(bool value) noexcept { this->EnableSorting = value; }
virtual ~cmDebuggerVariables();
};
+2 -2
View File
@@ -17,7 +17,7 @@ struct cmDocumentationEntry
}
#endif
std::string Name = {};
std::string Brief = {};
std::string Name;
std::string Brief;
char CustomNamePrefix = ' ';
};
+1 -1
View File
@@ -509,7 +509,7 @@ unsigned long cmELFInternalImpl<Types>::GetDynamicEntryPosition(int j)
return 0;
}
ELF_Shdr const& sec = this->SectionHeaders[this->DynamicSectionIndex];
return static_cast<unsigned long>(sec.sh_offset + sec.sh_entsize * j);
return sec.sh_offset + sec.sh_entsize * static_cast<unsigned long>(j);
}
template <class Types>
+1 -1
View File
@@ -713,7 +713,7 @@ bool cmFileCopier::InstallDirectory(const std::string& source,
if (!source.empty()) {
dir.Load(source);
}
unsigned long numFiles = static_cast<unsigned long>(dir.GetNumberOfFiles());
unsigned long numFiles = dir.GetNumberOfFiles();
for (unsigned long fileNum = 0; fileNum < numFiles; ++fileNum) {
if (!(strcmp(dir.GetFile(fileNum), ".") == 0 ||
strcmp(dir.GetFile(fileNum), "..") == 0)) {
-1
View File
@@ -338,7 +338,6 @@ namespace {
struct entry_to_remove
{
entry_to_remove(std::string const& name, cmMakefile* makefile)
: value()
{
if (cmValue to_skip = makefile->GetDefinition(
cmStrCat("_CMAKE_SYSTEM_PREFIX_PATH_", name, "_PREFIX_COUNT"))) {
+1 -5
View File
@@ -164,8 +164,7 @@ class cmCaseInsensitiveDirectoryListGenerator
{
public:
cmCaseInsensitiveDirectoryListGenerator(cm::string_view name)
: DirectoryLister{}
, DirName{ name }
: DirName{ name }
{
}
@@ -209,7 +208,6 @@ class cmDirectoryListGenerator
public:
cmDirectoryListGenerator(std::vector<std::string> const& names)
: Names{ names }
, Matches{}
, Current{ this->Matches.cbegin() }
{
}
@@ -332,8 +330,6 @@ class cmFileListGeneratorGlob
public:
cmFileListGeneratorGlob(cm::string_view pattern)
: Pattern(pattern)
, Files{}
, Current{}
{
}
+2 -2
View File
@@ -72,11 +72,11 @@ public:
static std::string StripEmptyListElements(const std::string& input);
static inline bool StartsWithGeneratorExpression(const std::string& input)
static bool StartsWithGeneratorExpression(const std::string& input)
{
return input.length() >= 2 && input[0] == '$' && input[1] == '<';
}
static inline bool StartsWithGeneratorExpression(const char* input)
static bool StartsWithGeneratorExpression(const char* input)
{
return input && input[0] == '$' && input[1] == '<';
}
+5 -4
View File
@@ -2516,8 +2516,8 @@ void cmGeneratorTarget::AddCUDAArchitectureFlags(cmBuildStep compileOrLink,
return;
}
return this->AddCUDAArchitectureFlagsImpl(compileOrLink, config, "CUDA",
std::move(arch), flags);
this->AddCUDAArchitectureFlagsImpl(compileOrLink, config, "CUDA",
std::move(arch), flags);
}
void cmGeneratorTarget::AddCUDAArchitectureFlagsImpl(cmBuildStep compileOrLink,
@@ -2695,8 +2695,9 @@ void cmGeneratorTarget::AddHIPArchitectureFlags(cmBuildStep compileOrLink,
}
if (this->Makefile->GetSafeDefinition("CMAKE_HIP_PLATFORM") == "nvidia") {
return this->AddCUDAArchitectureFlagsImpl(compileOrLink, config, "HIP",
std::move(arch), flags);
this->AddCUDAArchitectureFlagsImpl(compileOrLink, config, "HIP",
std::move(arch), flags);
return;
}
cmList options(arch);
-7
View File
@@ -13,8 +13,6 @@
const std::string cmLinkItem::DEFAULT = "DEFAULT";
cmLinkItem::cmLinkItem() = default;
cmLinkItem::cmLinkItem(std::string n, bool c, cmListFileBacktrace bt,
std::string feature)
: String(std::move(n))
@@ -73,11 +71,6 @@ std::ostream& operator<<(std::ostream& os, cmLinkItem const& item)
return os << item.AsStr();
}
cmLinkImplItem::cmLinkImplItem()
: cmLinkItem()
{
}
cmLinkImplItem::cmLinkImplItem(cmLinkItem item, bool checkCMP0027)
: cmLinkItem(std::move(item))
, CheckCMP0027(checkCMP0027)
+2 -2
View File
@@ -29,7 +29,7 @@ public:
// default feature: link library without decoration
static const std::string DEFAULT;
cmLinkItem();
cmLinkItem() = default;
cmLinkItem(std::string s, bool c, cmListFileBacktrace bt,
std::string feature = DEFAULT);
cmLinkItem(cmGeneratorTarget const* t, bool c, cmListFileBacktrace bt,
@@ -50,7 +50,7 @@ public:
class cmLinkImplItem : public cmLinkItem
{
public:
cmLinkImplItem();
cmLinkImplItem() = default;
cmLinkImplItem(cmLinkItem item, bool checkCMP0027);
bool CheckCMP0027 = false;
};
+2 -2
View File
@@ -1135,11 +1135,11 @@ public:
// Non-members
// ===========
friend inline bool operator==(const cmList& lhs, const cmList& rhs) noexcept
friend bool operator==(const cmList& lhs, const cmList& rhs) noexcept
{
return lhs.Values == rhs.Values;
}
friend inline bool operator!=(const cmList& lhs, const cmList& rhs) noexcept
friend bool operator!=(const cmList& lhs, const cmList& rhs) noexcept
{
return lhs.Values != rhs.Values;
}
+4 -4
View File
@@ -360,11 +360,11 @@ void cmQtAutoGenInitializer::AddAutogenExecutableToDependencies(
if (genVars.ExecutableTarget) {
dependencies.push_back(genVars.ExecutableTarget->Target->GetName());
} else if (this->MultiConfig && this->UseBetterGraph) {
cm::string_view const& configGenexWithCommandConfig =
cm::string_view const configGenexWithCommandConfig =
"$<COMMAND_CONFIG:$<$<CONFIG:";
cm::string_view const& configGenex = "$<$<CONFIG:";
cm::string_view const& configGenexEnd = ">";
cm::string_view const& configGenexEndWithCommandConfig = ">>";
cm::string_view const configGenex = "$<$<CONFIG:";
cm::string_view const configGenexEnd = ">";
cm::string_view const configGenexEndWithCommandConfig = ">>";
auto genexBegin =
this->CrossConfig ? configGenexWithCommandConfig : configGenex;
auto genexEnd =
+1 -1
View File
@@ -133,7 +133,7 @@ cmSystemTools::OutputCallback s_StdoutCallback;
# if defined(_WIN32)
extern __declspec(dllimport) char** environ;
# else
extern char** environ;
extern char** environ; // NOLINT(readability-redundant-declaration)
# endif
#endif
+8 -3
View File
@@ -250,7 +250,7 @@ struct UsageRequirementProperty
void CopyFromEntries(cmBTStringRange entries)
{
return cm::append(this->Entries, entries);
cm::append(this->Entries, entries);
}
enum class Action
@@ -354,6 +354,8 @@ struct TargetProperty
}
cm::static_string_view const Name;
// Explicit initialization is needed for AppleClang in Xcode 8 and below
// NOLINTNEXTLINE(readability-redundant-member-init)
cm::optional<cm::static_string_view> const Default = {};
InitCondition const InitConditional = InitCondition::Always;
Repetition const Repeat = Repetition::Once;
@@ -2047,10 +2049,13 @@ struct ReadOnlyProperty
{
ReadOnlyProperty(ReadOnlyCondition cond)
: Condition{ cond }
, Policy{} {};
{
}
ReadOnlyProperty(ReadOnlyCondition cond, cmPolicies::PolicyID id)
: Condition{ cond }
, Policy{ id } {};
, Policy{ id }
{
}
ReadOnlyCondition Condition;
cm::optional<cmPolicies::PolicyID> Policy;
+2 -2
View File
@@ -158,10 +158,10 @@ public:
};
template <typename T>
inline uv_handle_ptr_base_<T>::uv_handle_ptr_base_(
uv_handle_ptr_base_<T>::uv_handle_ptr_base_(
uv_handle_ptr_base_<T>&&) noexcept = default;
template <typename T>
inline uv_handle_ptr_base_<T>& uv_handle_ptr_base_<T>::operator=(
uv_handle_ptr_base_<T>& uv_handle_ptr_base_<T>::operator=(
uv_handle_ptr_base_<T>&&) noexcept = default;
/**