Fix clang-tidy warnings

This commit is contained in:
IRBorisov 2024-05-06 18:13:24 +03:00
parent de81d4037f
commit 97614cc3bf
24 changed files with 108 additions and 91 deletions

View File

@ -1,40 +1,44 @@
Checks: "*,\ Checks: "*,\
-altera-id-dependent-backward-branch,\
-altera-struct-pack-align,\ -altera-struct-pack-align,\
-altera-unroll-loops,\ -altera-unroll-loops,\
-altera-id-dependent-backward-branch,\ -bugprone-branch-clone,\
-llvmlibc-callee-namespace,\ -bugprone-easily-swappable-parameters,\
-llvmlibc-restrict-system-libc-headers,\ -bugprone-suspicious-include,\
-llvmlibc-implementation-in-namespace,\ -bugprone-exception-escape,\
-llvmlibc-inline-function-decl,\ -cppcoreguidelines-avoid-const-or-ref-data-members,\
-cppcoreguidelines-avoid-do-while,\
-cppcoreguidelines-non-private-member-variables-in-classes,\
-cppcoreguidelines-prefer-member-initializer,\
-cppcoreguidelines-special-member-functions,\
-fuchsia-default-arguments,\
-fuchsia-default-arguments-calls,\
-fuchsia-default-arguments-declarations,\
-fuchsia-multiple-inheritance,\
-fuchsia-overloaded-operator,\
-fuchsia-statically-constructed-objects,\
-fuchsia-trailing-return,\
-google-global-names-in-headers,\
-google-readability-todo,\
-google-runtime-references,\
-hicpp-special-member-functions,\
-llvm-else-after-return,\ -llvm-else-after-return,\
-llvm-header-guard,\ -llvm-header-guard,\
-llvm-include-order,\ -llvm-include-order,\
-bugprone-branch-clone,\ -llvmlibc-callee-namespace,\
-bugprone-suspicious-include,\ -llvmlibc-implementation-in-namespace,\
-bugprone-easily-swappable-parameters,\ -llvmlibc-inline-function-decl,\
-llvmlibc-restrict-system-libc-headers,\
-misc-include-cleaner,\
-misc-no-recursion,\
-misc-non-private-member-variables-in-classes,\
-modernize-use-trailing-return-type,\ -modernize-use-trailing-return-type,\
-hicpp-special-member-functions,\
-google-runtime-references,\
-fuchsia-overloaded-operator,\
-fuchsia-default-arguments,\
-google-readability-todo,\
-google-global-names-in-headers,\
-readability-redundant-access-specifiers,\
-readability-redundant-member-init,\
-readability-else-after-return,\
-readability-implicit-bool-conversion,\
-readability-use-anyofallof,\
-readability-identifier-length,\
-performance-inefficient-string-concatenation,\ -performance-inefficient-string-concatenation,\
-performance-unnecessary-value-param,\ -performance-unnecessary-value-param,\
-fuchsia-default-arguments-declarations,\ -readability-else-after-return,\
-fuchsia-trailing-return,\ -readability-function-cognitive-complexity,\
-fuchsia-multiple-inheritance,\ -readability-identifier-length,\
-fuchsia-default-arguments-calls,\ -readability-implicit-bool-conversion,\
-misc-non-private-member-variables-in-classes,\ -readability-redundant-access-specifiers,\
-misc-no-recursion,\ -readability-redundant-member-init,\
-misc-include-cleaner,\ -readability-use-anyofallof"
-cppcoreguidelines-special-member-functions,\
-cppcoreguidelines-prefer-member-initializer,\
-cppcoreguidelines-avoid-const-or-ref-data-members,\
-cppcoreguidelines-non-private-member-variables-in-classes"

View File

@ -28,12 +28,12 @@
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion> <VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{7E1D5338-F819-4C96-B461-9EAAB8D02E1D}</ProjectGuid> <ProjectGuid>{7E1D5338-F819-4C96-B461-9EAAB8D02E1D}</ProjectGuid>
<ConfigurationType>StaticLibrary</ConfigurationType> <ConfigurationType>StaticLibrary</ConfigurationType>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<RootNamespace>cclGraph</RootNamespace> <RootNamespace>cclGraph</RootNamespace>
<PlatformToolset>v143</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@ -120,7 +120,7 @@ xcopy /y /s /q /i ..\cclCommons\include ..\..\output\include</Command>
<AdditionalIncludeDirectories>include</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>include</AdditionalIncludeDirectories>
<ProgramDataBaseFileName>$(IntDir)$(ProjectName)d.pdb</ProgramDataBaseFileName> <ProgramDataBaseFileName>$(IntDir)$(ProjectName)d.pdb</ProgramDataBaseFileName>
<ObjectFileName>$(IntDir)obj\</ObjectFileName> <ObjectFileName>$(IntDir)obj\</ObjectFileName>
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion> <InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>

View File

@ -1,9 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<None Include="VSCustom.ruleset" />
<None Include="Jenkinsfile.groovy" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Filter Include="Graph"> <Filter Include="Graph">
<UniqueIdentifier>{f0a3dd37-e5ae-4a37-ab65-d574c8dfe252}</UniqueIdentifier> <UniqueIdentifier>{f0a3dd37-e5ae-4a37-ab65-d574c8dfe252}</UniqueIdentifier>
@ -20,7 +16,4 @@
<Filter>Graph</Filter> <Filter>Graph</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
</Project> </Project>

View File

@ -298,7 +298,7 @@ CGraph::ItemsGroup CGraph::GetAllLoopsItems() const {
} }
} }
if (size(component) != 1 || HasEdge(index, index)) { if (size(component) != 1 || HasEdge(index, index)) {
result.push_back({}); result.emplace_back();
result.back().reserve(size(component)); result.back().reserve(size(component));
for (const auto item : component) { for (const auto item : component) {
result.back().emplace(graph[item].uid); result.back().emplace(graph[item].uid);

View File

@ -64,7 +64,8 @@ namespace {
[[nodiscard]] UTF8Iterator ReferenceStart(const std::string_view refStr, const StrPos start) noexcept { [[nodiscard]] UTF8Iterator ReferenceStart(const std::string_view refStr, const StrPos start) noexcept {
for (auto iter = UTF8Iterator(refStr, start); iter != UTF8End(refStr); ++iter) { for (auto iter = UTF8Iterator(refStr, start); iter != UTF8End(refStr); ++iter) {
if (*iter == '@') { if (*iter == '@') {
if (++iter == UTF8End(refStr) || *iter == '{') { ++iter;
if (iter == UTF8End(refStr) || *iter == '{') {
return iter; return iter;
} }
} }

View File

@ -160,7 +160,7 @@ std::string RefsManager::OutputRefs(const std::string& normStr, const StrRange s
auto finish = subRange.finish; auto finish = subRange.finish;
for (const auto& ref : refs) { for (const auto& ref : refs) {
const auto intersection = subRange.Intersect(ref.position); const auto intersection = subRange.Intersect(ref.position);
if (!intersection.has_value() || intersection->length() == 0) { if (!intersection.has_value() || intersection->empty()) {
if (subRange.IsBefore(ref.position)) { if (subRange.IsBefore(ref.position)) {
break; break;
} }

View File

@ -16,10 +16,19 @@ struct RSConcept {
std::string definition{}; std::string definition{};
std::string convention{}; std::string convention{};
explicit RSConcept(const EntityUID entity, std::string alias, const CstType type = CstType::base, explicit RSConcept(
std::string definition = {}, std::string convention = {}) noexcept const EntityUID entity,
: uid{ entity }, alias{ std::move(alias) }, type{ type }, std::string alias,
definition{ std::move(definition) }, convention{ std::move(convention) } {} const CstType type = CstType::base,
std::string definition = {},
std::string convention = {}
) noexcept :
uid{ entity },
alias{ std::move(alias) },
type{ type },
definition{ std::move(definition) },
convention{ std::move(convention) }
{}
RSConcept() = default; RSConcept() = default;

View File

@ -81,7 +81,7 @@ public:
[[nodiscard]] change::Hash FullHash() const; [[nodiscard]] change::Hash FullHash() const;
private: private:
[[nodiscard]] inline bool NotifyAndReturn(const bool result) { [[nodiscard]] bool NotifyAndReturn(const bool result) {
if (result) { if (result) {
NotifyModification(); NotifyModification();
} }

View File

@ -71,7 +71,7 @@ public:
void UpdateState(); void UpdateState();
private: private:
[[nodiscard]] inline bool NotifyAndReturn(const bool result) { [[nodiscard]] bool NotifyAndReturn(const bool result) {
if (result) { if (result) {
NotifyModification(); NotifyModification();
} }

View File

@ -17,17 +17,20 @@ bool EquationOptions::IsEqualTo(const Options& opt2) const {
bool EquationOptions::SwapKeyVal(const EntityUID key) { bool EquationOptions::SwapKeyVal(const EntityUID key) {
if (!ContainsKey(key)) { if (!ContainsKey(key)) {
return false; return false;
} else if (const auto val = translation(key); ContainsKey(translation(key))) {
return false;
} else {
Equation props = properties[key];
if (props.mode != Equation::Mode::createNew) {
props.mode = props.mode == Equation::Mode::keepHier ? Equation::Mode::keepDel : Equation::Mode::keepHier;
}
Erase(key);
Insert(val, key, props);
return true;
} }
const auto newKey = translation(key);
if (ContainsKey(newKey)) {
return false;
}
Equation props = properties[key];
if (props.mode != Equation::Mode::createNew) {
props.mode = props.mode == Equation::Mode::keepHier ? Equation::Mode::keepDel : Equation::Mode::keepHier;
}
Erase(key);
const auto newValue = key;
Insert(newKey, newValue, props);
return true;
} }
const Equation& EquationOptions::PropsFor(const EntityUID key) const { const Equation& EquationOptions::PropsFor(const EntityUID key) const {

View File

@ -126,8 +126,12 @@ void OSSchema::SetPictLink(const PictID target, const MediaLink& lnk) {
} }
} }
const Pict& OSSchema::LoadPict(Pict&& pict, GridPosition pos, const src::Handle& handle, // NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
std::unique_ptr<OperationHandle> params) { const Pict& OSSchema::LoadPict(
Pict&& pict, GridPosition pos,
const src::Handle& handle,
std::unique_ptr<OperationHandle> params
) {
if (Grid()(pos).has_value()) { if (Grid()(pos).has_value()) {
pos = Grid().ClosestFreePos(pos); pos = Grid().ClosestFreePos(pos);
} }
@ -149,10 +153,12 @@ PictPtr OSSchema::InsertOperation(const PictID operand1, const PictID operand2)
graph->AddItem(newID, { operand1, operand2 }); graph->AddItem(newID, { operand1, operand2 });
const auto newPos = Grid().ChildPosFor(operand1, operand2); const auto newPos = Grid().ChildPosFor(operand1, operand2);
InsertInternal(Pict{ newID }, InsertInternal(
newPos, Pict{ newID },
src::Handle{ src::SrcType::rsDoc }, newPos,
std::make_unique<OperationHandle>()); src::Handle{ src::SrcType::rsDoc },
std::make_unique<OperationHandle>()
);
NotifyModification(); NotifyModification();
return &storage.at(newID); return &storage.at(newID);
@ -168,9 +174,12 @@ PictPtr OSSchema::InsertBase() {
return &storage.at(newID); return &storage.at(newID);
} }
void OSSchema::InsertInternal(const Pict& pict, GridPosition pos, void OSSchema::InsertInternal(
const src::Handle& srcHandle, const Pict& pict,
std::unique_ptr<OperationHandle> opHandle) { GridPosition pos,
const src::Handle& srcHandle,
std::unique_ptr<OperationHandle> opHandle
) {
const auto pid = pict.uid; const auto pid = pict.uid;
idGen.AddUID(pid); idGen.AddUID(pid);

View File

@ -119,7 +119,7 @@ std::optional<size_t> ossGraphFacet::FindItemIndex(const PictID item) const {
} }
size_t ossGraphFacet::InsertKeyValue(const PictID item) { size_t ossGraphFacet::InsertKeyValue(const PictID item) {
graph.emplace_back(std::vector<size_t>{}); graph.emplace_back();
items.emplace_back(item); items.emplace_back(item);
return size(items) - 1U; return size(items) - 1U;
} }

View File

@ -216,9 +216,12 @@ ops::Result ossOperationsFacet::CreateNewResult(const PictID pid) {
return opResult; return opResult;
} }
bool ossOperationsFacet::SaveOperationResult(const PictID pid, // NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
const EntityTranslation& old2New, bool ossOperationsFacet::SaveOperationResult(
ops::Result&& opResult) { const PictID pid,
const EntityTranslation& old2New,
ops::Result&& opResult
) {
auto& opHandle = operations.at(pid); auto& opHandle = operations.at(pid);
assert(opHandle != nullptr); assert(opHandle != nullptr);
const auto guard = core.DndGuard(); const auto guard = core.DndGuard();

View File

@ -87,6 +87,7 @@ EntityUID RSCore::Emplace(const CstType type, const std::string& definition) {
return newID.uid; return newID.uid;
} }
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
EntityUID RSCore::Insert(ConceptRecord&& cst) { EntityUID RSCore::Insert(ConceptRecord&& cst) {
RSConcept newRS{cst.uid, cst.alias, cst.type, std::move(cst.rs), std::move(cst.convention) }; RSConcept newRS{cst.uid, cst.alias, cst.type, std::move(cst.rs), std::move(cst.convention) };
TextConcept newText{cst.uid, cst.alias, std::move(cst.term), std::move(cst.definition) }; TextConcept newText{cst.uid, cst.alias, std::move(cst.term), std::move(cst.definition) };
@ -213,6 +214,7 @@ VectorOfEntities RSCore::InsertCopy(const std::vector<ConceptRecord>& input) {
return result; return result;
} }
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
EntityUID RSCore::Load(ConceptRecord&& cst) { EntityUID RSCore::Load(ConceptRecord&& cst) {
RSConcept newRS{ cst.uid, cst.alias, cst.type, std::move(cst.rs), std::move(cst.convention) }; RSConcept newRS{ cst.uid, cst.alias, cst.type, std::move(cst.rs), std::move(cst.convention) };
TextConcept newText{ cst.uid, cst.alias, std::move(cst.term), std::move(cst.definition) }; TextConcept newText{ cst.uid, cst.alias, std::move(cst.term), std::move(cst.definition) };

View File

@ -172,7 +172,8 @@ void rsValuesFacet::PruneStructure(const EntityUID target) {
} }
const auto& typeValue = core.GetParse(target).exprType; const auto& typeValue = core.GetParse(target).exprType;
assert(typeValue.has_value()); assert(typeValue.has_value());
const auto& type = std::get<rslang::Typification>(typeValue.value()); // NOLINT(bugprone-exception-escape) // NOLINTNEXTLINE(bugprone-exception-escape, bugprone-unchecked-optional-access)
const auto& type = std::get<rslang::Typification>(typeValue.value());
if (!oldData->IsCollection()) { if (!oldData->IsCollection()) {
if (!CheckBasicElements(oldData.value(), type)) { if (!CheckBasicElements(oldData.value(), type)) {
storage->Erase(target); storage->Erase(target);

View File

@ -46,7 +46,7 @@
<ClCompile Include="unity\reflex_unity2.cpp" /> <ClCompile Include="unity\reflex_unity2.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="src\RSParserImpl.y"/> <None Include="src\RSParserImpl.y" />
<None Include="src\AsciiLexerImpl.l" /> <None Include="src\AsciiLexerImpl.l" />
<None Include="src\MathLexerImpl.l" /> <None Include="src\MathLexerImpl.l" />
</ItemGroup> </ItemGroup>

View File

@ -207,10 +207,6 @@
<None Include="src\MathLexerImpl.l"> <None Include="src\MathLexerImpl.l">
<Filter>11 parse\lexer</Filter> <Filter>11 parse\lexer</Filter>
</None> </None>
</ItemGroup> <None Include="src\RSParserImpl.y" />
<ItemGroup>
<Bison Include="src\RSParserImpl.y">
<Filter>11 parse\parser</Filter>
</Bison>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -18,7 +18,7 @@ enum class Syntax : uint8_t {
}; };
//! RS language token types enumeration //! RS language token types enumeration
enum class TokenID : uint32_t { enum class TokenID : uint32_t { // NOLINT(performance-enum-size)
// Global, local IDs and literals // Global, local IDs and literals
ID_LOCAL = 258, ID_LOCAL = 258,
ID_GLOBAL, ID_GLOBAL,

View File

@ -92,7 +92,7 @@ std::string Normalizer::CreateTupleName(const SyntaxTree::Node& root) {
std::stack<const SyntaxTree::Node*> nodeStack{}; std::stack<const SyntaxTree::Node*> nodeStack{};
std::stack<std::vector<Index>> pathStack{}; std::stack<std::vector<Index>> pathStack{};
nodeStack.push(&root); nodeStack.push(&root);
pathStack.push({}); pathStack.emplace();
while (!std::empty(nodeStack)) { while (!std::empty(nodeStack)) {
auto curPath = pathStack.top(); auto curPath = pathStack.top();
pathStack.pop(); pathStack.pop();

View File

@ -1,5 +1,3 @@
#pragma once
#include "ccl/rslang/Auditor.h" #include "ccl/rslang/Auditor.h"
namespace ccl::rslang { namespace ccl::rslang {

View File

@ -1,5 +1,3 @@
#pragma once
#include "ccl/rslang/Interpreter.h" #include "ccl/rslang/Interpreter.h"
#include <optional> #include <optional>

View File

@ -42,7 +42,7 @@ using Description = Generator::StructureDescription;
return {}; return {};
} }
const auto& newName = substitutes.at(argName); const auto& newName = substitutes.at(argName);
argsTypes.emplace_back(TypedID{ newName, std::get<Typification>(*type) }); argsTypes.emplace_back(newName, std::get<Typification>(*type));
} }
return Generator::CreatePrefix(argsTypes); return Generator::CreatePrefix(argsTypes);
} }

View File

@ -63,7 +63,7 @@ SDCompact::Header SDCompact::CreateHeader(const Typification& type) {
result.push_back(host.E().baseID); break; result.push_back(host.E().baseID); break;
case rslang::StructureType::collection: case rslang::StructureType::collection:
result.push_back("B"); break; result.emplace_back("B"); break;
case rslang::StructureType::tuple: case rslang::StructureType::tuple:
break; break;

View File

@ -223,8 +223,8 @@ std::optional<SyntaxTree::Cursor> FindMinimalNode(SyntaxTree::Cursor root, StrRa
} else { } else {
root.MoveToChild(0); root.MoveToChild(0);
do { do {
if (const auto result = FindMinimalNode(root, range); const auto result = FindMinimalNode(root, range);
result.has_value()) { if (result.has_value()) {
return result; return result;
} }
} while (root.MoveToNextSibling()); } while (root.MoveToNextSibling());