Merge pull request #11392 from alalek:master_drop_errorNoReturn

pull/11411/merge
Alexander Alekhin 7 years ago
commit 84b3b5b4a4
  1. 2
      modules/core/include/opencv2/core.hpp
  2. 51
      modules/core/include/opencv2/core/base.hpp
  3. 12
      modules/core/src/check.cpp
  4. 2
      modules/core/src/opengl.cpp
  5. 2
      modules/core/src/persistence.cpp
  6. 27
      modules/core/src/system.cpp
  7. 4
      modules/dnn/include/opencv2/dnn/dnn.inl.hpp
  8. 2
      modules/highgui/src/window.cpp

@ -144,7 +144,7 @@ It is possible to alternate error processing by using #redirectError().
@param exc the exception raisen.
@deprecated drop this version
*/
CV_EXPORTS void error( const Exception& exc );
CV_EXPORTS CV_NORETURN void error(const Exception& exc);
enum SortFlags { SORT_EVERY_ROW = 0, //!< each matrix row is sorted independently
SORT_EVERY_COLUMN = 1, //!< each matrix column is sorted

@ -373,32 +373,7 @@ It is possible to alternate error processing by using redirectError().
@param _line - line number in the source file where the error has occurred
@see CV_Error, CV_Error_, CV_Assert, CV_DbgAssert
*/
CV_EXPORTS void error(int _code, const String& _err, const char* _func, const char* _file, int _line);
#ifdef __GNUC__
# if defined __clang__ || defined __APPLE__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Winvalid-noreturn"
# endif
#endif
/** same as cv::error, but does not return */
CV_INLINE CV_NORETURN void errorNoReturn(int _code, const String& _err, const char* _func, const char* _file, int _line)
{
error(_code, _err, _func, _file, _line);
#ifdef __GNUC__
# if !defined __clang__ && !defined __APPLE__
// this suppresses this warning: "noreturn" function does return [enabled by default]
__builtin_trap();
// or use infinite loop: for (;;) {}
# endif
#endif
}
#ifdef __GNUC__
# if defined __clang__ || defined __APPLE__
# pragma GCC diagnostic pop
# endif
#endif
CV_EXPORTS CV_NORETURN void error(int _code, const String& _err, const char* _func, const char* _file, int _line);
#if defined __GNUC__
#define CV_Func __func__
@ -446,25 +421,19 @@ for example:
#define CV_Assert_1( expr ) if(!!(expr)) ; else cv::error( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ )
#endif // CV_STATIC_ANALYSIS
//! @cond IGNORED
#define CV__ErrorNoReturn( code, msg ) cv::errorNoReturn( code, msg, CV_Func, __FILE__, __LINE__ )
#define CV__ErrorNoReturn_( code, args ) cv::errorNoReturn( code, cv::format args, CV_Func, __FILE__, __LINE__ )
#ifdef __OPENCV_BUILD
#undef CV_Error
#define CV_Error CV__ErrorNoReturn
#undef CV_Error_
#define CV_Error_ CV__ErrorNoReturn_
#undef CV_Assert_1
#define CV_Assert_1( expr ) if(!!(expr)) ; else cv::errorNoReturn( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ )
#else
// backward compatibility
#define CV_ErrorNoReturn CV__ErrorNoReturn
#define CV_ErrorNoReturn_ CV__ErrorNoReturn_
#if !defined(__OPENCV_BUILD) // TODO: backward compatibility only
#ifndef CV_ErrorNoReturn
#define CV_ErrorNoReturn CV_Error
#endif
#ifndef CV_ErrorNoReturn_
#define CV_ErrorNoReturn_ CV_Error_
#endif
#endif
//! @endcond
#endif // CV_STATIC_ANALYSIS
#define CV_Assert_2( expr1, expr2 ) CV_Assert_1(expr1); CV_Assert_1(expr2)
#define CV_Assert_3( expr1, expr2, expr3 ) CV_Assert_2(expr1, expr2); CV_Assert_1(expr3)
#define CV_Assert_4( expr1, expr2, expr3, expr4 ) CV_Assert_3(expr1, expr2, expr3); CV_Assert_1(expr4)

@ -67,7 +67,7 @@ void check_failed_auto_(const T& v1, const T& v2, const CheckContext& ctx)
ss << "must be " << getTestOpPhraseStr(ctx.testOp) << std::endl;
}
ss << " '" << ctx.p2_str << "' is " << v2;
cv::errorNoReturn(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
}
void check_failed_MatDepth(const int v1, const int v2, const CheckContext& ctx)
{
@ -79,7 +79,7 @@ void check_failed_MatDepth(const int v1, const int v2, const CheckContext& ctx)
ss << "must be " << getTestOpPhraseStr(ctx.testOp) << std::endl;
}
ss << " '" << ctx.p2_str << "' is " << v2 << " (" << depthToString(v2) << ")";
cv::errorNoReturn(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
}
void check_failed_MatType(const int v1, const int v2, const CheckContext& ctx)
{
@ -91,7 +91,7 @@ void check_failed_MatType(const int v1, const int v2, const CheckContext& ctx)
ss << "must be " << getTestOpPhraseStr(ctx.testOp) << std::endl;
}
ss << " '" << ctx.p2_str << "' is " << v2 << " (" << typeToString(v2) << ")";
cv::errorNoReturn(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
}
void check_failed_MatChannels(const int v1, const int v2, const CheckContext& ctx)
{
@ -119,7 +119,7 @@ void check_failed_auto_(const T& v, const CheckContext& ctx)
<< " '" << ctx.p2_str << "'" << std::endl
<< "where" << std::endl
<< " '" << ctx.p1_str << "' is " << v;
cv::errorNoReturn(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
}
void check_failed_MatDepth(const int v, const CheckContext& ctx)
{
@ -128,7 +128,7 @@ void check_failed_MatDepth(const int v, const CheckContext& ctx)
<< " '" << ctx.p2_str << "'" << std::endl
<< "where" << std::endl
<< " '" << ctx.p1_str << "' is " << v << " (" << depthToString(v) << ")";
cv::errorNoReturn(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
}
void check_failed_MatType(const int v, const CheckContext& ctx)
{
@ -137,7 +137,7 @@ void check_failed_MatType(const int v, const CheckContext& ctx)
<< " '" << ctx.p2_str << "'" << std::endl
<< "where" << std::endl
<< " '" << ctx.p1_str << "' is " << v << " (" << typeToString(v) << ")";
cv::errorNoReturn(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
cv::error(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
}
void check_failed_MatChannels(const int v, const CheckContext& ctx)
{

@ -82,7 +82,7 @@ inline static bool checkError(const char* file, const int line, const char* func
default:
msg = "Unknown error";
};
cv::errorNoReturn(Error::OpenGlApiCallError, func, msg, file, line);
cv::error(Error::OpenGlApiCallError, func, msg, file, line);
}
return true;
}

@ -149,7 +149,7 @@ void icvParseError( CvFileStorage* fs, const char* func_name,
const char* err_msg, const char* source_file, int source_line )
{
cv::String msg = cv::format("%s(%d): %s", fs->filename, fs->lineno, err_msg);
cv::errorNoReturn(cv::Error::StsParseError, func_name, msg.c_str(), source_file, source_line );
cv::error(cv::Error::StsParseError, func_name, msg.c_str(), source_file, source_line );
}
void icvFSCreateCollection( CvFileStorage* fs, int tag, CvFileNode* collection )

@ -970,6 +970,13 @@ static void cv_terminate_handler() {
#endif
#ifdef __GNUC__
# if defined __clang__ || defined __APPLE__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Winvalid-noreturn"
# endif
#endif
void error( const Exception& exc )
{
#ifdef CV_ERROR_SET_TERMINATE_HANDLER
@ -1000,13 +1007,33 @@ void error( const Exception& exc )
}
CV_THROW(exc);
#ifdef __GNUC__
# if !defined __clang__ && !defined __APPLE__
// this suppresses this warning: "noreturn" function does return [enabled by default]
__builtin_trap();
// or use infinite loop: for (;;) {}
# endif
#endif
}
void error(int _code, const String& _err, const char* _func, const char* _file, int _line)
{
error(cv::Exception(_code, _err, _func, _file, _line));
#ifdef __GNUC__
# if !defined __clang__ && !defined __APPLE__
// this suppresses this warning: "noreturn" function does return [enabled by default]
__builtin_trap();
// or use infinite loop: for (;;) {}
# endif
#endif
}
#ifdef __GNUC__
# if defined __clang__ || defined __APPLE__
# pragma GCC diagnostic pop
# endif
#endif
ErrorCallback
redirectError( ErrorCallback errCallback, void* userdata, void** prevUserdata)

@ -274,11 +274,7 @@ inline int DictValue::size() const
case Param::REAL:
return (int)pd->size();
}
#ifdef __OPENCV_BUILD
CV_Error(Error::StsInternal, "");
#else
CV_ErrorNoReturn(Error::StsInternal, "");
#endif
}
inline std::ostream &operator<<(std::ostream &stream, const DictValue &dictv)

@ -603,7 +603,7 @@ void cv::setWindowTitle(const String&, const String&)
}
#define CV_NO_GUI_ERROR(funcname) \
cv::errorNoReturn(cv::Error::StsError, \
cv::error(cv::Error::StsError, \
"The function is not implemented. " \
"Rebuild the library with Windows, GTK+ 2.x or Carbon support. "\
"If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script", \

Loading…
Cancel
Save