summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2020-06-27 16:23:18 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2020-06-27 16:23:18 +0100
commit064a44e571f2bf2593571fc42f808129f8c447c5 (patch)
tree2b52f31301b2b0ac636a19eaaa14d008d451de83
parentClang format and tidy (diff)
downloadslicer-1.10.1.tar.bz2
slicer-1.10.1.tar.xz
slicer-1.10.1.zip
Pass clang-tidy and cppcheckslicer-1.10.1
-rw-r--r--Jamroot.jam33
-rw-r--r--slicer/db/sqlInsertSerializer.h11
-rw-r--r--slicer/db/sqlSelectDeserializer.h3
-rw-r--r--slicer/db/sqlSource.h2
-rw-r--r--slicer/ice/serializer.cpp8
-rw-r--r--slicer/ice/serializer.h12
-rw-r--r--slicer/slicer/modelPartsTypes.h3
-rw-r--r--slicer/slicer/modelPartsTypes.impl.h19
-rw-r--r--slicer/test/preprocessor.cpp11
-rw-r--r--slicer/tool/parser.cpp10
10 files changed, 59 insertions, 53 deletions
diff --git a/Jamroot.jam b/Jamroot.jam
index 9d1aa16..b350916 100644
--- a/Jamroot.jam
+++ b/Jamroot.jam
@@ -34,22 +34,25 @@ project
<toolset>tidy:<xcheckxx>hicpp-no-array-decay
<toolset>tidy:<xcheckxx>hicpp-vararg
<toolset>tidy:<checkxx>performance-*
- <toolset>tidy:<exclude>test/bin/tidy/debug/cxxstd-17-iso/classes.h
- <toolset>tidy:<exclude>test/bin/tidy/debug/cxxstd-17-iso/classtype.h
- <toolset>tidy:<exclude>test/bin/tidy/debug/cxxstd-17-iso/collections.h
- <toolset>tidy:<exclude>test/bin/tidy/debug/cxxstd-17-iso/enums.h
- <toolset>tidy:<exclude>test/bin/tidy/debug/cxxstd-17-iso/inheritance.h
- <toolset>tidy:<exclude>test/bin/tidy/debug/cxxstd-17-iso/interfaces.h
- <toolset>tidy:<exclude>test/bin/tidy/debug/cxxstd-17-iso/json.h
- <toolset>tidy:<exclude>test/bin/tidy/debug/cxxstd-17-iso/locals.h
- <toolset>tidy:<exclude>test/bin/tidy/debug/cxxstd-17-iso/optionals.h
- <toolset>tidy:<exclude>test/bin/tidy/debug/cxxstd-17-iso/structs.h
- <toolset>tidy:<exclude>test/bin/tidy/debug/cxxstd-17-iso/types.h
- <toolset>tidy:<exclude>test/bin/tidy/debug/cxxstd-17-iso/xml.h
+ <toolset>tidy:<exclude>test/bin/tidy/debug/checker-none/cxxstd-17-iso/classes.h
+ <toolset>tidy:<exclude>test/bin/tidy/debug/checker-none/cxxstd-17-iso/classtype.h
+ <toolset>tidy:<exclude>test/bin/tidy/debug/checker-none/cxxstd-17-iso/collections.h
+ <toolset>tidy:<exclude>test/bin/tidy/debug/checker-none/cxxstd-17-iso/enums.h
+ <toolset>tidy:<exclude>test/bin/tidy/debug/checker-none/cxxstd-17-iso/inheritance.h
+ <toolset>tidy:<exclude>test/bin/tidy/debug/checker-none/cxxstd-17-iso/interfaces.h
+ <toolset>tidy:<exclude>test/bin/tidy/debug/checker-none/cxxstd-17-iso/json.h
+ <toolset>tidy:<exclude>test/bin/tidy/debug/checker-none/cxxstd-17-iso/locals.h
+ <toolset>tidy:<exclude>test/bin/tidy/debug/checker-none/cxxstd-17-iso/optionals.h
+ <toolset>tidy:<exclude>test/bin/tidy/debug/checker-none/cxxstd-17-iso/structs.h
+ <toolset>tidy:<exclude>test/bin/tidy/debug/checker-none/cxxstd-17-iso/types.h
+ <toolset>tidy:<exclude>test/bin/tidy/debug/checker-none/cxxstd-17-iso/xml.h
<toolset>tidy:<exclude>slicer/bin/common.h
- <toolset>tidy:<exclude>xml/bin/tidy/debug/cxxstd-17-iso/xmlExceptions.h
- <toolset>tidy:<exclude>db/bin/tidy/debug/cxxstd-17-iso/sqlExceptions.h
- <toolset>tidy:<exclude>db/bin/tidy/debug/cxxstd-17-iso/testModels.h
+ <toolset>tidy:<exclude>xml/bin/tidy/debug/checker-none/cxxstd-17-iso/xmlExceptions.h
+ <toolset>tidy:<exclude>db/bin/tidy/debug/checker-none/cxxstd-17-iso/sqlExceptions.h
+ <toolset>tidy:<exclude>db/bin/tidy/debug/checker-none/cxxstd-17-iso/testModels.h
+ <toolset>tidy:<exclude>ice/cpp/*
+ <toolset>tidy:<define>ICE_IGNORE_VERSION
+ <toolset>tidy:<define>__x86_64
;
build-project slicer ;
diff --git a/slicer/db/sqlInsertSerializer.h b/slicer/db/sqlInsertSerializer.h
index 6150d66..b964b5e 100644
--- a/slicer/db/sqlInsertSerializer.h
+++ b/slicer/db/sqlInsertSerializer.h
@@ -29,21 +29,22 @@ namespace Slicer {
class DLL_PUBLIC SqlAutoIdInsertSerializer : public SqlInsertSerializer {
public:
- template<typename... P> SqlAutoIdInsertSerializer(const P &... p) : SqlInsertSerializer(p...) { }
+ template<typename... P> explicit SqlAutoIdInsertSerializer(const P &... p) : SqlInsertSerializer(p...) { }
protected:
virtual void createInsertField(
- int & fieldNo, std::ostream & insert, const std::string & name, const HookCommon * h) const;
+ int & fieldNo, std::ostream & insert, const std::string & name, const HookCommon * h) const override;
virtual void bindObjectAndExecuteField(
- int & paramNo, DB::ModifyCommand *, const Slicer::ModelPartPtr &, const HookCommon *) const;
+ int & paramNo, DB::ModifyCommand *, const Slicer::ModelPartPtr &, const HookCommon *) const override;
};
class DLL_PUBLIC SqlFetchIdInsertSerializer : public SqlAutoIdInsertSerializer {
public:
- template<typename... P> SqlFetchIdInsertSerializer(const P &... p) : SqlAutoIdInsertSerializer(p...) { }
+ template<typename... P>
+ explicit SqlFetchIdInsertSerializer(const P &... p) : SqlAutoIdInsertSerializer(p...) { }
protected:
- virtual void bindObjectAndExecute(const Slicer::ModelPartPtr &, DB::ModifyCommand *) const;
+ virtual void bindObjectAndExecute(const Slicer::ModelPartPtr &, DB::ModifyCommand *) const override;
};
}
diff --git a/slicer/db/sqlSelectDeserializer.h b/slicer/db/sqlSelectDeserializer.h
index 5f34ef4..32961e9 100644
--- a/slicer/db/sqlSelectDeserializer.h
+++ b/slicer/db/sqlSelectDeserializer.h
@@ -8,7 +8,8 @@
namespace Slicer {
class DLL_PUBLIC SqlSelectDeserializer : public Slicer::Deserializer {
public:
- SqlSelectDeserializer(DB::SelectCommand *, Ice::optional<std::string> typeIdCol = Ice::optional<std::string>());
+ explicit SqlSelectDeserializer(
+ DB::SelectCommand *, Ice::optional<std::string> typeIdCol = Ice::optional<std::string>());
void Deserialize(Slicer::ModelPartForRootPtr) override;
diff --git a/slicer/db/sqlSource.h b/slicer/db/sqlSource.h
index 548f35e..c48fb4d 100644
--- a/slicer/db/sqlSource.h
+++ b/slicer/db/sqlSource.h
@@ -11,7 +11,7 @@ namespace Slicer {
public Slicer::TValueSource<boost::posix_time::time_duration>,
public Slicer::TValueSource<boost::posix_time::ptime> {
public:
- SqlSource(const DB::Column & c);
+ explicit SqlSource(const DB::Column & c);
bool isNull() const;
void set(boost::posix_time::ptime & b) const override;
diff --git a/slicer/ice/serializer.cpp b/slicer/ice/serializer.cpp
index 877f531..a7a4eb9 100644
--- a/slicer/ice/serializer.cpp
+++ b/slicer/ice/serializer.cpp
@@ -14,14 +14,14 @@ namespace Slicer {
{
ic->destroy();
}
- IceBlobSerializer::IceBlobSerializer(Ice::ByteSeq & b) : blob(b) { }
+ IceBlobSerializer::IceBlobSerializer(Ice::ByteSeq & b) : refblob(b) { }
void
IceBlobSerializer::Serialize(ModelPartForRootPtr mp)
{
Ice::OutputStream s(ic);
mp->Write(s);
- s.finished(blob);
+ s.finished(refblob);
}
IceStreamSerializer::IceStreamSerializer(std::ostream & os) : IceBlobSerializer(blob), strm(os) { }
@@ -33,12 +33,12 @@ namespace Slicer {
strm.write((const char *)&blob.front(), blob.size());
}
- IceBlobDeserializer::IceBlobDeserializer(const Ice::ByteSeq & b) : blob(b) { }
+ IceBlobDeserializer::IceBlobDeserializer(const Ice::ByteSeq & b) : refblob(b) { }
void
IceBlobDeserializer::Deserialize(ModelPartForRootPtr mp)
{
- Ice::InputStream s(ic, blob);
+ Ice::InputStream s(ic, refblob);
mp->Read(s);
}
diff --git a/slicer/ice/serializer.h b/slicer/ice/serializer.h
index 05a7752..cbead6f 100644
--- a/slicer/ice/serializer.h
+++ b/slicer/ice/serializer.h
@@ -19,17 +19,17 @@ namespace Slicer {
class DLL_PUBLIC IceBlobSerializer : public Serializer, protected IceBase {
public:
- IceBlobSerializer(Ice::ByteSeq &);
+ explicit IceBlobSerializer(Ice::ByteSeq &);
void Serialize(ModelPartForRootPtr) override;
private:
- Ice::ByteSeq & blob;
+ Ice::ByteSeq & refblob;
};
class DLL_PUBLIC IceStreamSerializer : public IceBlobSerializer {
public:
- IceStreamSerializer(std::ostream &);
+ explicit IceStreamSerializer(std::ostream &);
void Serialize(ModelPartForRootPtr) override;
@@ -40,17 +40,17 @@ namespace Slicer {
class DLL_PUBLIC IceBlobDeserializer : public Deserializer, protected IceBase {
public:
- IceBlobDeserializer(const Ice::ByteSeq &);
+ explicit IceBlobDeserializer(const Ice::ByteSeq &);
void Deserialize(ModelPartForRootPtr) override;
protected:
- const Ice::ByteSeq & blob;
+ const Ice::ByteSeq & refblob;
};
class DLL_PUBLIC IceStreamDeserializer : public IceBlobDeserializer {
public:
- IceStreamDeserializer(std::istream &);
+ explicit IceStreamDeserializer(std::istream &);
void Deserialize(ModelPartForRootPtr) override;
diff --git a/slicer/slicer/modelPartsTypes.h b/slicer/slicer/modelPartsTypes.h
index b47353b..78eee3b 100644
--- a/slicer/slicer/modelPartsTypes.h
+++ b/slicer/slicer/modelPartsTypes.h
@@ -361,9 +361,6 @@ namespace Slicer {
explicit ModelPartForStreamRoot(Stream<T> * s);
const std::string & GetRootName() const override;
-
- private:
- Stream<T> * stream;
};
}
diff --git a/slicer/slicer/modelPartsTypes.impl.h b/slicer/slicer/modelPartsTypes.impl.h
index be464d1..ca562a6 100644
--- a/slicer/slicer/modelPartsTypes.impl.h
+++ b/slicer/slicer/modelPartsTypes.impl.h
@@ -447,11 +447,13 @@ namespace Slicer {
ChildRef
ModelPartForComplex<T>::GetChildRefFromRange(const R & range, const HookFilter & flt)
{
- auto model = GetModel();
- for (const auto & h : range) {
- if (h->filter(flt)) {
- return ChildRef(h->Get(model), h->GetMetadata());
- }
+ const auto itr = std::find_if(boost::begin(range), boost::end(range), [&flt](auto && h) {
+ return h->filter(flt);
+ });
+ if (itr != boost::end(range)) {
+ const auto & h = *itr;
+ auto model = GetModel();
+ return ChildRef(h->Get(model), h->GetMetadata());
}
return ChildRef();
}
@@ -526,17 +528,18 @@ namespace Slicer {
class DLL_PRIVATE ModelPartForComplex<T>::HookMetadata : public ModelPartForComplex<T>::template Hook<MT, MP> {
public:
HookMetadata(MT T::*member, const std::string & n, Metadata md) :
- Hook<MT, MP>(member, n), metadata(std::move(md))
+ Hook<MT, MP>(member, n), hookMetadata(std::move(md))
{
}
[[nodiscard]] const Metadata &
GetMetadata() const override
{
- return metadata;
+ return hookMetadata;
}
- const Metadata metadata;
+ private:
+ const Metadata hookMetadata;
};
// ModelPartForClass
diff --git a/slicer/test/preprocessor.cpp b/slicer/test/preprocessor.cpp
index 454d58a..4f474ee 100644
--- a/slicer/test/preprocessor.cpp
+++ b/slicer/test/preprocessor.cpp
@@ -6,6 +6,7 @@
#include <buffer.h>
#include <common.h>
#include <definedDirs.h>
+#include <numeric>
#include <tool/parser.h>
using ComponentsCount = std::map<std::string, unsigned int>;
@@ -16,12 +17,12 @@ ComponentsCount COMPONENTS_IN_TEST_ICE = {{"classtype.ice", 1}, {"classes.ice",
unsigned int
total()
{
- unsigned int t = 0;
- for (const auto & c : COMPONENTS_IN_TEST_ICE) {
- t += c.second;
- }
+ const auto t = std::accumulate(
+ COMPONENTS_IN_TEST_ICE.begin(), COMPONENTS_IN_TEST_ICE.end(), 0U, [](auto & t, auto && c) {
+ return t += c.second;
+ });
+ BOOST_CHECK_EQUAL(47, t);
return t;
- BOOST_REQUIRE_EQUAL(40, t);
}
void
diff --git a/slicer/tool/parser.cpp b/slicer/tool/parser.cpp
index d342c35..81bb10e 100644
--- a/slicer/tool/parser.cpp
+++ b/slicer/tool/parser.cpp
@@ -595,9 +595,9 @@ namespace Slicer {
cpp = cppfile.get();
Slicer::Slicer::Args args;
// Copy includes to args
- for (const auto & include : includes) {
- args.push_back("-I" + include.string());
- }
+ std::transform(includes.begin(), includes.end(), std::back_inserter(args), [](auto && include) {
+ return "-I" + include.string();
+ });
Slice::PreprocessorPtr icecpp = Slice::Preprocessor::create("slicer", slicePath, args);
FILE * cppHandle = icecpp->preprocess(false);
@@ -618,7 +618,7 @@ namespace Slicer {
throw CompilerError("unit parse failed");
}
- unsigned int initial = Components();
+ unsigned int initial = components;
u->visit(this, false);
@@ -628,7 +628,7 @@ namespace Slicer {
cpp = nullptr;
}
- return Components() - initial;
+ return components - initial;
}
catch (...) {
if (!cppPath.empty()) {