diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-05-26 20:42:08 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-05-26 22:33:02 +0200 |
commit | fe6cce01c88d045a1fcf09acf049c34c22299b02 (patch) | |
tree | c118594a43386096bca55179f31b2b61e64dfa48 /connectivity | |
parent | b894a3d7f991dd248dfd8935b31da8bccfd130b2 (diff) |
Fix loplugin:simplifypointertobool for libstdc++ std::shared_ptr
...where the get member function is defined on a std::__shared_ptr base class,
so loplugin:simplifypointertobool used to miss those until now. (While e.g.
using libc++ on macOS found those cases.)
366d08f2f6d4de922f6099c62bb81b49d89e0a68 "new loplugin:simplifypointertobool"
was mistaken in breaking isSmartPointerType(const clang::Type* t) out of
isSmartPointerType(const Expr* e); c874294ad9fb178df47c66875bfbdec466e39763 "Fix
detection of std::unique_ptr/shared_ptr in loplugin:redundantpointerops" had
introduced that indivisible two-step algorithm on purpose.
The amount of additional hits (on Linux) apparently asked for turning
loplugin:simplifypointertobool into a rewriting plugin. Which in turn showed
that the naive adivce to just "drop the get()" is not sufficient in places that
are not contextually converted to bool, as those places need to be wrapped in a
bool(...) functional cast now. If the expression was already wrapped in
parentheses, those could be reused as part of the functional cast, but
implementing that showed that such cases are not yet found at all by the
existing loplugin:simplifypointertobool. Lets leave that TODO for another
commit.
Besides the changes to compilerplugins/ itself, this change has been generated
fully automatically with the rewriting plugin on Linux.
Change-Id: I83107d6f634fc9ac232986f49044d7017df83e2a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94888
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Jenkins
Diffstat (limited to 'connectivity')
5 files changed, 19 insertions, 19 deletions
diff --git a/connectivity/source/commontools/TTableHelper.cxx b/connectivity/source/commontools/TTableHelper.cxx index e22740144316..e86af9673052 100644 --- a/connectivity/source/commontools/TTableHelper.cxx +++ b/connectivity/source/commontools/TTableHelper.cxx @@ -371,7 +371,7 @@ void OTableHelper::refreshForeignKeys(::std::vector< OUString>& _rNames) { if ( sOldFKName != sFkName ) { - if ( pKeyProps.get() ) + if ( pKeyProps ) m_pImpl->m_aKeys.emplace(sOldFKName,pKeyProps); const OUString sReferencedName = ::dbtools::composeTableName(getMetaData(),sCatalog,aSchema,aName,false,::dbtools::EComposeRule::InDataManipulation); @@ -387,13 +387,13 @@ void OTableHelper::refreshForeignKeys(::std::vector< OUString>& _rNames) } // if ( m_pTables->hasByName(sReferencedName) ) sOldFKName = sFkName; } // if ( sOldFKName != sFkName ) - else if ( pKeyProps.get() ) + else if ( pKeyProps ) { pKeyProps->m_aKeyColumnNames.push_back(sForeignKeyColumn); } } } // while( xResult->next() ) - if ( pKeyProps.get() ) + if ( pKeyProps ) m_pImpl->m_aKeys.emplace(sOldFKName,pKeyProps); ::comphelper::disposeComponent(xResult); } diff --git a/connectivity/source/drivers/hsqldb/HStorageAccess.cxx b/connectivity/source/drivers/hsqldb/HStorageAccess.cxx index 5ea16e7e1c60..60e3fd0ee868 100644 --- a/connectivity/source/drivers/hsqldb/HStorageAccess.cxx +++ b/connectivity/source/drivers/hsqldb/HStorageAccess.cxx @@ -68,7 +68,7 @@ extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_Nativ } #endif std::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key); - Reference< XOutputStream> xFlush = pHelper.get() ? pHelper->getOutputStream() : Reference< XOutputStream>(); + Reference< XOutputStream> xFlush = pHelper ? pHelper->getOutputStream() : Reference< XOutputStream>(); if ( xFlush.is() ) try { @@ -108,7 +108,7 @@ extern "C" SAL_JNI_EXPORT jlong JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_Nati std::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key); OSL_ENSURE(pHelper.get(),"No stream helper!"); - jlong nReturn = pHelper.get() ? pHelper->getSeek()->getPosition() : jlong(0); + jlong nReturn = pHelper ? pHelper->getSeek()->getPosition() : jlong(0); #ifdef HSQLDB_DBG aOpLog.logReturn( nReturn ); #endif @@ -132,7 +132,7 @@ extern "C" SAL_JNI_EXPORT jlong JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_Nati std::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key); OSL_ENSURE(pHelper.get(),"No stream helper!"); - jlong nReturn = pHelper.get() ? pHelper->getSeek()->getLength() :jlong(0); + jlong nReturn = pHelper ? pHelper->getSeek()->getLength() :jlong(0); #ifdef HSQLDB_DBG aOpLog.logReturn( nReturn ); #endif @@ -143,7 +143,7 @@ extern "C" SAL_JNI_EXPORT jlong JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_Nati jint read_from_storage_stream( JNIEnv * env, jstring name, jstring key ) { std::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key); - Reference< XInputStream> xIn = pHelper.get() ? pHelper->getInputStream() : Reference< XInputStream>(); + Reference< XInputStream> xIn = pHelper ? pHelper->getInputStream() : Reference< XInputStream>(); OSL_ENSURE(xIn.is(),"Input stream is NULL!"); if ( xIn.is() ) { @@ -201,7 +201,7 @@ jint read_from_storage_stream_into_buffer( JNIEnv * env, jstring name, jstring k } #endif std::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key); - Reference< XInputStream> xIn = pHelper.get() ? pHelper->getInputStream() : Reference< XInputStream>(); + Reference< XInputStream> xIn = pHelper ? pHelper->getInputStream() : Reference< XInputStream>(); OSL_ENSURE(xIn.is(),"Input stream is NULL!"); if ( xIn.is() ) { @@ -274,7 +274,7 @@ extern "C" SAL_JNI_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_Nativ #endif std::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key); - Reference< XInputStream> xIn = pHelper.get() ? pHelper->getInputStream() : Reference< XInputStream>(); + Reference< XInputStream> xIn = pHelper ? pHelper->getInputStream() : Reference< XInputStream>(); OSL_ENSURE(xIn.is(),"Input stream is NULL!"); if ( xIn.is() ) { @@ -340,7 +340,7 @@ extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_Nativ #endif std::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key); - Reference< XSeekable> xSeek = pHelper.get() ? pHelper->getSeek() : Reference< XSeekable>(); + Reference< XSeekable> xSeek = pHelper ? pHelper->getSeek() : Reference< XSeekable>(); OSL_ENSURE(xSeek.is(),"No Seekable stream!"); if ( !xSeek.is() ) @@ -396,7 +396,7 @@ extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_Nativ void write_to_storage_stream_from_buffer( JNIEnv* env, jstring name, jstring key, jbyteArray buffer, jint off, jint len ) { std::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key); - Reference< XOutputStream> xOut = pHelper.get() ? pHelper->getOutputStream() : Reference< XOutputStream>(); + Reference< XOutputStream> xOut = pHelper ? pHelper->getOutputStream() : Reference< XOutputStream>(); OSL_ENSURE(xOut.is(),"Stream is NULL"); try @@ -456,7 +456,7 @@ extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_Nativ void write_to_storage_stream( JNIEnv* env, jstring name, jstring key, jint v ) { std::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key); - Reference< XOutputStream> xOut = pHelper.get() ? pHelper->getOutputStream() : Reference< XOutputStream>(); + Reference< XOutputStream> xOut = pHelper ? pHelper->getOutputStream() : Reference< XOutputStream>(); OSL_ENSURE(xOut.is(),"Stream is NULL"); try { diff --git a/connectivity/source/drivers/hsqldb/StorageNativeInputStream.cxx b/connectivity/source/drivers/hsqldb/StorageNativeInputStream.cxx index 28221925dcc2..bdafac4ee3ab 100644 --- a/connectivity/source/drivers/hsqldb/StorageNativeInputStream.cxx +++ b/connectivity/source/drivers/hsqldb/StorageNativeInputStream.cxx @@ -141,7 +141,7 @@ extern "C" SAL_JNI_EXPORT jlong JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_Stor std::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key); OSL_ENSURE(pHelper.get(),"No stream helper!"); - if ( pHelper.get() ) + if ( pHelper ) { Reference<XInputStream> xIn = pHelper->getInputStream(); if ( xIn.is() ) @@ -203,7 +203,7 @@ extern "C" SAL_JNI_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_Stora std::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key); OSL_ENSURE(pHelper.get(),"No stream helper!"); - Reference<XInputStream> xIn = pHelper.get() ? pHelper->getInputStream() : Reference<XInputStream>(); + Reference<XInputStream> xIn = pHelper ? pHelper->getInputStream() : Reference<XInputStream>(); if ( xIn.is() ) { try @@ -246,7 +246,7 @@ extern "C" SAL_JNI_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_Stora #endif std::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key); - Reference< XInputStream> xIn = pHelper.get() ? pHelper->getInputStream() : Reference< XInputStream>(); + Reference< XInputStream> xIn = pHelper ? pHelper->getInputStream() : Reference< XInputStream>(); OSL_ENSURE(xIn.is(),"Input stream is NULL!"); jint nBytesRead = 0; if ( xIn.is() ) diff --git a/connectivity/source/drivers/hsqldb/StorageNativeOutputStream.cxx b/connectivity/source/drivers/hsqldb/StorageNativeOutputStream.cxx index 7a4f2b7aa50c..f766696e0d9b 100644 --- a/connectivity/source/drivers/hsqldb/StorageNativeOutputStream.cxx +++ b/connectivity/source/drivers/hsqldb/StorageNativeOutputStream.cxx @@ -109,7 +109,7 @@ extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_Stora #endif std::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key); - Reference< XOutputStream> xFlush = pHelper.get() ? pHelper->getOutputStream() : Reference< XOutputStream>(); + Reference< XOutputStream> xFlush = pHelper ? pHelper->getOutputStream() : Reference< XOutputStream>(); if ( xFlush.is() ) try { @@ -176,7 +176,7 @@ extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_Stora OperationLogFile( env, name, "output" ).logOperation( "sync" ); #endif std::shared_ptr< StreamHelper > pStream = StorageContainer::getRegisteredStream( env, name, key ); - Reference< XOutputStream > xFlush = pStream.get() ? pStream->getOutputStream() : Reference< XOutputStream>(); + Reference< XOutputStream > xFlush = pStream ? pStream->getOutputStream() : Reference< XOutputStream>(); OSL_ENSURE( xFlush.is(), "StorageNativeOutputStream::sync: could not retrieve an output stream!" ); if ( xFlush.is() ) { diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index 9cb334c27e86..d8c48c64321a 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -101,7 +101,7 @@ namespace connectivity public: bool isQueryAllowed( const OUString& _rQueryName ) { - if ( !m_pForbiddenQueryNames.get() ) + if ( !m_pForbiddenQueryNames ) return true; if ( m_pForbiddenQueryNames->find( _rQueryName ) == m_pForbiddenQueryNames->end() ) return true; @@ -123,7 +123,7 @@ namespace connectivity :m_rpAllForbiddenNames( _rIteratorImpl.m_pForbiddenQueryNames ) ,m_sForbiddenQueryName( _rForbiddenQueryName ) { - if ( !m_rpAllForbiddenNames.get() ) + if ( !m_rpAllForbiddenNames ) m_rpAllForbiddenNames = std::make_shared<QueryNameSet>(); m_rpAllForbiddenNames->insert( m_sForbiddenQueryName ); } |