From 42ca6e53291e975555cc9cd5ecff25bfea556d7e Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 11 Apr 2018 09:05:06 +0100 Subject: coverity#1401328 silence Uncaught exception MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit and a bunch more Change-Id: Icdd195d1ddfc0259743892097a65c07277d53fd9 Reviewed-on: https://gerrit.libreoffice.org/52711 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- include/tools/diagnose_ex.h | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/tools/diagnose_ex.h b/include/tools/diagnose_ex.h index 31c2b376baa2..9c18d5f51ad4 100644 --- a/include/tools/diagnose_ex.h +++ b/include/tools/diagnose_ex.h @@ -33,6 +33,24 @@ TOOLS_DLLPUBLIC void DbgUnhandledException(const css::uno::Any& caughtException, const char* currentFunction, const char* fileAndLineNo, const char* area = nullptr, const char* explanatory = nullptr); +//getCaughtException throws exceptions in never-going-to-happen situations which +//floods coverity with warnings +inline css::uno::Any DbgGetCaughtException() +{ +#if defined(__COVERITY__) + try + { + return ::cppu::getCaughtException(); + } + catch (...) + { + std::abort(); + } +#else + return ::cppu::getCaughtException(); +#endif +} + /** reports a caught UNO exception via OSL diagnostics Note that whenever you use this, it might be an indicator that your error @@ -40,11 +58,11 @@ TOOLS_DLLPUBLIC void DbgUnhandledException(const css::uno::Any& caughtException, This takes two optional parameters: area and explanatory */ #define DBG_UNHANDLED_EXCEPTION_0_ARGS() \ - DbgUnhandledException( ::cppu::getCaughtException(), OSL_THIS_FUNC, SAL_DETAIL_WHERE ); + DbgUnhandledException( DbgGetCaughtException(), OSL_THIS_FUNC, SAL_DETAIL_WHERE ); #define DBG_UNHANDLED_EXCEPTION_1_ARGS(area) \ - DbgUnhandledException( ::cppu::getCaughtException(), OSL_THIS_FUNC, SAL_DETAIL_WHERE, area ); + DbgUnhandledException( DbgGetCaughtException(), OSL_THIS_FUNC, SAL_DETAIL_WHERE, area ); #define DBG_UNHANDLED_EXCEPTION_2_ARGS(area, explanatory) \ - DbgUnhandledException( ::cppu::getCaughtException(), OSL_THIS_FUNC, SAL_DETAIL_WHERE, area, explanatory ); + DbgUnhandledException( DbgGetCaughtException(), OSL_THIS_FUNC, SAL_DETAIL_WHERE, area, explanatory ); #define DBG_UNHANDLED_FUNC_CHOOSER(_f1, _f2, _f3, ...) _f3 #define DBG_UNHANDLED_FUNC_RECOMPOSER(argsWithParentheses) DBG_UNHANDLED_FUNC_CHOOSER argsWithParentheses -- cgit