[Libreoffice-commits] core.git: 5 commits - connectivity/source include/sal scaddins/source svx/source ucbhelper/source
Tor Lillqvist
tml at collabora.com
Wed Sep 4 05:07:12 PDT 2013
connectivity/source/commontools/BlobHelper.cxx | 13 ++-
connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx | 36 ++++------
connectivity/source/sdbcx/VUser.cxx | 10 +-
include/sal/types.h | 28 +++++++
scaddins/source/analysis/analysishelper.cxx | 10 +-
scaddins/source/analysis/financial.cxx | 31 +++-----
svx/source/form/fmdmod.cxx | 8 ++
ucbhelper/source/client/content.cxx | 7 +
8 files changed, 88 insertions(+), 55 deletions(-)
New commits:
commit d868e2d2e38ee8f0a1427dd2de5c0fc547b28506
Author: Tor Lillqvist <tml at collabora.com>
Date: Wed Sep 4 14:59:02 2013 +0300
WaE: Unreachable code: Use SAL_WNOUNREACHABLE_CODE_PUSH/POP
Cleaner than my first attempt.
This reverts commit 9c0ba0ba41cb3b814cc8bf7a33abf1245d4b241e.
Change-Id: Iec9da427ab2a92cb0765f73af14d83a37f765290
diff --git a/ucbhelper/source/client/content.cxx b/ucbhelper/source/client/content.cxx
index 850f56e..e36207b 100644
--- a/ucbhelper/source/client/content.cxx
+++ b/ucbhelper/source/client/content.cxx
@@ -1057,6 +1057,9 @@ sal_Bool Content::isFolder()
}
//=========================================================================
+
+SAL_WNOUNREACHABLE_CODE_PUSH
+
sal_Bool Content::isDocument()
throw( CommandAbortedException, RuntimeException, Exception )
{
@@ -1072,13 +1075,13 @@ sal_Bool Content::isDocument()
get() ) ),
m_xImpl->getEnvironment() );
-#if !(defined(_MSC_VER) && defined(ENABLE_LTO))
// Unreachable - cancelCommandExecution always throws an exception,
// But some compilers complain...
return sal_False;
-#endif
}
+SAL_WNOUNREACHABLE_CODE_POP
+
//=========================================================================
//=========================================================================
//
commit 5326020f85b67faab34bca5c605b6070c6c4bef0
Author: Tor Lillqvist <tml at collabora.com>
Date: Wed Sep 4 14:39:05 2013 +0300
WaE: Unreachable code: Use SAL_WNOUNREACHABLE_CODE_PUSH/POP
Cleaner than my first attempt.
This reverts commit aa4868de78b3a3893722f7a079f4d05e18abd8db.
Change-Id: I9c92be72e69292731983a53fc2de29ba333071c9
diff --git a/connectivity/source/commontools/BlobHelper.cxx b/connectivity/source/commontools/BlobHelper.cxx
index 5135072..fff3e09 100644
--- a/connectivity/source/commontools/BlobHelper.cxx
+++ b/connectivity/source/commontools/BlobHelper.cxx
@@ -46,20 +46,25 @@ BlobHelper::BlobHelper(const ::com::sun::star::uno::Sequence< sal_Int8 >& _val)
return new ::comphelper::SequenceInputStream(m_aValue);
}
// -----------------------------------------------------------------------------
+
+// The "return" after a call to throwFeatureNotImplementedException()
+// (which always throws) will be detected as unreachable when doing
+// global inlining.
+
+SAL_WNOUNREACHABLE_CODE_PUSH
+
::sal_Int64 SAL_CALL BlobHelper::position( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& /*pattern*/, ::sal_Int64 /*start*/ ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
::dbtools::throwFeatureNotImplementedException( "XBlob::position", *this );
-#if !(defined(_MSC_VER) && defined(ENABLE_LTO))
return 0;
-#endif
}
// -----------------------------------------------------------------------------
::sal_Int64 SAL_CALL BlobHelper::positionOfBlob( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& /*pattern*/, ::sal_Int64 /*start*/ ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
::dbtools::throwFeatureNotImplementedException( "XBlob::positionOfBlob", *this );
-#if !(defined(_MSC_VER) && defined(ENABLE_LTO))
return 0;
-#endif
}
+SAL_WNOUNREACHABLE_CODE_POP
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx
index 7ebd380..6217626 100644
--- a/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx
+++ b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx
@@ -323,21 +323,23 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isAfterLast( ) throw(SQLException
return m_bEOF;
}
// -------------------------------------------------------------------------
+
+SAL_WNOUNREACHABLE_CODE_PUSH
+
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isFirst( ) throw(SQLException, RuntimeException)
{
::dbtools::throwFunctionSequenceException(*this);
-#if !(defined(_MSC_VER) && defined(ENABLE_LTO))
return sal_False;
-#endif
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isLast( ) throw(SQLException, RuntimeException)
{
::dbtools::throwFunctionSequenceException(*this);
-#if !(defined(_MSC_VER) && defined(ENABLE_LTO))
return sal_False;
-#endif
}
+
+SAL_WNOUNREACHABLE_CODE_POP
+
// -------------------------------------------------------------------------
void SAL_CALL ODatabaseMetaDataResultSet::beforeFirst( ) throw(SQLException, RuntimeException)
{
@@ -361,46 +363,41 @@ void SAL_CALL ODatabaseMetaDataResultSet::close( ) throw(SQLException, RuntimeE
}
// -------------------------------------------------------------------------
+SAL_WNOUNREACHABLE_CODE_PUSH
+
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::first( ) throw(SQLException, RuntimeException)
{
::dbtools::throwFunctionSequenceException(*this);
-#if !(defined(_MSC_VER) && defined(ENABLE_LTO))
return sal_False;
-#endif
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::last( ) throw(SQLException, RuntimeException)
{
::dbtools::throwFunctionSequenceException(*this);
-#if !(defined(_MSC_VER) && defined(ENABLE_LTO))
return sal_False;
-#endif
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::absolute( sal_Int32 /*row*/ ) throw(SQLException, RuntimeException)
{
::dbtools::throwFunctionSequenceException(*this);
-#if !(defined(_MSC_VER) && defined(ENABLE_LTO))
return sal_False;
-#endif
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::relative( sal_Int32 /*row*/ ) throw(SQLException, RuntimeException)
{
::dbtools::throwFunctionSequenceException(*this);
-#if !(defined(_MSC_VER) && defined(ENABLE_LTO))
return sal_False;
-#endif
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::previous( ) throw(SQLException, RuntimeException)
{
::dbtools::throwFunctionSequenceException(*this);
-#if !(defined(_MSC_VER) && defined(ENABLE_LTO))
return sal_False;
-#endif
}
+
+SAL_WNOUNREACHABLE_CODE_POP
+
// -------------------------------------------------------------------------
Reference< XInterface > SAL_CALL ODatabaseMetaDataResultSet::getStatement( ) throw(SQLException, RuntimeException)
{
@@ -408,29 +405,28 @@ Reference< XInterface > SAL_CALL ODatabaseMetaDataResultSet::getStatement( ) th
}
// -------------------------------------------------------------------------
+SAL_WNOUNREACHABLE_CODE_PUSH
+
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowDeleted( ) throw(SQLException, RuntimeException)
{
::dbtools::throwFunctionSequenceException(*this);
-#if !(defined(_MSC_VER) && defined(ENABLE_LTO))
return sal_False;
-#endif
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowInserted( ) throw(SQLException, RuntimeException)
{
::dbtools::throwFunctionSequenceException(*this);
-#if !(defined(_MSC_VER) && defined(ENABLE_LTO))
return sal_False;
-#endif
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowUpdated( ) throw(SQLException, RuntimeException)
{
::dbtools::throwFunctionSequenceException(*this);
-#if !(defined(_MSC_VER) && defined(ENABLE_LTO))
return sal_False;
-#endif
}
+
+SAL_WNOUNREACHABLE_CODE_POP
+
// -------------------------------------------------------------------------
sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException)
diff --git a/connectivity/source/sdbcx/VUser.cxx b/connectivity/source/sdbcx/VUser.cxx
index ad088aa..f7f8176 100644
--- a/connectivity/source/sdbcx/VUser.cxx
+++ b/connectivity/source/sdbcx/VUser.cxx
@@ -121,16 +121,15 @@ Reference< XNameAccess > SAL_CALL OUser::getGroups( ) throw(RuntimeException)
return const_cast<OUser*>(this)->m_pGroups;
}
// -------------------------------------------------------------------------
-// -------------------------------------------------------------------------
+
+SAL_WNOUNREACHABLE_CODE_PUSH
sal_Int32 SAL_CALL OUser::getPrivileges( const OUString& /*objName*/, sal_Int32 /*objType*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
::osl::MutexGuard aGuard(m_aMutex);
checkDisposed(OUser_BASE::rBHelper.bDisposed);
::dbtools::throwFeatureNotImplementedException( "XAuthorizable::changePassword", *this );
-#if !(defined(_MSC_VER) && defined(ENABLE_LTO))
return 0;
-#endif
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL OUser::getGrantablePrivileges( const OUString& /*objName*/, sal_Int32 /*objType*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
@@ -138,10 +137,11 @@ sal_Int32 SAL_CALL OUser::getGrantablePrivileges( const OUString& /*objName*/, s
::osl::MutexGuard aGuard(m_aMutex);
checkDisposed(OUser_BASE::rBHelper.bDisposed);
::dbtools::throwFeatureNotImplementedException( "XAuthorizable::getGrantablePrivileges", *this );
-#if !(defined(_MSC_VER) && defined(ENABLE_LTO))
return 0;
-#endif
}
+
+SAL_WNOUNREACHABLE_CODE_POP
+
// -------------------------------------------------------------------------
void SAL_CALL OUser::grantPrivileges( const OUString& /*objName*/, sal_Int32 /*objType*/, sal_Int32 /*objPrivileges*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
{
commit 543937297a7e936718a7e37a6ebe30dfc418e567
Author: Tor Lillqvist <tml at collabora.com>
Date: Wed Sep 4 14:27:25 2013 +0300
WaE: Unreachable code: Use SAL_WNOUNREACHABLE_CODE_PUSH/POP
Cleaner than my first attempt.
This reverts commit 853167931600777e7bf44a35e051628a1169bcfc.
Change-Id: Ib25b72a1f18d8adef5fa8d2960f233e0a7c29844
diff --git a/scaddins/source/analysis/analysishelper.cxx b/scaddins/source/analysis/analysishelper.cxx
index 0012231..85eff90 100644
--- a/scaddins/source/analysis/analysishelper.cxx
+++ b/scaddins/source/analysis/analysishelper.cxx
@@ -1068,8 +1068,9 @@ double GetOddfprice( sal_Int32 /*nNullDate*/, sal_Int32 /*nSettle*/, sal_Int32 /
sal_Int32 /*nFirstCoup*/, double /*fRate*/, double /*fYield*/, double /*fRedemp*/, sal_Int32 /*nFreq*/,
sal_Int32 /*nBase*/ ) throw( uno::RuntimeException, lang::IllegalArgumentException )
{
- // If you ever change this to not unconditionally throw, adapt
- // getOddfprice() (note lower-case 'g') in financial.cxx.
+ // If you change this to not unconditionally throw, the
+ // SAL_WNOUNREACHABLE_CODE_PUSH/POP around the caller in
+ // financial.cxx can be removed.
throw uno::RuntimeException(); // #87380#
}
@@ -1153,8 +1154,9 @@ double GetOddfyield( sal_Int32 /*nNullDate*/, sal_Int32 /*nSettle*/, sal_Int32 /
sal_Int32 /*nFirstCoup*/, double /*fRate*/, double /*fPrice*/, double /*fRedemp*/, sal_Int32 /*nFreq*/,
sal_Int32 /*nBase*/ ) throw( uno::RuntimeException, lang::IllegalArgumentException )
{
- // Ditto here, if you change this to not throw unconditionally,
- // adapt getOddfyield() in financial.cxx.
+ // If you change this to not unconditionally throw, the
+ // SAL_WNOUNREACHABLE_CODE_PUSH/POP around the caller in
+ // financial.cxx can be removed.
throw uno::RuntimeException(); // #87380#
}
diff --git a/scaddins/source/analysis/financial.cxx b/scaddins/source/analysis/financial.cxx
index a34591a..bfaec15 100644
--- a/scaddins/source/analysis/financial.cxx
+++ b/scaddins/source/analysis/financial.cxx
@@ -395,6 +395,10 @@ double SAL_CALL AnalysisAddIn::getTbillyield( const css::uno::Reference< css::be
RETURN_FINITE( fRet );
}
+// Encapsulation violation: We *know* that GetOddfprice() always
+// throws.
+
+SAL_WNOUNREACHABLE_CODE_PUSH
double SAL_CALL AnalysisAddIn::getOddfprice( const css::uno::Reference< css::beans::XPropertySet >& xOpt,
sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nIssue, sal_Int32 nFirstCoup,
@@ -403,22 +407,16 @@ double SAL_CALL AnalysisAddIn::getOddfprice( const css::uno::Reference< css::bea
if( fRate < 0.0 || fYield < 0.0 || CHK_Freq || nMat <= nFirstCoup || nFirstCoup <= nSettle || nSettle <= nIssue )
throw css::lang::IllegalArgumentException();
-#if !(defined(_MSC_VER) && defined(ENABLE_LTO))
double fRet = GetOddfprice( GetNullDate( xOpt ), nSettle, nMat, nIssue, nFirstCoup, fRate, fYield, fRedemp, nFreq, getDateMode( xOpt, rOB ) );
RETURN_FINITE( fRet );
-#else
- // During link-time optimization the compiler inlines the above
- // call to GetOddfprice() (note upper-case 'G') (from
- // analysishelper.cxx), and notices that GetOddfprice() always
- // throws, so the assignment and return are unreachable. Avoid
- // that warning by throwing directly here.
- (void) rOB;
- (void) fRedemp;
- (void) xOpt;
- throw css::uno::RuntimeException();
-#endif
}
+SAL_WNOUNREACHABLE_CODE_POP
+
+// Encapsulation violation: We *know* that Getoddfyield() always
+// throws.
+
+SAL_WNOUNREACHABLE_CODE_PUSH
double SAL_CALL AnalysisAddIn::getOddfyield( const css::uno::Reference< css::beans::XPropertySet >& xOpt,
sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nIssue, sal_Int32 nFirstCoup,
@@ -427,19 +425,12 @@ double SAL_CALL AnalysisAddIn::getOddfyield( const css::uno::Reference< css::bea
if( fRate < 0.0 || fPrice <= 0.0 || CHK_Freq || nMat <= nFirstCoup || nFirstCoup <= nSettle || nSettle <= nIssue )
throw css::lang::IllegalArgumentException();
-#if !(defined(_MSC_VER) && defined(ENABLE_LTO))
double fRet = GetOddfyield( GetNullDate( xOpt ), nSettle, nMat, nIssue, nFirstCoup, fRate, fPrice, fRedemp, nFreq,
getDateMode( xOpt, rOB ) );
RETURN_FINITE( fRet );
-#else
- // Same story here, see comment in getOddfprice()
- (void) rOB;
- (void) fRedemp;
- (void) xOpt;
- throw css::uno::RuntimeException();
-#endif
}
+SAL_WNOUNREACHABLE_CODE_POP
double SAL_CALL AnalysisAddIn::getOddlprice( const css::uno::Reference< css::beans::XPropertySet >& xOpt,
sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nLastInterest,
commit 849f7d1484167111f34e2da931fc7b6e57eb1b25
Author: Tor Lillqvist <tml at collabora.com>
Date: Wed Sep 4 14:25:23 2013 +0300
WaE: unreachable code
Change-Id: I65158d7f8f632fb153adc1a4560de25ed1be0810
diff --git a/svx/source/form/fmdmod.cxx b/svx/source/form/fmdmod.cxx
index e5092eb..6012e9c 100644
--- a/svx/source/form/fmdmod.cxx
+++ b/svx/source/form/fmdmod.cxx
@@ -47,11 +47,19 @@ using namespace ::svxform;
}
//-----------------------------------------------------------------------------
+
+// Encapsulation violation: We *know* that
+// SvxUnoDrawMSFactory::createInstanceWithArguments() always throws.
+
+SAL_WNOUNREACHABLE_CODE_PUSH
+
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SvxFmMSFactory::createInstanceWithArguments(const OUString& ServiceSpecifier, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments) throw( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException )
{
return SvxUnoDrawMSFactory::createInstanceWithArguments(ServiceSpecifier, Arguments );
}
+SAL_WNOUNREACHABLE_CODE_POP
+
//-----------------------------------------------------------------------------
::com::sun::star::uno::Sequence< OUString > SAL_CALL SvxFmMSFactory::getAvailableServiceNames(void) throw( ::com::sun::star::uno::RuntimeException )
{
commit 78d09575da61ac681f708ee76fc239111aa7186e
Author: Tor Lillqvist <tml at collabora.com>
Date: Wed Sep 4 14:22:20 2013 +0300
Add SAL_WNOUNREACHABLE_CODE_PUSH and _POP macros
To be used around code where some compiler, in some circumstances,
generates bogus warnings about unreachable code, that it would be much
uglier to work around otherwise.
Specifically, I will at first now use this to get rid of MSVC warnings
about unreachable code when calling a function defined in another
source file (but going into the same library) that always throws. The
compiler notices this when one uses link-time code generation and it
thus can do global inlining of code from all compilation units that go
into a library (or executable).
For MSVC, the __pragma that the SAL_WNOUNREACHABLE_CODE_PUSH macro
expands to needs to be in force at the start curly brace of a
function, so place the PUSH macro before the function definition. For
clarity, I guess it is best that the corresponding POP macro comes
after the end of the function.
Change-Id: Icef5259c5360b9facdc136fec1f207665ce79d90
diff --git a/include/sal/types.h b/include/sal/types.h
index 145d47e..c7a61bd 100644
--- a/include/sal/types.h
+++ b/include/sal/types.h
@@ -512,6 +512,34 @@ template< typename T1, typename T2 > inline T1 static_int_cast(T2 n) {
# define SAL_WNODEPRECATED_DECLARATIONS_POP
#endif
+/**
+ Use as follows:
+
+ SAL_WNOUNREACHABLE_CODE_PUSH
+
+ function definition
+
+ SAL_WNOUNREACHABLE_CODE_POP
+
+ Useful in cases where the compiler is "too clever" like when doing
+ link-time code generation, and noticing that a called function
+ always throws, and fixing the problem cleanly so that it produceds
+ no warnings in normal non-LTO compilations either is not easy.
+
+*/
+
+#ifdef _MSC_VER
+#define SAL_WNOUNREACHABLE_CODE_PUSH \
+ __pragma(warning(push)) \
+ __pragma(warning(disable:4702))
+#define SAL_WNOUNREACHABLE_CODE_POP \
+ __pragma(warning(pop))
+#else
+/* Add definitions for GCC and Clang if needed */
+#define SAL_WNOUNREACHABLE_CODE_PUSH
+#define SAL_WNOUNREACHABLE_CODE_POP
+#endif
+
/** Annotate unused but required C++ function parameters.
An unused parameter is required if the function needs to adhere to a given
More information about the Libreoffice-commits
mailing list