From 26e4b00f50502f788b67d09eccb06f121d72fc2f Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 27 Mar 2019 19:35:46 +0000 Subject: Enable some clang-tidy checks and fix up accordingly --- icespider/common/Jamfile.jam | 17 ++++++++++------- icespider/compile/Jamfile.jam | 5 ++++- icespider/compile/routeCompiler.cpp | 5 +++++ icespider/compile/slice/Jamroot.jam | 1 + icespider/core/Jamfile.jam | 6 +++++- icespider/core/ihttpRequest.h | 7 ++++++- icespider/core/xwwwFormUrlEncoded.cpp | 1 + icespider/fcgi/cgiRequestBase.cpp | 1 + icespider/fileSessions/fileSessions.cpp | 3 ++- icespider/testing/testRequest.cpp | 2 ++ icespider/unittests/Jamfile.jam | 28 +++++++++++++++++++--------- icespider/unittests/testRoutes.json | 7 +------ 12 files changed, 57 insertions(+), 26 deletions(-) diff --git a/icespider/common/Jamfile.jam b/icespider/common/Jamfile.jam index 0c53482..dc13273 100644 --- a/icespider/common/Jamfile.jam +++ b/icespider/common/Jamfile.jam @@ -1,23 +1,26 @@ lib adhocutil : : : : /usr/include/adhocutil ; lib slicer : : : : /usr/include/slicer ; -cpp http-slicer : - http.ice - : - pure - ; +obj http : http.ice : tidy:none ; +obj session : session.ice : tidy:none ; lib icespider-common : - [ glob-tree *.ice *.cpp : bin ] - http-slicer + [ glob *.cpp ] + http session + http.ice : adhocutil ..//pthread ..//Ice slicer + pure + http + session : : ..//pthread ..//Ice + http + session . ; diff --git a/icespider/compile/Jamfile.jam b/icespider/compile/Jamfile.jam index f65800e..8d01d72 100644 --- a/icespider/compile/Jamfile.jam +++ b/icespider/compile/Jamfile.jam @@ -5,11 +5,13 @@ lib boost_program_options ; lib stdc++fs ; lib mcpp ; +obj routes : routes.ice : ../common//icespider-common tidy:none ; lib icespider-compile : routeCompiler.cpp routes.ice + routes : - yes + pure # Need to disable LTO here cos of a GCC bug, this isn't # performance critical anyway -fno-lto @@ -21,6 +23,7 @@ lib icespider-compile : slice//Slice ../common//icespider-common ../common//icespider-common + routes ..//Ice ..//pthread mcpp diff --git a/icespider/compile/routeCompiler.cpp b/icespider/compile/routeCompiler.cpp index ae48428..75737ee 100644 --- a/icespider/compile/routeCompiler.cpp +++ b/icespider/compile/routeCompiler.cpp @@ -74,10 +74,12 @@ namespace IceSpider { auto fqon = boost::algorithm::join(ns + cls->name(), "."); if (fqon == tn) return { NULL, cls->declaration() }; auto t = findType(tn, cls, ns + cls->name()); + // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDelete) if (t.first || t.second) return t; } for (const auto & m : c->modules()) { auto t = findType(tn, m, ns + m->name()); + // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDelete) if (t.first || t.second) return t; } return { NULL, NULL }; @@ -87,6 +89,7 @@ namespace IceSpider { RouteCompiler::findType(const std::string & tn, const Units & us) { for (const auto & u : us) { + // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDelete) auto t = findType(tn, u.second); if (t.first || t.second) return t; } @@ -439,6 +442,8 @@ namespace IceSpider { auto ip = ps.find(p.first)->second; const auto paramType = "std::remove_cvref<%?>::type"_fmt( Slice::inputTypeToString(ip->type(), false, "", ip->getMetaData())); + // This shouldn't be needed... the warning is ignored elsewhere to no effect + fprintbf(4, output, "// NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall)\n"); if (p.second->source == ParameterSource::Body) { if (p.second->key) { if (!doneBody) { diff --git a/icespider/compile/slice/Jamroot.jam b/icespider/compile/slice/Jamroot.jam index 46b4e3c..f83b79e 100644 --- a/icespider/compile/slice/Jamroot.jam +++ b/icespider/compile/slice/Jamroot.jam @@ -13,6 +13,7 @@ lib Slice : $(ice)/cpp/src/Slice/FileTracker.cpp $(ice)/cpp/src/Slice/Scanner.cpp : + tidy:none -fPIC $(ice)/cpp/src static diff --git a/icespider/core/Jamfile.jam b/icespider/core/Jamfile.jam index 2f2f733..91e92e9 100644 --- a/icespider/core/Jamfile.jam +++ b/icespider/core/Jamfile.jam @@ -2,16 +2,20 @@ lib adhocutil : : : : /usr/include/adhocutil ; lib slicer : : : : /usr/include/slicer ; lib stdc++fs ; +obj routeOptions : routeOptions.ice : tidy:none ; lib icespider-core : - [ glob-tree *.c *.cpp *.ice : bin ] + [ glob *.c *.cpp ] + routeOptions : ../common//icespider-common adhocutil slicer stdc++fs ../common + routeOptions : : . ../common//icespider-common ../common + routeOptions ; diff --git a/icespider/core/ihttpRequest.h b/icespider/core/ihttpRequest.h index fb56efb..e1044f1 100644 --- a/icespider/core/ihttpRequest.h +++ b/icespider/core/ihttpRequest.h @@ -53,8 +53,12 @@ namespace IceSpider { else if constexpr (std::is_constructible::value) { return T(*v); } + else if constexpr (std::is_same::value) { + return std::to_string(*v); + } else { try { + // NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall) return boost::lexical_cast(*v); } catch (const boost::bad_lexical_cast & e) { @@ -62,13 +66,14 @@ namespace IceSpider { } } } - else { + else { return std::nullopt; } } template T getURLParam(unsigned int n) const { + // NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall) return *getFrom(n, &IHttpRequest::getURLParam); } template diff --git a/icespider/core/xwwwFormUrlEncoded.cpp b/icespider/core/xwwwFormUrlEncoded.cpp index a9e19ba..7f4bdcd 100644 --- a/icespider/core/xwwwFormUrlEncoded.cpp +++ b/icespider/core/xwwwFormUrlEncoded.cpp @@ -72,6 +72,7 @@ namespace IceSpider { SET(Ice::Int); SET(Ice::Long); SET(Ice::Float); + // NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall) SET(Ice::Double); const std::string & s; }; diff --git a/icespider/fcgi/cgiRequestBase.cpp b/icespider/fcgi/cgiRequestBase.cpp index 8735d87..ab4d5e8 100644 --- a/icespider/fcgi/cgiRequestBase.cpp +++ b/icespider/fcgi/cgiRequestBase.cpp @@ -80,6 +80,7 @@ namespace IceSpider { { namespace ba = boost::algorithm; if (auto path = findFirstOrElse(envmap, REDIRECT_URL, SCRIPT_NAME).substr(1); + // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) !path.empty()) { ba::split(pathElements, path, ba::is_any_of("/"), ba::token_compress_off); } diff --git a/icespider/fileSessions/fileSessions.cpp b/icespider/fileSessions/fileSessions.cpp index e1c3b5c..ad026da 100644 --- a/icespider/fileSessions/fileSessions.cpp +++ b/icespider/fileSessions/fileSessions.cpp @@ -35,6 +35,7 @@ namespace IceSpider { SessionPtr createSession(const ::Ice::Current &) override { auto s = std::make_shared(); + // NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall) s->id = boost::lexical_cast(boost::uuids::random_generator()()); s->duration = duration; save(s); @@ -109,7 +110,7 @@ namespace IceSpider { while (di != std::filesystem::directory_iterator()) { auto s = load(di->path()); if (s && isExpired(s)) { - destroySession(s->id, Ice::Current()); + FileSessions::destroySession(s->id, Ice::Current()); } di++; } diff --git a/icespider/testing/testRequest.cpp b/icespider/testing/testRequest.cpp index 1c0d9cb..5aa5bce 100644 --- a/icespider/testing/testRequest.cpp +++ b/icespider/testing/testRequest.cpp @@ -10,7 +10,9 @@ namespace IceSpider { { namespace ba = boost::algorithm; auto path = p.substr(1); + // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) if (!path.empty()) { + // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) ba::split(url, path, ba::is_any_of("/"), ba::token_compress_off); } } diff --git a/icespider/unittests/Jamfile.jam b/icespider/unittests/Jamfile.jam index 352d665..bf31020 100644 --- a/icespider/unittests/Jamfile.jam +++ b/icespider/unittests/Jamfile.jam @@ -43,7 +43,7 @@ run : BOOST_TEST_DYN_LINK testCommon - test-api + test-api-lib dl adhocutil slicer-xml @@ -53,7 +53,7 @@ run ../compile//icespider-compile ../compile//icespider-compile . - test-api + test-api-lib : testCompile : ; @@ -79,9 +79,11 @@ run xslt/transform.xslt : BOOST_TEST_DYN_LINK - ../compile//icespider + gcc:../compile//icespider/gcc + clang:../compile//icespider/clang + tidy:../compile//icespider/gcc testCommon - test-api + test-api-lib adhocutil slicer slicer-json @@ -92,22 +94,27 @@ run ../xslt//icespider-xslt ../testing//icespider-testing ../common//icespider-common - test-api - ../compile + test-api-lib + gcc:../compile//icespider/gcc + clang:../compile//icespider/clang + tidy:../compile//icespider/gcc . : testApp ; +obj test-fcgi : test-fcgi.ice : tidy:none ; run testFcgi.cpp test-fcgi.ice + test-fcgi ../fcgi/cgiRequestBase.cpp : : : - yes + pure BOOST_TEST_DYN_LINK testCommon ../common//icespider-common ../core//icespider-core ../core//icespider-core + test-fcgi stdc++fs slicer slicer-json @@ -129,15 +136,18 @@ run ../core//icespider-core ; -lib test-api : +obj test-api : test-api.ice : . tidy:none ; +lib test-api-lib : test-api.ice test-api-impl.cpp + test-api : - yes + pure slicer adhocutil ..//pthread ..//Ice + test-api . ; diff --git a/icespider/unittests/testRoutes.json b/icespider/unittests/testRoutes.json index 7d3b10f..e3f2298 100644 --- a/icespider/unittests/testRoutes.json +++ b/icespider/unittests/testRoutes.json @@ -69,12 +69,7 @@ "itemWithDefault":{ "path": "/item/{s}/{i}", "method": "GET", - "operation": "TestIceSpider.TestApi.withParams", - "params": { - "i": { - "default": "1234" - } - } + "operation": "TestIceSpider.TestApi.withParams" }, "mashStruct": { "path": "/mashS/{s}/{t}/{i}", -- cgit v1.2.3