From 1cbecc7aad843b677ea078734493ae1122303b1f Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 20 Mar 2019 19:38:10 +0000 Subject: First round of clang tidy changes --- Jamroot.jam | 9 ++++++++- icetray/dryice/dryice.cpp | 3 +++ icetray/icetray/Jamfile.jam | 12 ++++++++++-- icetray/icetray/icetrayService.cpp | 4 ++++ icetray/icetray/logger.cpp | 17 +++++++++-------- icetray/icetray/logger.h | 4 ++-- icetray/tool/icetraySql.cpp | 1 + icetray/unittests/Jamfile.jam | 13 +++++++++---- icetray/unittests/testIceTrayLogger.cpp | 5 +++-- icetray/unittests/testIceTrayOptions.cpp | 2 +- icetray/unittests/testIceTrayReplace.cpp | 2 -- icetray/unittests/testOptions.cpp | 8 ++++++-- icetray/unittests/testService.cpp | 4 ---- icetray/unittests/testService.h | 2 -- 14 files changed, 56 insertions(+), 30 deletions(-) diff --git a/Jamroot.jam b/Jamroot.jam index 704caf4..909ef13 100644 --- a/Jamroot.jam +++ b/Jamroot.jam @@ -15,7 +15,14 @@ project debug:"-W -Wall -Werror -Wextra" coverage:"--coverage" coverage:"--coverage" - ; + tidy:boost-* + tidy:bugprone-* + tidy:clang-* + tidy:misc-* +#tidy:modernize-* + tidy:hicpp-* +#tidy:performance-* + ; build-project icetray ; diff --git a/icetray/dryice/dryice.cpp b/icetray/dryice/dryice.cpp index 7cf5c35..4021b9b 100644 --- a/icetray/dryice/dryice.cpp +++ b/icetray/dryice/dryice.cpp @@ -9,6 +9,7 @@ namespace IceTray { DryIce::DryIce(const Ice::StringSeq & cmdline) { + // NOLINTNEXTLINE(hicpp-no-array-decay) BOOST_ASSERT(!currentDryIce); Ice::StringSeq args; Ice::InitializationData id; @@ -59,7 +60,9 @@ namespace IceTray { ServicePtr DryIceClient::getService() const { + // NOLINTNEXTLINE(hicpp-no-array-decay) BOOST_ASSERT(DryIce::currentDryIce); + // NOLINTNEXTLINE(hicpp-no-array-decay) BOOST_ASSERT(DryIce::currentDryIce->s); return DryIce::currentDryIce->s; } diff --git a/icetray/icetray/Jamfile.jam b/icetray/icetray/Jamfile.jam index 3796fa8..bacda4e 100644 --- a/icetray/icetray/Jamfile.jam +++ b/icetray/icetray/Jamfile.jam @@ -2,8 +2,14 @@ import package ; lib boost_program_options ; +obj logWriter : logWriter.ice : + no + . + tidy:none + ; lib icetray : - [ glob-tree *.cpp *.ice : bin ] + [ glob *.cpp *.ice ] + logWriter : ..//adhocutil ..//dbppcore @@ -14,7 +20,8 @@ lib icetray : ..//slicer-db ../..//glibmm boost_program_options - yes + logWriter + pure . : : . @@ -22,6 +29,7 @@ lib icetray : ..//adhocutil ..//slicer ..//slicer-db + logWriter ; explicit install ; diff --git a/icetray/icetray/icetrayService.cpp b/icetray/icetray/icetrayService.cpp index d53930e..77e5ba6 100644 --- a/icetray/icetray/icetrayService.cpp +++ b/icetray/icetray/icetrayService.cpp @@ -9,12 +9,14 @@ namespace IceTray { Service::Service() { + // NOLINTNEXTLINE(hicpp-no-array-decay) BOOST_ASSERT(!current); current = this; } Service::~Service() { + // NOLINTNEXTLINE(hicpp-no-array-decay) BOOST_ASSERT(current); current = nullptr; } @@ -22,6 +24,7 @@ namespace IceTray { Service * Service::getCurrent() { + // NOLINTNEXTLINE(hicpp-no-array-decay) BOOST_ASSERT(current); return current; } @@ -30,6 +33,7 @@ namespace IceTray { Service::create(Ice::CommunicatorPtr) { auto serviceFactories = AdHoc::PluginManager::getDefault()->getAll(); + // NOLINTNEXTLINE(hicpp-no-array-decay) BOOST_ASSERT(serviceFactories.size() == 1); return serviceFactories.begin()->get()->implementation()->create(); } diff --git a/icetray/icetray/logger.cpp b/icetray/icetray/logger.cpp index 5143ea0..a6e61b4 100644 --- a/icetray/icetray/logger.cpp +++ b/icetray/icetray/logger.cpp @@ -19,9 +19,7 @@ namespace IceTray { { } - LoggerBase::~LoggerBase() - { - } + LoggerBase::~LoggerBase() = default; const Domain & LoggerBase::getDomain() const @@ -64,8 +62,11 @@ namespace IceTray { const auto fl = firstFor(priority); if (fl != logs.end()) { va_list v; + // NOLINTNEXTLINE(hicpp-vararg,hicpp-no-array-decay) va_start(v, msgfmt); + // NOLINTNEXTLINE(hicpp-no-array-decay) vmessagef(fl, priority, msgfmt, v); + // NOLINTNEXTLINE(hicpp-no-array-decay) va_end(v); } } @@ -78,6 +79,7 @@ namespace IceTray { if (len > 0) { message(fl, priority, msg); } + // NOLINTNEXTLINE(hicpp-no-malloc) free(msg); } @@ -102,6 +104,7 @@ namespace IceTray { std::unique_ptr res { abi::__cxa_demangle(type.name(), NULL, NULL, NULL), std::free }; + // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) return getLogger(res.get()); } @@ -164,10 +167,6 @@ namespace IceTray { return ::AdHoc::GlobalStatic<::IceTray::Logging::LogManager>::get(); } - AbstractLogWriter::AbstractLogWriter() - { - } - AbstractLogWriter::AbstractLogWriter(LogLevel level) { logDomains.insert({ { }, level }); @@ -220,7 +219,9 @@ namespace IceTray { Ice::StringSeq AbstractLogWriter::splitDomain(const std::string & domain) { - if (domain.empty()) return Ice::StringSeq(); + if (domain.empty()) { + return Ice::StringSeq(); + } Ice::StringSeq domainTokens; boost::algorithm::split(domainTokens, domain, boost::algorithm::is_any_of(".:"), boost::algorithm::token_compress_on); diff --git a/icetray/icetray/logger.h b/icetray/icetray/logger.h index 32b57db..00e948d 100644 --- a/icetray/icetray/logger.h +++ b/icetray/icetray/logger.h @@ -23,7 +23,7 @@ namespace IceTray { class DLL_PUBLIC LoggerBase { public: LoggerBase(const Domain & domain); - ~LoggerBase(); + virtual ~LoggerBase() = 0; const Domain & getDomain() const; @@ -97,7 +97,7 @@ namespace IceTray { IceUtil::Optional level(Domain, const Ice::Current &) override; protected: - AbstractLogWriter(); + AbstractLogWriter() = default; AbstractLogWriter(LogLevel level); AbstractLogWriter(const std::string & prefix, Ice::PropertiesPtr p); diff --git a/icetray/tool/icetraySql.cpp b/icetray/tool/icetraySql.cpp index 3b3d1d9..2b9a5ff 100644 --- a/icetray/tool/icetraySql.cpp +++ b/icetray/tool/icetraySql.cpp @@ -46,6 +46,7 @@ main(int argc, char ** argv) ("sql", po::value(&sql)->required(), "Path of SQL script") ("cpp", po::value(&cpp)->required(), "Path of C++ file to write") ("h", po::value(&h)->required(), "Path of header file to write") + // NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall) ("basedir,d", po::value(&base)->default_value(fs::current_path()), "Base directory of SQL scripts (namespaces are created relative to here)") ("namespace", po::value(&sqlns), "Namespace to create SqlSource in") ("connector,c", po::value(&connector), "Specifiy a default connector name") diff --git a/icetray/unittests/Jamfile.jam b/icetray/unittests/Jamfile.jam index 7ca8e2f..67ffc0a 100644 --- a/icetray/unittests/Jamfile.jam +++ b/icetray/unittests/Jamfile.jam @@ -20,10 +20,12 @@ alias testCommon : : : : ..//pthread boost_utf BOOST_TEST_DYN_LINK - ../tool//icetray-sql - ../tool//icetray-sql + ../tool//icetray-sql/gcc + ../tool//icetray-sql/gcc $(me) ../icetray//icetray + tidy:hicpp-vararg + tidy:hicpp-no-array-decay ; generators.register-standard $(__name__).icetray.c++.sql : SQL : CPP(%.sql) H(%.sql) ; @@ -40,15 +42,17 @@ actions icetray.c++.sql bind ICETRAYSQLBIN $(ICETRAYSQLBIN) --basedir="$(BASEDIR)" --namespace="$(NAMESPACE)" "$(2[1])" "$(1[1])" "$(1[2])" } +obj testIceTrayService : testIceTrayService.ice : tidy:none ; run testIceTray.cpp - testIceTrayService.ice + testIceTrayService testIceTrayServiceI.cpp testIceTrayServiceTestSql.sql subdir/some.sql subdir/a/more.sql : : : TestIceTray::sql + testIceTrayService testCommon stdc++fs dbpp-postgresql @@ -65,13 +69,14 @@ run run testIceTrayReplace.cpp - testIceTrayService.ice + testIceTrayService testIceTrayServiceI.cpp testIceTrayServiceTestSql.sql subdir/some.sql subdir/a/more.sql : : : TestIceTray::sql + testIceTrayService testCommon stdc++fs dbpp-postgresql diff --git a/icetray/unittests/testIceTrayLogger.cpp b/icetray/unittests/testIceTrayLogger.cpp index b8c9d5c..3eabf0d 100644 --- a/icetray/unittests/testIceTrayLogger.cpp +++ b/icetray/unittests/testIceTrayLogger.cpp @@ -24,12 +24,12 @@ struct LogEntry { class TestLogWriter : public AbstractLogWriter { public: template - TestLogWriter(const T & ... t) : + explicit TestLogWriter(const T & ... t) : AbstractLogWriter(t...) { } - TestLogWriter(const Ice::PropertiesPtr & p) : + explicit TestLogWriter(const Ice::PropertiesPtr & p) : AbstractLogWriter("TestLogWriter", p) { } @@ -76,6 +76,7 @@ BOOST_AUTO_TEST_CASE( staticLogInit ) BOOST_REQUIRE_EQUAL(expected, staticLog->getDomain()); } +// NOLINTNEXTLINE(hicpp-special-member-functions) class TestLogImpl { public: TestLogImpl() : diff --git a/icetray/unittests/testIceTrayOptions.cpp b/icetray/unittests/testIceTrayOptions.cpp index 62f921a..3101052 100644 --- a/icetray/unittests/testIceTrayOptions.cpp +++ b/icetray/unittests/testIceTrayOptions.cpp @@ -14,7 +14,7 @@ class DI : public IceTray::DryIce { public: - DI(const Ice::StringSeq & opts) : IceTray::DryIce(opts) { } + explicit DI(const Ice::StringSeq & opts) : IceTray::DryIce(opts) { } }; BOOST_AUTO_TEST_CASE( testOptions ) diff --git a/icetray/unittests/testIceTrayReplace.cpp b/icetray/unittests/testIceTrayReplace.cpp index 346e0a1..1558326 100644 --- a/icetray/unittests/testIceTrayReplace.cpp +++ b/icetray/unittests/testIceTrayReplace.cpp @@ -11,8 +11,6 @@ namespace TestIceTray { class DummyTestIceTrayServiceI : public TestIceTrayService { public: - DummyTestIceTrayServiceI() { } - void method1(const Ice::Current &) override { } void method2(Ice::Int, std::string, const Ice::Current &) override { } }; diff --git a/icetray/unittests/testOptions.cpp b/icetray/unittests/testOptions.cpp index af5151c..b47e8a4 100644 --- a/icetray/unittests/testOptions.cpp +++ b/icetray/unittests/testOptions.cpp @@ -1,6 +1,8 @@ #include "testOptions.h" -TestOptions::TestOptions() : IceTray::Options("Test options") +TestOptions::TestOptions() : + IceTray::Options("Test options"), + testInt(0) { } @@ -12,7 +14,9 @@ ICETRAY_OPTIONS(TestOptions, class TestOptionsInline : public IceTray::Options { public: - TestOptionsInline() : IceTray::Options("Test options inline") + TestOptionsInline() : + IceTray::Options("Test options inline"), + testInt(0) { } diff --git a/icetray/unittests/testService.cpp b/icetray/unittests/testService.cpp index 0e8cc2d..8f678b0 100644 --- a/icetray/unittests/testService.cpp +++ b/icetray/unittests/testService.cpp @@ -1,10 +1,6 @@ #include "testService.h" #include "testOptions.h" -TestService::~TestService() -{ -} - void TestService::addObjects(const std::string &, const Ice::CommunicatorPtr &, const Ice::StringSeq &, const Ice::ObjectAdapterPtr &) { diff --git a/icetray/unittests/testService.h b/icetray/unittests/testService.h index 42af919..7c5a0ae 100644 --- a/icetray/unittests/testService.h +++ b/icetray/unittests/testService.h @@ -2,8 +2,6 @@ class DLL_PUBLIC TestService : public IceTray::Service { public: - virtual ~TestService(); - void addObjects(const std::string &, const Ice::CommunicatorPtr &, const Ice::StringSeq &, const Ice::ObjectAdapterPtr &) override; }; -- cgit v1.2.3