[Libreoffice-commits] core.git: compilerplugins/clang connectivity/source dbaccess/source extensions/source forms/source reportdesign/source sd/source solenv/CompilerTest_compilerplugins_clang.mk svx/source vcl/source xmloff/source

Noel Grandin noel.grandin at collabora.co.uk
Tue Apr 3 12:55:20 UTC 2018


 compilerplugins/clang/dbgunhandledexception.cxx        |  107 +++++++++++++++++
 compilerplugins/clang/test/dbgunhandledexception.cxx   |   37 +++++
 connectivity/source/drivers/hsqldb/HView.cxx           |    2 
 dbaccess/source/core/api/SingleSelectQueryComposer.cxx |    2 
 dbaccess/source/ui/browser/sbagrid.cxx                 |    2 
 dbaccess/source/ui/browser/unodatbr.cxx                |    5 
 dbaccess/source/ui/querydesign/querycontroller.cxx     |    2 
 dbaccess/source/ui/tabledesign/TableController.cxx     |    2 
 extensions/source/propctrlr/formcomponenthandler.cxx   |   18 +-
 forms/source/component/DatabaseForm.cxx                |    2 
 forms/source/component/FormComponent.cxx               |   22 +--
 reportdesign/source/ui/report/propbrw.cxx              |    4 
 sd/source/ui/sidebar/DocumentHelper.cxx                |    2 
 solenv/CompilerTest_compilerplugins_clang.mk           |    1 
 svx/source/fmcomp/gridcell.cxx                         |    2 
 svx/source/fmcomp/gridctrl.cxx                         |    2 
 svx/source/form/fmobjfac.cxx                           |    2 
 vcl/source/control/field2.cxx                          |    1 
 xmloff/source/core/xmlimp.cxx                          |    2 
 xmloff/source/forms/elementexport.cxx                  |    6 
 20 files changed, 182 insertions(+), 41 deletions(-)

New commits:
commit 0e493cae407cca65f58329b3319d9c836cdf5096
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Apr 3 11:56:52 2018 +0200

    new loplugin:dbgunhandledexception
    
    enforce that DBG_UNHANDLED_EXCEPTION is called first in a catch block,
    otherwise it cannot do it's job properly
    
    Change-Id: I906436c6861212c44f8f21552ccbceb54f15c6e1
    Reviewed-on: https://gerrit.libreoffice.org/52303
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/compilerplugins/clang/dbgunhandledexception.cxx b/compilerplugins/clang/dbgunhandledexception.cxx
new file mode 100644
index 000000000000..54b00f57f758
--- /dev/null
+++ b/compilerplugins/clang/dbgunhandledexception.cxx
@@ -0,0 +1,107 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * Based on LLVM/Clang.
+ *
+ * This file is distributed under the University of Illinois Open Source
+ * License. See LICENSE.TXT for details.
+ *
+ */
+
+#include "check.hxx"
+#include "plugin.hxx"
+#include <clang/Lex/Lexer.h>
+#include <fstream>
+#include <set>
+
+namespace loplugin
+{
+/*
+This is a compile check.
+
+Check that DBG_UNHANDLED_EXCEPTION is always the first statement in a catch block, otherwise
+it does not work properly.
+*/
+
+class DbgUnhandledException : public RecursiveASTVisitor<DbgUnhandledException>, public Plugin
+{
+public:
+    explicit DbgUnhandledException(InstantiationData const& data);
+    virtual void run() override;
+    bool VisitCallExpr(CallExpr const* call);
+    bool TraverseCXXCatchStmt(CXXCatchStmt*);
+
+private:
+    CXXCatchStmt const* currCatchStmt = nullptr;
+};
+
+DbgUnhandledException::DbgUnhandledException(const InstantiationData& data)
+    : Plugin(data)
+{
+}
+
+void DbgUnhandledException::run()
+{
+    TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
+}
+
+bool DbgUnhandledException::TraverseCXXCatchStmt(CXXCatchStmt* catchStmt)
+{
+    auto prevCatchStmt = currCatchStmt;
+    currCatchStmt = catchStmt;
+    auto rv = RecursiveASTVisitor::TraverseCXXCatchStmt(catchStmt);
+    currCatchStmt = prevCatchStmt;
+    return rv;
+}
+
+bool DbgUnhandledException::VisitCallExpr(const CallExpr* call)
+{
+    if (ignoreLocation(call))
+        return true;
+    const FunctionDecl* func = call->getDirectCallee();
+    if (!func)
+        return true;
+
+    if (!func->getIdentifier() || func->getName() != "DbgUnhandledException")
+        return true;
+
+    if (!currCatchStmt)
+    {
+        report(DiagnosticsEngine::Warning, "DBG_UNHANDLED_EXCEPTION outside catch block",
+               call->getLocStart());
+        return true;
+    }
+    auto catchBlock = dyn_cast<CompoundStmt>(currCatchStmt->getHandlerBlock());
+    if (!catchBlock)
+    {
+        report(DiagnosticsEngine::Warning,
+               "something wrong with DBG_UNHANDLED_EXCEPTION, no CompoundStmt?",
+               call->getLocStart());
+        return true;
+    }
+    if (catchBlock->size() < 1)
+    {
+        report(DiagnosticsEngine::Warning,
+               "something wrong with DBG_UNHANDLED_EXCEPTION, CompoundStmt size == 0?",
+               call->getLocStart());
+        return true;
+    }
+
+    Stmt const* firstStmt = *catchBlock->body_begin();
+    if (auto exprWithCleanups = dyn_cast<ExprWithCleanups>(firstStmt))
+        firstStmt = exprWithCleanups->getSubExpr();
+    if (firstStmt != call)
+    {
+        report(DiagnosticsEngine::Warning,
+               "DBG_UNHANDLED_EXCEPTION must be first statement in catch block",
+               call->getLocStart());
+    }
+    return true;
+}
+
+static Plugin::Registration<DbgUnhandledException> X("dbgunhandledexception");
+
+} // namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/compilerplugins/clang/test/dbgunhandledexception.cxx b/compilerplugins/clang/test/dbgunhandledexception.cxx
new file mode 100644
index 000000000000..0abaef0dd06d
--- /dev/null
+++ b/compilerplugins/clang/test/dbgunhandledexception.cxx
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/diagnose_ex.h>
+
+void func1();
+
+int main()
+{
+    try
+    {
+        func1();
+    }
+    catch (std::exception const&)
+    {
+        SAL_WARN("xmloff", "message");
+        DBG_UNHANDLED_EXCEPTION(
+            "xmloff",
+            "message"); // expected-error at -2 {{DBG_UNHANDLED_EXCEPTION must be first statement in catch block [loplugin:dbgunhandledexception]}}
+    }
+    try
+    {
+        func1();
+    }
+    catch (std::exception const&)
+    {
+        DBG_UNHANDLED_EXCEPTION("xmloff", "message");
+    }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/connectivity/source/drivers/hsqldb/HView.cxx b/connectivity/source/drivers/hsqldb/HView.cxx
index 10ec3ed7a2e4..bd4e65eca2c4 100644
--- a/connectivity/source/drivers/hsqldb/HView.cxx
+++ b/connectivity/source/drivers/hsqldb/HView.cxx
@@ -130,9 +130,9 @@ namespace connectivity { namespace hsqldb
         }
         catch( const Exception& )
         {
+            DBG_UNHANDLED_EXCEPTION("connectivity.hsqldb");
             if ( bDropSucceeded )
                 xStatement->execute( sRestoreCommand );
-            DBG_UNHANDLED_EXCEPTION("connectivity.hsqldb");
         }
     }
 
diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
index 46f59d6d2c08..9f76150d75ca 100644
--- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -605,8 +605,8 @@ void SAL_CALL OSingleSelectQueryComposer::setElementaryQuery( const OUString& _r
     }
     catch( const Exception& )
     {
-        SAL_WARN("dbaccess", "OSingleSelectQueryComposer::setElementaryQuery: there should be no error anymore for the additive statement!" );
         DBG_UNHANDLED_EXCEPTION("dbaccess");
+        SAL_WARN("dbaccess", "OSingleSelectQueryComposer::setElementaryQuery: there should be no error anymore for the additive statement!" );
         // every part of the additive statement should have passed other tests already, and should not
         // be able to cause any errors ... me thinks
     }
diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx
index 2acfbe8bc341..5556e0f02cc6 100644
--- a/dbaccess/source/ui/browser/sbagrid.cxx
+++ b/dbaccess/source/ui/browser/sbagrid.cxx
@@ -1436,10 +1436,10 @@ IMPL_LINK_NOARG(SbaGridControl, AsynchDropEvent, void*, void)
         }
         catch(const Exception& )
         {
+            DBG_UNHANDLED_EXCEPTION("dbaccess");
             if (m_pMasterListener)
                 m_pMasterListener->AfterDrop();
             Show();
-            DBG_UNHANDLED_EXCEPTION("dbaccess");
         }
         if ( !bCountFinal )
             setDataSource(Reference< XRowSet >(xDataSource,UNO_QUERY));
diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx
index 32e2488b672f..aff8900255e6 100644
--- a/dbaccess/source/ui/browser/unodatbr.cxx
+++ b/dbaccess/source/ui/browser/unodatbr.cxx
@@ -2386,13 +2386,10 @@ bool SbaTableQueryBrowser::implLoadAnything(const OUString& _rDataSourceName, co
     }
     catch( const WrappedTargetException& e )
     {
-        SQLException aSql;
         if  ( e.TargetException.isExtractableTo( ::cppu::UnoType< SQLException >::get() ) )
             showError( SQLExceptionInfo( e.TargetException ) );
         else
-        {
-            DBG_UNHANDLED_EXCEPTION("dbaccess");
-        }
+            SAL_WARN("dbaccess", e);
     }
     catch(const Exception&)
     {
diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx
index a7fa6a8d9fa6..0e02efe02a2a 100644
--- a/dbaccess/source/ui/querydesign/querycontroller.cxx
+++ b/dbaccess/source/ui/querydesign/querycontroller.cxx
@@ -1519,9 +1519,9 @@ bool OQueryController::doSaveAsDoc(bool _bSaveAs)
     }
     catch(const Exception&)
     {
+        DBG_UNHANDLED_EXCEPTION("dbaccess");
         if ( !bNew )
             m_sName = sOriginalName;
-        DBG_UNHANDLED_EXCEPTION("dbaccess");
     }
 
     showError( aInfo );
diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx
index 6662a2a535da..de6d7fef6aa1 100644
--- a/dbaccess/source/ui/tabledesign/TableController.cxx
+++ b/dbaccess/source/ui/tabledesign/TableController.cxx
@@ -411,8 +411,8 @@ bool OTableController::doSaveDoc(bool _bSaveAs)
     }
     catch( const Exception& )
     {
-        bError = true;
         DBG_UNHANDLED_EXCEPTION("dbaccess");
+        bError = true;
     }
 
     if ( aInfo.isValid() )
diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx
index 37db834b8d62..5f94899b054e 100644
--- a/extensions/source/propctrlr/formcomponenthandler.cxx
+++ b/extensions/source/propctrlr/formcomponenthandler.cxx
@@ -1937,8 +1937,8 @@ namespace pcr
         }
         catch( const Exception& )
         {
-            OSL_FAIL( "FormComponentPropertyHandler::impl_updateDependentProperty_nothrow: caught an exception!" );
             DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
+            OSL_FAIL( "FormComponentPropertyHandler::impl_updateDependentProperty_nothrow: caught an exception!" );
         }
     }
 
@@ -2014,8 +2014,8 @@ namespace pcr
         }
         catch( const Exception& )
         {
-            OSL_FAIL( "FormComponentPropertyHandler::onNewComponent: caught an exception!" );
             DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
+            OSL_FAIL( "FormComponentPropertyHandler::onNewComponent: caught an exception!" );
         }
     }
 
@@ -2268,8 +2268,8 @@ namespace pcr
         }
         catch( const Exception& )
         {
-            OSL_FAIL( "FormComponentPropertyHandler::impl_getRowSet_nothrow: caught an exception!" );
             DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
+            OSL_FAIL( "FormComponentPropertyHandler::impl_getRowSet_nothrow: caught an exception!" );
         }
         return xReturn;
     }
@@ -2303,8 +2303,8 @@ namespace pcr
         }
         catch (const Exception&)
         {
-            OSL_FAIL( "FormComponentPropertyHandler::impl_initFieldList_nothrow: caught an exception!" );
             DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
+            OSL_FAIL( "FormComponentPropertyHandler::impl_initFieldList_nothrow: caught an exception!" );
         }
     }
 
@@ -2354,8 +2354,8 @@ namespace pcr
             }
             catch( const Exception& )
             {
-                OSL_FAIL( "FormComponentPropertyHandler::impl_ensureRowsetConnection_nothrow: caught an exception during error handling!" );
                 DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
+                OSL_FAIL( "FormComponentPropertyHandler::impl_ensureRowsetConnection_nothrow: caught an exception during error handling!" );
             }
             // additional info about what happened
             INetURLObject aParser( sDataSourceName );
@@ -2413,8 +2413,8 @@ namespace pcr
         }
         catch (const Exception&)
         {
-            OSL_FAIL("FormComponentPropertyHandler::impl_describeCursorSource_nothrow: caught an exception !");
             DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
+            OSL_FAIL("FormComponentPropertyHandler::impl_describeCursorSource_nothrow: caught an exception !");
         }
     }
 
@@ -2586,8 +2586,8 @@ namespace pcr
         catch (const SQLException& e) { aErrorInfo = e; }
         catch( const Exception& )
         {
-            OSL_FAIL( "FormComponentPropertyHandler::impl_dialogFilterOrSort_nothrow: caught an exception!" );
             DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
+            OSL_FAIL( "FormComponentPropertyHandler::impl_dialogFilterOrSort_nothrow: caught an exception!" );
         }
 
         if ( aErrorInfo.isValid() )
@@ -2681,8 +2681,8 @@ namespace pcr
         }
         catch( const Exception& )
         {
-            OSL_FAIL( "FormComponentPropertyHandler::impl_dialogFormatting_nothrow: : caught an exception!" );
             DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
+            OSL_FAIL( "FormComponentPropertyHandler::impl_dialogFormatting_nothrow: : caught an exception!" );
         }
         return bChanged;
     }
@@ -3196,8 +3196,8 @@ namespace pcr
             }
             catch( const Exception& )
             {
-                OSL_FAIL( "FormComponentPropertyHandler::impl_hasValidDataSourceSignature_nothrow: caught an exception!" );
                 DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
+                OSL_FAIL( "FormComponentPropertyHandler::impl_hasValidDataSourceSignature_nothrow: caught an exception!" );
             }
         }
         return bHas;
diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx
index 0cfb1c72fd97..ceb1cfe8befa 100644
--- a/forms/source/component/DatabaseForm.cxx
+++ b/forms/source/component/DatabaseForm.cxx
@@ -3041,9 +3041,9 @@ bool ODatabaseForm::impl_approveRowChange_throw( const EventObject& _rEvent, con
         }
         catch (const SQLException&)
         {
+            DBG_UNHANDLED_EXCEPTION("forms.component");
             if ( _bAllowSQLException )
                 throw;
-            DBG_UNHANDLED_EXCEPTION("forms.component");
         }
         catch (const Exception&)
         {
diff --git a/forms/source/component/FormComponent.cxx b/forms/source/component/FormComponent.cxx
index 11cfed98d15a..05ed6dc5018d 100644
--- a/forms/source/component/FormComponent.cxx
+++ b/forms/source/component/FormComponent.cxx
@@ -459,8 +459,8 @@ void OControlModel::readHelpTextCompatibly(const css::uno::Reference< css::io::X
     }
     catch(const Exception&)
     {
-        SAL_WARN("forms.component", "OControlModel::readHelpTextCompatibly: could not forward the property value to the aggregate!");
         DBG_UNHANDLED_EXCEPTION("forms.component");
+        SAL_WARN("forms.component", "OControlModel::readHelpTextCompatibly: could not forward the property value to the aggregate!");
     }
 }
 
@@ -474,8 +474,8 @@ void OControlModel::writeHelpTextCompatibly(const css::uno::Reference< css::io::
     }
     catch(const Exception&)
     {
-        SAL_WARN("forms.component", "OControlModel::writeHelpTextCompatibly: could not retrieve the property value from the aggregate!");
         DBG_UNHANDLED_EXCEPTION("forms.component");
+        SAL_WARN("forms.component", "OControlModel::writeHelpTextCompatibly: could not retrieve the property value from the aggregate!");
     }
     ::comphelper::operator<<( _rxOutStream, sHelpText);
 }
@@ -515,8 +515,8 @@ OControlModel::OControlModel(
                 }
                 catch( const Exception& )
                 {
-                    SAL_WARN("forms.component",  "OControlModel::OControlModel: caught an exception!");
                     DBG_UNHANDLED_EXCEPTION("forms.component");
+                    SAL_WARN("forms.component",  "OControlModel::OControlModel: caught an exception!");
                 }
             }
         }
@@ -1805,8 +1805,8 @@ void SAL_CALL OBoundControlModel::propertyChange( const PropertyChangeEvent& evt
 
         catch( const Exception& )
         {
-            SAL_WARN("forms.component",  "OBoundControlModel::propertyChange: could not adjust my binding-controlled property!");
             DBG_UNHANDLED_EXCEPTION("forms.component");
+            SAL_WARN("forms.component",  "OBoundControlModel::propertyChange: could not adjust my binding-controlled property!");
         }
 
     }
@@ -2146,8 +2146,8 @@ void OBoundControlModel::doSetControlValue( const Any& _rValue )
 
     catch( const Exception& )
     {
-        SAL_WARN("forms.component",  "OBoundControlModel::doSetControlValue: caught an exception!");
         DBG_UNHANDLED_EXCEPTION("forms.component");
+        SAL_WARN("forms.component",  "OBoundControlModel::doSetControlValue: caught an exception!");
     }
 }
 
@@ -2167,8 +2167,8 @@ void OBoundControlModel::onConnectedValidator( )
 
     catch( const Exception& )
     {
-        SAL_WARN("forms.component",  "OBoundControlModel::onConnectedValidator: caught an exception!");
         DBG_UNHANDLED_EXCEPTION("forms.component");
+        SAL_WARN("forms.component",  "OBoundControlModel::onConnectedValidator: caught an exception!");
     }
 
     recheckValidity( false );
@@ -2187,8 +2187,8 @@ void OBoundControlModel::onDisconnectedValidator( )
 
     catch( const Exception& )
     {
-        SAL_WARN("forms.component",  "OBoundControlModel::onDisconnectedValidator: caught an exception!");
         DBG_UNHANDLED_EXCEPTION("forms.component");
+        SAL_WARN("forms.component",  "OBoundControlModel::onDisconnectedValidator: caught an exception!");
     }
 
     recheckValidity( false );
@@ -2265,8 +2265,8 @@ void OBoundControlModel::reset()
 
     catch( const SQLException& )
     {
-        SAL_WARN("forms.component",  "OBoundControlModel::reset: caught an SQL exception!" );
         DBG_UNHANDLED_EXCEPTION("forms.component");
+        SAL_WARN("forms.component",  "OBoundControlModel::reset: caught an SQL exception!" );
     }
 
     // #i24495# - don't count the insert row as "invalid"
@@ -2310,8 +2310,8 @@ void OBoundControlModel::reset()
 
         catch(const Exception&)
         {
-            SAL_WARN("forms.component", "OBoundControlModel::reset: this should have succeeded in all cases!");
             DBG_UNHANDLED_EXCEPTION("forms.component");
+            SAL_WARN("forms.component", "OBoundControlModel::reset: this should have succeeded in all cases!");
         }
 
         bool bNeedValueTransfer = true;
@@ -2461,8 +2461,8 @@ void OBoundControlModel::disconnectExternalValueBinding( )
 
     catch( const Exception& )
     {
-        SAL_WARN("forms.component",  "OBoundControlModel::disconnectExternalValueBinding: caught an exception!");
         DBG_UNHANDLED_EXCEPTION("forms.component");
+        SAL_WARN("forms.component",  "OBoundControlModel::disconnectExternalValueBinding: caught an exception!");
     }
 
     // if the binding also acts as our validator, disconnect the validator, too
@@ -2790,8 +2790,8 @@ void OBoundControlModel::recheckValidity( bool _bForceNotification )
 
     catch( const Exception& )
     {
-        SAL_WARN("forms.component",  "OBoundControlModel::recheckValidity: caught an exception!");
         DBG_UNHANDLED_EXCEPTION("forms.component");
+        SAL_WARN("forms.component",  "OBoundControlModel::recheckValidity: caught an exception!");
     }
 }
 
diff --git a/reportdesign/source/ui/report/propbrw.cxx b/reportdesign/source/ui/report/propbrw.cxx
index 2f671b5872e6..e8f17e035c2e 100644
--- a/reportdesign/source/ui/report/propbrw.cxx
+++ b/reportdesign/source/ui/report/propbrw.cxx
@@ -108,8 +108,8 @@ PropBrw::PropBrw(const Reference< XComponentContext >& _xORB, vcl::Window* pPare
     }
     catch (Exception&)
     {
-        OSL_FAIL("PropBrw::PropBrw: could not create/initialize my frame!");
         DBG_UNHANDLED_EXCEPTION("reportdesign");
+        OSL_FAIL("PropBrw::PropBrw: could not create/initialize my frame!");
         m_xMeAsFrame.clear();
     }
 
@@ -153,8 +153,8 @@ PropBrw::PropBrw(const Reference< XComponentContext >& _xORB, vcl::Window* pPare
         }
         catch (Exception&)
         {
-            OSL_FAIL("PropBrw::PropBrw: could not create/initialize the browser controller!");
             DBG_UNHANDLED_EXCEPTION("reportdesign");
+            OSL_FAIL("PropBrw::PropBrw: could not create/initialize the browser controller!");
             try
             {
                 ::comphelper::disposeComponent(m_xBrowserController);
diff --git a/sd/source/ui/sidebar/DocumentHelper.cxx b/sd/source/ui/sidebar/DocumentHelper.cxx
index b7b3519bfaa4..dc76d90a4777 100644
--- a/sd/source/ui/sidebar/DocumentHelper.cxx
+++ b/sd/source/ui/sidebar/DocumentHelper.cxx
@@ -229,8 +229,8 @@ SdPage* DocumentHelper::AddMasterPage (
         }
         catch(const uno::Exception&)
         {
-            pClonedMasterPage = nullptr;
             DBG_UNHANDLED_EXCEPTION("sd");
+            pClonedMasterPage = nullptr;
         }
         catch(const ::std::exception& e)
         {
diff --git a/solenv/CompilerTest_compilerplugins_clang.mk b/solenv/CompilerTest_compilerplugins_clang.mk
index 5187f60beb2f..17866e52781f 100644
--- a/solenv/CompilerTest_compilerplugins_clang.mk
+++ b/solenv/CompilerTest_compilerplugins_clang.mk
@@ -19,6 +19,7 @@ $(eval $(call gb_CompilerTest_add_exception_objects,compilerplugins_clang, \
     compilerplugins/clang/test/cppunitassertequals \
     compilerplugins/clang/test/cstylecast \
     compilerplugins/clang/test/datamembershadow \
+    compilerplugins/clang/test/dbgunhandledexception \
     compilerplugins/clang/test/dodgyswitch \
     compilerplugins/clang/test/doubleconvert \
     compilerplugins/clang/test/emptyif \
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index d5edb7c1ff5f..feb3c3fb9b23 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -1094,8 +1094,8 @@ void DbTextField::Init( vcl::Window& rParent, const Reference< XRowSet >& xCurso
     }
     catch( const Exception& )
     {
-        OSL_FAIL( "DbTextField::Init: caught an exception while determining the multi-line capabilities!" );
         DBG_UNHANDLED_EXCEPTION("svx");
+        OSL_FAIL( "DbTextField::Init: caught an exception while determining the multi-line capabilities!" );
     }
 
     m_bIsSimpleEdit = !bIsMultiLine;
diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx
index ba4cff36d95e..8093bddd31b9 100644
--- a/svx/source/fmcomp/gridctrl.cxx
+++ b/svx/source/fmcomp/gridctrl.cxx
@@ -2440,8 +2440,8 @@ bool DbGridControl::SeekCursor(long nRow, bool bAbsolute)
         }
         catch(Exception&)
         {
-            OSL_FAIL("DbGridControl::SeekCursor : failed ...");
             DBG_UNHANDLED_EXCEPTION("svx");
+            OSL_FAIL("DbGridControl::SeekCursor : failed ...");
             m_nSeekPos = -1; // no further data set available
         }
     }
diff --git a/svx/source/form/fmobjfac.cxx b/svx/source/form/fmobjfac.cxx
index d0169efd51c8..bfc834e9cd1a 100644
--- a/svx/source/form/fmobjfac.cxx
+++ b/svx/source/form/fmobjfac.cxx
@@ -100,8 +100,8 @@ namespace
         }
         catch( const Exception& )
         {
-            OSL_FAIL( "lcl_initProperty: caught an exception!" );
             DBG_UNHANDLED_EXCEPTION("svx");
+            OSL_FAIL( "lcl_initProperty: caught an exception!" );
         }
     }
 }
diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx
index e05960b660f0..c57449aec148 100644
--- a/vcl/source/control/field2.cxx
+++ b/vcl/source/control/field2.cxx
@@ -161,7 +161,6 @@ static bool ImplIsPatternChar( sal_Unicode cChar, sal_Char cEditMask )
     }
     catch (const css::uno::Exception&)
     {
-        SAL_WARN( "vcl.control", "ImplIsPatternChar: Exception caught!" );
         DBG_UNHANDLED_EXCEPTION("vcl.control");
         return false;
     }
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index a2baf499cabd..6adabad9bb6e 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -1593,7 +1593,7 @@ void SvXMLImport::AddNumberStyle(sal_Int32 nKey, const OUString& rName)
         }
     }
     else {
-        DBG_UNHANDLED_EXCEPTION( "xmloff.core", "not possible to create NameContainer");
+        SAL_WARN( "xmloff.core", "not possible to create NameContainer");
     }
 }
 
diff --git a/xmloff/source/forms/elementexport.cxx b/xmloff/source/forms/elementexport.cxx
index b846ac745732..3ba0762e9623 100644
--- a/xmloff/source/forms/elementexport.cxx
+++ b/xmloff/source/forms/elementexport.cxx
@@ -1796,8 +1796,8 @@ namespace xmloff
         }
         catch( const Exception& )
         {
-            OSL_FAIL( "OControlExport::exportCellBindingAttributes: caught an exception!" );
             DBG_UNHANDLED_EXCEPTION("xmloff.forms");
+            OSL_FAIL( "OControlExport::exportCellBindingAttributes: caught an exception!" );
         }
     }
 
@@ -1838,8 +1838,8 @@ namespace xmloff
         }
         catch( const Exception& )
         {
-            OSL_FAIL( "OControlExport::exportCellListSourceRange: caught an exception!" );
             DBG_UNHANDLED_EXCEPTION("xmloff.forms");
+            OSL_FAIL( "OControlExport::exportCellListSourceRange: caught an exception!" );
         }
     }
 
@@ -1911,8 +1911,8 @@ namespace xmloff
         }
         catch( const Exception& )
         {
-            OSL_FAIL( "OColumnExport::controlHasActiveDataBinding: caught an exception!" );
             DBG_UNHANDLED_EXCEPTION("xmloff.forms");
+            OSL_FAIL( "OColumnExport::controlHasActiveDataBinding: caught an exception!" );
         }
 
         return false;


More information about the Libreoffice-commits mailing list