Merge pull request #23225 from mshabunin:fix-clang-warnings

This commit is contained in:
Alexander Alekhin 2023-02-08 17:28:07 +00:00
commit 649841e6bf
14 changed files with 47 additions and 41 deletions

View File

@ -24,7 +24,7 @@ if(UNIX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function -Wno-missing-braces -Wno-missing-field-initializers")
endif()
if(CV_CLANG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-self-assign")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-self-assign -Wno-strict-prototypes")
endif()
endif()

View File

@ -235,6 +235,10 @@ T* allocSingletonNew() { return new(allocSingletonNewBuffer(sizeof(T))) T(); }
#include "ipp.h"
#endif
#ifdef HAVE_IPP_IW
# if defined(__OPENCV_BUILD) && defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wstrict-prototypes"
# endif
# if defined(__OPENCV_BUILD) && defined(__GNUC__) && __GNUC__ >= 5
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wsuggest-override"
@ -246,6 +250,9 @@ T* allocSingletonNew() { return new(allocSingletonNewBuffer(sizeof(T))) T(); }
# if defined(__OPENCV_BUILD) && defined(__GNUC__) && __GNUC__ >= 5
# pragma GCC diagnostic pop
# endif
# if defined(__OPENCV_BUILD) && defined(__clang__)
# pragma clang diagnostic pop
# endif
#endif
#if IPP_VERSION_X100 >= 201700

View File

@ -664,7 +664,6 @@ static cv::GRunArgs run_py_kernel(cv::detail::PyObjectHolder kernel,
cv::GRunArgs outs;
try
{
int in_idx = 0;
// NB: Doesn't increase reference counter (false),
// because PyObject already have ownership.
// In case exception decrement reference counter.
@ -697,7 +696,6 @@ static cv::GRunArgs run_py_kernel(cv::detail::PyObjectHolder kernel,
util::throw_error(std::logic_error("GFrame isn't supported for custom operation"));
break;
}
++in_idx;
}
if (ctx.m_state.has_value())

View File

@ -27,7 +27,7 @@ class GMockExecutable final: public cv::gimpl::GIslandExecutable
m_priv->m_reshape_counter++;
}
virtual void handleNewStream() override { }
virtual void run(std::vector<InObj>&&, std::vector<OutObj>&&) { }
virtual void run(std::vector<InObj>&&, std::vector<OutObj>&&) override { }
virtual bool allocatesOutputs() const override
{
return true;

View File

@ -190,7 +190,7 @@ public:
: cv::gapi::wip::GCaptureSource(pipeline) {
}
bool pull(cv::gapi::wip::Data& data) {
bool pull(cv::gapi::wip::Data& data) override {
if (cv::gapi::wip::GCaptureSource::pull(data)) {
data = cv::MediaFrame::Create<TestMediaBGR>(cv::util::get<cv::Mat>(data));
return true;
@ -232,7 +232,7 @@ public:
: cv::gapi::wip::GCaptureSource(pipeline) {
}
bool pull(cv::gapi::wip::Data& data) {
bool pull(cv::gapi::wip::Data& data) override {
if (cv::gapi::wip::GCaptureSource::pull(data)) {
cv::Mat bgr = cv::util::get<cv::Mat>(data);
cv::Mat y, uv;
@ -256,7 +256,7 @@ public:
: cv::gapi::wip::GCaptureSource(pipeline) {
}
bool pull(cv::gapi::wip::Data& data) {
bool pull(cv::gapi::wip::Data& data) override {
if (cv::gapi::wip::GCaptureSource::pull(data)) {
cv::Mat bgr = cv::util::get<cv::Mat>(data);
cv::Mat gray;
@ -319,7 +319,7 @@ public:
return "InvalidSource sucessfuly failed!";
}
bool pull(cv::gapi::wip::Data& d) {
bool pull(cv::gapi::wip::Data& d) override {
++m_curr_frame_id;
if (m_curr_frame_id > m_num_frames) {
return false;

View File

@ -49,10 +49,10 @@ public:
CV_FilterBaseTest( bool _fp_kernel );
protected:
int prepare_test_case( int test_case_idx );
int read_params( const cv::FileStorage& fs );
void get_test_array_types_and_sizes( int test_case_idx, vector<vector<Size> >& sizes, vector<vector<int> >& types );
void get_minmax_bounds( int i, int j, int type, Scalar& low, Scalar& high );
int prepare_test_case( int test_case_idx ) CV_OVERRIDE;
int read_params( const cv::FileStorage& fs ) CV_OVERRIDE;
void get_test_array_types_and_sizes( int test_case_idx, vector<vector<Size> >& sizes, vector<vector<int> >& types ) CV_OVERRIDE;
void get_minmax_bounds( int i, int j, int type, Scalar& low, Scalar& high ) CV_OVERRIDE;
Size aperture_size;
Point anchor;
int max_aperture_size;
@ -689,8 +689,8 @@ public:
CV_SmoothBaseTest();
protected:
void get_test_array_types_and_sizes( int test_case_idx, vector<vector<Size> >& sizes, vector<vector<int> >& types );
double get_success_error_level( int test_case_idx, int i, int j );
void get_test_array_types_and_sizes( int test_case_idx, vector<vector<Size> >& sizes, vector<vector<int> >& types ) CV_OVERRIDE;
double get_success_error_level( int test_case_idx, int i, int j ) CV_OVERRIDE;
const char* smooth_type;
void dump_test_case(int test_case_idx, std::ostream* out) CV_OVERRIDE
@ -802,10 +802,10 @@ public:
CV_GaussianBlurTest();
protected:
void prepare_to_validation( int test_case_idx );
void run_func();
void get_test_array_types_and_sizes( int test_case_idx, vector<vector<Size> >& sizes, vector<vector<int> >& types );
double get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ );
void prepare_to_validation( int test_case_idx ) CV_OVERRIDE;
void run_func() CV_OVERRIDE;
void get_test_array_types_and_sizes( int test_case_idx, vector<vector<Size> >& sizes, vector<vector<int> >& types ) CV_OVERRIDE;
double get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ ) CV_OVERRIDE;
double sigma;
int param1, param2;

View File

@ -116,20 +116,22 @@
# endif
#endif
#if defined(__OPENCV_BUILD) && defined(__clang__)
#pragma clang diagnostic ignored "-Winconsistent-missing-override"
#endif
#if defined(__OPENCV_BUILD) && defined(__GNUC__) && __GNUC__ >= 5
//#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#endif
#if defined(__OPENCV_BUILD) && defined(__APPLE__) && defined(__clang__) && ((__clang_major__*100 + __clang_minor__) >= 1301)
#if defined(__OPENCV_BUILD) && defined(__clang__) && ((__clang_major__*100 + __clang_minor__) >= 1301)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-copy"
#pragma clang diagnostic ignored "-Winconsistent-missing-override"
#endif
#include "opencv2/ts/ts_gtest.h"
#if defined(__OPENCV_BUILD) && defined(__GNUC__) && __GNUC__ >= 5
//#pragma GCC diagnostic pop
#endif
#if defined(__OPENCV_BUILD) && defined(__clang__) && ((__clang_major__*100 + __clang_minor__) >= 1301)
#pragma clang diagnostic pop
#endif
#include "opencv2/ts/ts_ext.hpp"
#ifndef GTEST_USES_SIMPLE_RE

View File

@ -49,13 +49,13 @@ bool checkBigDataTests();
#undef TEST
#define TEST_(test_case_name, test_name, parent_class, bodyMethodName, BODY_IMPL) \
#define TEST_(test_case_name, test_name, parent_class, bodyMethodName, BODY_ATTR, BODY_IMPL) \
class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public parent_class {\
public:\
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {}\
private:\
virtual void TestBody() CV_OVERRIDE;\
virtual void bodyMethodName();\
virtual void bodyMethodName() BODY_ATTR;\
static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;\
GTEST_DISALLOW_COPY_AND_ASSIGN_(\
GTEST_TEST_CLASS_NAME_(test_case_name, test_name));\
@ -74,7 +74,7 @@ bool checkBigDataTests();
void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() BODY_IMPL( #test_case_name "_" #test_name ) \
void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::bodyMethodName()
#define TEST(test_case_name, test_name) TEST_(test_case_name, test_name, ::testing::Test, Body, CV__TEST_BODY_IMPL)
#define TEST(test_case_name, test_name) TEST_(test_case_name, test_name, ::testing::Test, Body,, CV__TEST_BODY_IMPL)
#define CV__TEST_BIGDATA_BODY_IMPL(name) \
{ \
@ -96,9 +96,9 @@ bool checkBigDataTests();
// Special type of tests which require / use or validate processing of huge amount of data (>= 2Gb)
#if defined(_M_X64) || defined(_M_ARM64) || defined(__x86_64__) || defined(__aarch64__)
#define BIGDATA_TEST(test_case_name, test_name) TEST_(BigData_ ## test_case_name, test_name, ::testing::Test, Body, CV__TEST_BIGDATA_BODY_IMPL)
#define BIGDATA_TEST(test_case_name, test_name) TEST_(BigData_ ## test_case_name, test_name, ::testing::Test, Body,, CV__TEST_BIGDATA_BODY_IMPL)
#else
#define BIGDATA_TEST(test_case_name, test_name) TEST_(BigData_ ## test_case_name, DISABLED_ ## test_name, ::testing::Test, Body, CV__TEST_BIGDATA_BODY_IMPL)
#define BIGDATA_TEST(test_case_name, test_name) TEST_(BigData_ ## test_case_name, DISABLED_ ## test_name, ::testing::Test, Body,, CV__TEST_BIGDATA_BODY_IMPL)
#endif
#undef TEST_F
@ -128,13 +128,13 @@ bool checkBigDataTests();
void GTEST_TEST_CLASS_NAME_(test_fixture, test_name)::Body()
// Don't use directly
#define CV__TEST_P(test_case_name, test_name, bodyMethodName, BODY_IMPL/*(name_str)*/) \
#define CV__TEST_P(test_case_name, test_name, bodyMethodName, BODY_ATTR, BODY_IMPL/*(name_str)*/) \
class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
: public test_case_name { \
public: \
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \
private: \
virtual void bodyMethodName(); \
virtual void bodyMethodName() BODY_ATTR; \
virtual void TestBody() CV_OVERRIDE; \
static int AddToRegistry() { \
::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
@ -160,7 +160,7 @@ bool checkBigDataTests();
void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::bodyMethodName()
#undef TEST_P
#define TEST_P(test_case_name, test_name) CV__TEST_P(test_case_name, test_name, Body, CV__TEST_BODY_IMPL)
#define TEST_P(test_case_name, test_name) CV__TEST_P(test_case_name, test_name, Body,, CV__TEST_BODY_IMPL)
#define CV_TEST_EXPECT_EXCEPTION_MESSAGE(statement, msg) \

View File

@ -551,7 +551,7 @@ void PrintTo(const Size& sz, ::std::ostream* os);
// EXPECT_TRUE(foo.StatusIsOK());
// }
#define PERF_TEST(test_case_name, test_name)\
TEST_(test_case_name, test_name, ::perf::TestBase, PerfTestBody, CV__PERF_TEST_BODY_IMPL)
TEST_(test_case_name, test_name, ::perf::TestBase, PerfTestBody, CV_OVERRIDE, CV__PERF_TEST_BODY_IMPL)
// Defines a performance test that uses a test fixture.
//
@ -595,7 +595,7 @@ void PrintTo(const Size& sz, ::std::ostream* os);
//
// @Note PERF_TEST_P() below violates behavior of original Google Tests - there is no tests instantiation in original TEST_P()
// This macro is intended for usage with separate INSTANTIATE_TEST_CASE_P macro
#define PERF_TEST_P_(test_case_name, test_name) CV__TEST_P(test_case_name, test_name, PerfTestBody, CV__PERF_TEST_BODY_IMPL)
#define PERF_TEST_P_(test_case_name, test_name) CV__TEST_P(test_case_name, test_name, PerfTestBody, CV_OVERRIDE, CV__PERF_TEST_BODY_IMPL)
// Defines a parametrized performance test.
//
@ -628,7 +628,7 @@ void PrintTo(const Size& sz, ::std::ostream* os);
protected:\
virtual void PerfTestBody();\
};\
CV__TEST_P(fixture##_##name, name, PerfTestBodyDummy, CV__PERF_TEST_BODY_IMPL){} \
CV__TEST_P(fixture##_##name, name, PerfTestBodyDummy,, CV__PERF_TEST_BODY_IMPL){} \
INSTANTIATE_TEST_CASE_P(/*none*/, fixture##_##name, params);\
void fixture##_##name::PerfTestBody()

View File

@ -2104,8 +2104,6 @@ struct KeypointComparator
{
return cmp(pts_[idx1], pts_[idx2]);
}
private:
KeypointComparator& operator=(const KeypointComparator&) = delete;
};
}//namespace
@ -2119,7 +2117,8 @@ void perf::sort(std::vector<cv::KeyPoint>& pts, cv::InputOutputArray descriptors
for (int i = 0; i < desc.rows; ++i)
idxs[i] = i;
std::sort(idxs.data(), idxs.data() + desc.rows, KeypointComparator(pts));
comparators::KeypointGreater cmp;
std::sort(idxs.data(), idxs.data() + desc.rows, [&](int lhs, int rhs){ return cmp(pts[lhs], pts[rhs]); });
std::vector<cv::KeyPoint> spts(pts.size());
cv::Mat sdesc(desc.size(), desc.type());

View File

@ -198,7 +198,7 @@ DepthFrameUnpacker::DepthFrameUnpacker(){
outputDataBuf_ = new uint8_t[OUT_DATA_SIZE];
}
DepthFrameUnpacker::~DepthFrameUnpacker(){
DepthFrameUnpacker::~DepthFrameUnpacker() {
delete[] outputDataBuf_;
}

View File

@ -67,7 +67,7 @@ public:
class DepthFrameProcessor: public IFrameProcessor {
public:
DepthFrameProcessor(const OBExtensionParam& parma);
virtual ~DepthFrameProcessor() noexcept;
virtual ~DepthFrameProcessor();
virtual void process(Frame* frame) override;
private:
@ -78,7 +78,7 @@ private:
class DepthFrameUnpacker: public IFrameProcessor {
public:
DepthFrameUnpacker();
virtual ~DepthFrameUnpacker() noexcept;
virtual ~DepthFrameUnpacker();
virtual void process(Frame* frame) override;
private:
const uint32_t OUT_DATA_SIZE = 1280*800*2;

View File

@ -29,7 +29,7 @@ struct Data
bool doTrain(const Mat samples, const Mat responses, Mat &weights, float &shift);
//function finds two points for drawing line (wx = 0)
bool findPointsForLine(const Mat &weights, float shift, Point points[], int width, int height);
bool findPointsForLine(const Mat &weights, float shift, Point points[2], int width, int height);
// function finds cross point of line (wx = 0) and segment ( (y = HEIGHT, 0 <= x <= WIDTH) or (x = WIDTH, 0 <= y <= HEIGHT) )
bool findCrossPointWithBorders(const Mat &weights, float shift, const std::pair<Point,Point> &segment, Point &crossPoint);

View File

@ -157,7 +157,7 @@ static void onMouse(int event, int x, int y, int, void*)
{
for (int i = 0; i < 4; ++i)
{
if ((event == EVENT_LBUTTONDOWN) & ((abs(roi_corners[i].x - x) < 10)) & (abs(roi_corners[i].y - y) < 10))
if ((event == EVENT_LBUTTONDOWN) && ((abs(roi_corners[i].x - x) < 10)) && (abs(roi_corners[i].y - y) < 10))
{
selected_corner_index = i;
dragging = true;