Skip to content

Commit 4e83f4c

Browse files
committed
core: drop cv::errorNoReturn()
replaced to cv::error()
1 parent cd2b188 commit 4e83f4c

File tree

8 files changed

+47
-55
lines changed

8 files changed

+47
-55
lines changed

modules/core/include/opencv2/core.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ It is possible to alternate error processing by using #redirectError().
144144
@param exc the exception raisen.
145145
@deprecated drop this version
146146
*/
147-
CV_EXPORTS void error( const Exception& exc );
147+
CV_EXPORTS CV_NORETURN void error(const Exception& exc);
148148

149149
enum SortFlags { SORT_EVERY_ROW = 0, //!< each matrix row is sorted independently
150150
SORT_EVERY_COLUMN = 1, //!< each matrix column is sorted

modules/core/include/opencv2/core/base.hpp

Lines changed: 10 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -373,32 +373,7 @@ It is possible to alternate error processing by using redirectError().
373373
@param _line - line number in the source file where the error has occurred
374374
@see CV_Error, CV_Error_, CV_Assert, CV_DbgAssert
375375
*/
376-
CV_EXPORTS void error(int _code, const String& _err, const char* _func, const char* _file, int _line);
377-
378-
#ifdef __GNUC__
379-
# if defined __clang__ || defined __APPLE__
380-
# pragma GCC diagnostic push
381-
# pragma GCC diagnostic ignored "-Winvalid-noreturn"
382-
# endif
383-
#endif
384-
385-
/** same as cv::error, but does not return */
386-
CV_INLINE CV_NORETURN void errorNoReturn(int _code, const String& _err, const char* _func, const char* _file, int _line)
387-
{
388-
error(_code, _err, _func, _file, _line);
389-
#ifdef __GNUC__
390-
# if !defined __clang__ && !defined __APPLE__
391-
// this suppresses this warning: "noreturn" function does return [enabled by default]
392-
__builtin_trap();
393-
// or use infinite loop: for (;;) {}
394-
# endif
395-
#endif
396-
}
397-
#ifdef __GNUC__
398-
# if defined __clang__ || defined __APPLE__
399-
# pragma GCC diagnostic pop
400-
# endif
401-
#endif
376+
CV_EXPORTS CV_NORETURN void error(int _code, const String& _err, const char* _func, const char* _file, int _line);
402377

403378
#if defined __GNUC__
404379
#define CV_Func __func__
@@ -446,25 +421,19 @@ for example:
446421

447422
#define CV_Assert_1( expr ) if(!!(expr)) ; else cv::error( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ )
448423

424+
#endif // CV_STATIC_ANALYSIS
425+
449426
//! @cond IGNORED
450-
#define CV__ErrorNoReturn( code, msg ) cv::errorNoReturn( code, msg, CV_Func, __FILE__, __LINE__ )
451-
#define CV__ErrorNoReturn_( code, args ) cv::errorNoReturn( code, cv::format args, CV_Func, __FILE__, __LINE__ )
452-
#ifdef __OPENCV_BUILD
453-
#undef CV_Error
454-
#define CV_Error CV__ErrorNoReturn
455-
#undef CV_Error_
456-
#define CV_Error_ CV__ErrorNoReturn_
457-
#undef CV_Assert_1
458-
#define CV_Assert_1( expr ) if(!!(expr)) ; else cv::errorNoReturn( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ )
459-
#else
460-
// backward compatibility
461-
#define CV_ErrorNoReturn CV__ErrorNoReturn
462-
#define CV_ErrorNoReturn_ CV__ErrorNoReturn_
427+
#if !defined(__OPENCV_BUILD) // TODO: backward compatibility only
428+
#ifndef CV_ErrorNoReturn
429+
#define CV_ErrorNoReturn CV_Error
430+
#endif
431+
#ifndef CV_ErrorNoReturn_
432+
#define CV_ErrorNoReturn_ CV_Error_
433+
#endif
463434
#endif
464435
//! @endcond
465436

466-
#endif // CV_STATIC_ANALYSIS
467-
468437
#define CV_Assert_2( expr1, expr2 ) CV_Assert_1(expr1); CV_Assert_1(expr2)
469438
#define CV_Assert_3( expr1, expr2, expr3 ) CV_Assert_2(expr1, expr2); CV_Assert_1(expr3)
470439
#define CV_Assert_4( expr1, expr2, expr3, expr4 ) CV_Assert_3(expr1, expr2, expr3); CV_Assert_1(expr4)

modules/core/src/check.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void check_failed_auto_(const T& v1, const T& v2, const CheckContext& ctx)
6767
ss << "must be " << getTestOpPhraseStr(ctx.testOp) << std::endl;
6868
}
6969
ss << " '" << ctx.p2_str << "' is " << v2;
70-
cv::errorNoReturn(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
70+
cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
7171
}
7272
void check_failed_MatDepth(const int v1, const int v2, const CheckContext& ctx)
7373
{
@@ -79,7 +79,7 @@ void check_failed_MatDepth(const int v1, const int v2, const CheckContext& ctx)
7979
ss << "must be " << getTestOpPhraseStr(ctx.testOp) << std::endl;
8080
}
8181
ss << " '" << ctx.p2_str << "' is " << v2 << " (" << depthToString(v2) << ")";
82-
cv::errorNoReturn(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
82+
cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
8383
}
8484
void check_failed_MatType(const int v1, const int v2, const CheckContext& ctx)
8585
{
@@ -91,7 +91,7 @@ void check_failed_MatType(const int v1, const int v2, const CheckContext& ctx)
9191
ss << "must be " << getTestOpPhraseStr(ctx.testOp) << std::endl;
9292
}
9393
ss << " '" << ctx.p2_str << "' is " << v2 << " (" << typeToString(v2) << ")";
94-
cv::errorNoReturn(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
94+
cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
9595
}
9696
void check_failed_MatChannels(const int v1, const int v2, const CheckContext& ctx)
9797
{
@@ -119,7 +119,7 @@ void check_failed_auto_(const T& v, const CheckContext& ctx)
119119
<< " '" << ctx.p2_str << "'" << std::endl
120120
<< "where" << std::endl
121121
<< " '" << ctx.p1_str << "' is " << v;
122-
cv::errorNoReturn(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
122+
cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
123123
}
124124
void check_failed_MatDepth(const int v, const CheckContext& ctx)
125125
{
@@ -128,7 +128,7 @@ void check_failed_MatDepth(const int v, const CheckContext& ctx)
128128
<< " '" << ctx.p2_str << "'" << std::endl
129129
<< "where" << std::endl
130130
<< " '" << ctx.p1_str << "' is " << v << " (" << depthToString(v) << ")";
131-
cv::errorNoReturn(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
131+
cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
132132
}
133133
void check_failed_MatType(const int v, const CheckContext& ctx)
134134
{
@@ -137,7 +137,7 @@ void check_failed_MatType(const int v, const CheckContext& ctx)
137137
<< " '" << ctx.p2_str << "'" << std::endl
138138
<< "where" << std::endl
139139
<< " '" << ctx.p1_str << "' is " << v << " (" << typeToString(v) << ")";
140-
cv::errorNoReturn(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
140+
cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
141141
}
142142
void check_failed_MatChannels(const int v, const CheckContext& ctx)
143143
{

modules/core/src/opengl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ inline static bool checkError(const char* file, const int line, const char* func
8282
default:
8383
msg = "Unknown error";
8484
};
85-
cv::errorNoReturn(Error::OpenGlApiCallError, func, msg, file, line);
85+
cv::error(Error::OpenGlApiCallError, func, msg, file, line);
8686
}
8787
return true;
8888
}

modules/core/src/persistence.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void icvParseError( CvFileStorage* fs, const char* func_name,
149149
const char* err_msg, const char* source_file, int source_line )
150150
{
151151
cv::String msg = cv::format("%s(%d): %s", fs->filename, fs->lineno, err_msg);
152-
cv::errorNoReturn(cv::Error::StsParseError, func_name, msg.c_str(), source_file, source_line );
152+
cv::error(cv::Error::StsParseError, func_name, msg.c_str(), source_file, source_line );
153153
}
154154

155155
void icvFSCreateCollection( CvFileStorage* fs, int tag, CvFileNode* collection )

modules/core/src/system.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,13 @@ static void cv_terminate_handler() {
970970

971971
#endif
972972

973+
#ifdef __GNUC__
974+
# if defined __clang__ || defined __APPLE__
975+
# pragma GCC diagnostic push
976+
# pragma GCC diagnostic ignored "-Winvalid-noreturn"
977+
# endif
978+
#endif
979+
973980
void error( const Exception& exc )
974981
{
975982
#ifdef CV_ERROR_SET_TERMINATE_HANDLER
@@ -1000,13 +1007,33 @@ void error( const Exception& exc )
10001007
}
10011008

10021009
CV_THROW(exc);
1010+
#ifdef __GNUC__
1011+
# if !defined __clang__ && !defined __APPLE__
1012+
// this suppresses this warning: "noreturn" function does return [enabled by default]
1013+
__builtin_trap();
1014+
// or use infinite loop: for (;;) {}
1015+
# endif
1016+
#endif
10031017
}
10041018

10051019
void error(int _code, const String& _err, const char* _func, const char* _file, int _line)
10061020
{
10071021
error(cv::Exception(_code, _err, _func, _file, _line));
1022+
#ifdef __GNUC__
1023+
# if !defined __clang__ && !defined __APPLE__
1024+
// this suppresses this warning: "noreturn" function does return [enabled by default]
1025+
__builtin_trap();
1026+
// or use infinite loop: for (;;) {}
1027+
# endif
1028+
#endif
10081029
}
10091030

1031+
#ifdef __GNUC__
1032+
# if defined __clang__ || defined __APPLE__
1033+
# pragma GCC diagnostic pop
1034+
# endif
1035+
#endif
1036+
10101037

10111038
ErrorCallback
10121039
redirectError( ErrorCallback errCallback, void* userdata, void** prevUserdata)

modules/dnn/include/opencv2/dnn/dnn.inl.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,7 @@ inline int DictValue::size() const
274274
case Param::REAL:
275275
return (int)pd->size();
276276
}
277-
#ifdef __OPENCV_BUILD
278277
CV_Error(Error::StsInternal, "");
279-
#else
280-
CV_ErrorNoReturn(Error::StsInternal, "");
281-
#endif
282278
}
283279

284280
inline std::ostream &operator<<(std::ostream &stream, const DictValue &dictv)

modules/highgui/src/window.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ void cv::setWindowTitle(const String&, const String&)
603603
}
604604

605605
#define CV_NO_GUI_ERROR(funcname) \
606-
cv::errorNoReturn(cv::Error::StsError, \
606+
cv::error(cv::Error::StsError, \
607607
"The function is not implemented. " \
608608
"Rebuild the library with Windows, GTK+ 2.x or Carbon support. "\
609609
"If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script", \

0 commit comments

Comments
 (0)