diff --git a/.clang-tidy b/.clang-tidy index 6d2edd4f72..68d0a8f9de 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -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,\ diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 84ea32b84d..978c16b307 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -501,7 +501,7 @@ void cmCTestMultiProcessHandler::UnlockResources(int index) inline size_t cmCTestMultiProcessHandler::GetProcessorsUsed(int test) { - size_t processors = static_cast(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. diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx index e67e0c29e2..94dfa3e213 100644 --- a/Source/QtDialog/QCMakeCacheView.cxx +++ b/Source/QtDialog/QCMakeCacheView.cxx @@ -189,7 +189,7 @@ QCMakeCacheModel::~QCMakeCacheModel() = default; static uint qHash(const QCMakeProperty& p) { - return static_cast(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(newProps.size()); + this->NewPropertyCount = newProps.size(); if (View == FlatView) { QCMakePropertyList newP = newProps.values(); diff --git a/Source/QtDialog/QCMakePresetItemModel.cxx b/Source/QtDialog/QCMakePresetItemModel.cxx index 31a60008ce..cb96b6bbec 100644 --- a/Source/QtDialog/QCMakePresetItemModel.cxx +++ b/Source/QtDialog/QCMakePresetItemModel.cxx @@ -83,7 +83,7 @@ int QCMakePresetItemModel::rowCount(const QModelIndex& parent) const if (this->m_presets.empty()) { return 1; } - return static_cast(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(this->m_presets.size() + 1); + return this->m_presets.size() + 1; } diff --git a/Source/cmCMakePath.h b/Source/cmCMakePath.h index fd71c1fb57..52fd6aa0a7 100644 --- a/Source/cmCMakePath.h +++ b/Source/cmCMakePath.h @@ -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; diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 2e6cd408d8..6f101cb59c 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -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(arg); - return static_cast(mf->GetState()->GetCommand(name) ? 1 : 0); + return mf->GetState()->GetCommand(name) ? 1 : 0; } static void CCONV cmAddDefineFlag(void* arg, const char* definition) diff --git a/Source/cmDebuggerAdapter.cxx b/Source/cmDebuggerAdapter.cxx index c2e0d4f11b..0eacd0c121 100644 --- a/Source/cmDebuggerAdapter.cxx +++ b/Source/cmDebuggerAdapter.cxx @@ -70,7 +70,7 @@ public: { } - inline void Notify() + void Notify() { std::unique_lock lock(Mutex); Count++; @@ -78,7 +78,7 @@ public: Cv.notify_one(); } - inline void Wait() + void Wait() { std::unique_lock lock(Mutex); while (Count == 0) { diff --git a/Source/cmDebuggerVariables.h b/Source/cmDebuggerVariables.h index 753b811115..0c4a416d0f 100644 --- a/Source/cmDebuggerVariables.h +++ b/Source/cmDebuggerVariables.h @@ -102,22 +102,16 @@ public: std::shared_ptr variablesManager, std::string name, bool supportsVariableType, std::function()> 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 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(); }; diff --git a/Source/cmDocumentationEntry.h b/Source/cmDocumentationEntry.h index d9718361ec..2a26ecdfa6 100644 --- a/Source/cmDocumentationEntry.h +++ b/Source/cmDocumentationEntry.h @@ -17,7 +17,7 @@ struct cmDocumentationEntry } #endif - std::string Name = {}; - std::string Brief = {}; + std::string Name; + std::string Brief; char CustomNamePrefix = ' '; }; diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index 003f47b439..99d0ba4609 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -509,7 +509,7 @@ unsigned long cmELFInternalImpl::GetDynamicEntryPosition(int j) return 0; } ELF_Shdr const& sec = this->SectionHeaders[this->DynamicSectionIndex]; - return static_cast(sec.sh_offset + sec.sh_entsize * j); + return sec.sh_offset + sec.sh_entsize * static_cast(j); } template diff --git a/Source/cmFileCopier.cxx b/Source/cmFileCopier.cxx index 686162b26c..47d3d518b9 100644 --- a/Source/cmFileCopier.cxx +++ b/Source/cmFileCopier.cxx @@ -713,7 +713,7 @@ bool cmFileCopier::InstallDirectory(const std::string& source, if (!source.empty()) { dir.Load(source); } - unsigned long numFiles = static_cast(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)) { diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index 81e081c802..2abf341ffd 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -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"))) { diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index cc150fda03..7535ffc633 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -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 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{} { } diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index 134930804f..8d21aa8117 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -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] == '<'; } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index fb92771b03..6bf49a62fa 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -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); diff --git a/Source/cmLinkItem.cxx b/Source/cmLinkItem.cxx index 3654176ceb..6744bbbf67 100644 --- a/Source/cmLinkItem.cxx +++ b/Source/cmLinkItem.cxx @@ -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) diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index 4e356b7ab0..70efb16abd 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -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; }; diff --git a/Source/cmList.h b/Source/cmList.h index e1070960bc..7771a0ee26 100644 --- a/Source/cmList.h +++ b/Source/cmList.h @@ -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; } diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 1fd406c50b..720cfa2b03 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -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 = "$CrossConfig ? configGenexWithCommandConfig : configGenex; auto genexEnd = diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 5ad0439c9e..bd91784754 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -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 diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index f220837408..b390326f4b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -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 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 Policy; diff --git a/Source/cmUVHandlePtr.h b/Source/cmUVHandlePtr.h index b8b3491977..ef88ef14b8 100644 --- a/Source/cmUVHandlePtr.h +++ b/Source/cmUVHandlePtr.h @@ -158,10 +158,10 @@ public: }; template -inline uv_handle_ptr_base_::uv_handle_ptr_base_( +uv_handle_ptr_base_::uv_handle_ptr_base_( uv_handle_ptr_base_&&) noexcept = default; template -inline uv_handle_ptr_base_& uv_handle_ptr_base_::operator=( +uv_handle_ptr_base_& uv_handle_ptr_base_::operator=( uv_handle_ptr_base_&&) noexcept = default; /**