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 /dbaccess | |
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 'dbaccess')
-rw-r--r-- | dbaccess/source/core/dataaccess/ModelImpl.cxx | 4 | ||||
-rw-r--r-- | dbaccess/source/sdbtools/connection/objectnames.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/control/ColumnControlWindow.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/control/FieldDescControl.cxx | 8 | ||||
-rw-r--r-- | dbaccess/source/ui/control/RelationControl.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/HtmlReader.cxx | 4 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/UITools.cxx | 6 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/WCPage.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/WCopyTable.cxx | 10 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/WNameMatch.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/tabledesign/FieldDescriptions.cxx | 8 | ||||
-rw-r--r-- | dbaccess/source/ui/tabledesign/TEditControl.cxx | 4 | ||||
-rw-r--r-- | dbaccess/source/ui/tabledesign/TableController.cxx | 4 | ||||
-rw-r--r-- | dbaccess/source/ui/tabledesign/TableRow.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/uno/ColumnPeer.cxx | 2 |
15 files changed, 31 insertions, 31 deletions
diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx index 8f6dbaa31bb0..9aa56fe53787 100644 --- a/dbaccess/source/core/dataaccess/ModelImpl.cxx +++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx @@ -655,7 +655,7 @@ void ODatabaseModelImpl::dispose() for (auto const& elem : m_aContainer) { - if ( elem.get() ) + if ( elem ) elem->m_pDataSource = nullptr; } m_aContainer.clear(); @@ -1113,7 +1113,7 @@ TContentPtr& ODatabaseModelImpl::getObjectContainer( ObjectType _eType ) OSL_PRECOND( _eType >= E_FORM && _eType <= E_TABLE, "ODatabaseModelImpl::getObjectContainer: illegal index!" ); TContentPtr& rContentPtr = m_aContainer[ _eType ]; - if ( !rContentPtr.get() ) + if ( !rContentPtr ) { rContentPtr = std::make_shared<ODefinitionContainer_Impl>(); rContentPtr->m_pDataSource = this; diff --git a/dbaccess/source/sdbtools/connection/objectnames.cxx b/dbaccess/source/sdbtools/connection/objectnames.cxx index a8e103a2ee14..5ec2c22e8ea4 100644 --- a/dbaccess/source/sdbtools/connection/objectnames.cxx +++ b/dbaccess/source/sdbtools/connection/objectnames.cxx @@ -204,7 +204,7 @@ namespace sdbtools :m_pPrimary( _pPrimary ) ,m_pSecondary( _pSecondary ) { - OSL_ENSURE( m_pPrimary.get() && m_pSecondary.get(), "CombinedNameCheck::CombinedNameCheck: this will crash!" ); + OSL_ENSURE( m_pPrimary && m_pSecondary, "CombinedNameCheck::CombinedNameCheck: this will crash!" ); } // INameValidation diff --git a/dbaccess/source/ui/control/ColumnControlWindow.cxx b/dbaccess/source/ui/control/ColumnControlWindow.cxx index bac5b49cbd7c..28a77291ce13 100644 --- a/dbaccess/source/ui/control/ColumnControlWindow.cxx +++ b/dbaccess/source/ui/control/ColumnControlWindow.cxx @@ -152,7 +152,7 @@ OUString OColumnControlWindow::getAutoIncrementValue() const TOTypeInfoSP const & OColumnControlWindow::getDefaultTyp() const { - if ( !m_pTypeInfo.get() ) + if ( !m_pTypeInfo ) { m_pTypeInfo = std::make_shared<OTypeInfo>(); m_pTypeInfo->aUIName = m_sTypeNames.getToken(TYPE_OTHER, ';'); diff --git a/dbaccess/source/ui/control/FieldDescControl.cxx b/dbaccess/source/ui/control/FieldDescControl.cxx index 4650ba113303..c7bb190ab34e 100644 --- a/dbaccess/source/ui/control/FieldDescControl.cxx +++ b/dbaccess/source/ui/control/FieldDescControl.cxx @@ -916,7 +916,7 @@ void OFieldDescControl::DisplayData(OFieldDescription* pFieldDescr ) { DeactivateAggregate(tpRequired); } - else if (!m_xAutoIncrement && pFieldType.get()) + else if (!m_xAutoIncrement && pFieldType) { if (pFieldType->bNullable) ActivateAggregate(tpRequired); @@ -961,7 +961,7 @@ void OFieldDescControl::DisplayData(OFieldDescription* pFieldDescr ) OUString sDef = BoolStringUI(sValue); // Make sure that <<none>> is only present if the field can be NULL - if ( ( pFieldType.get() && !pFieldType->bNullable ) || !pFieldDescr->IsNullable() ) + if ( ( pFieldType && !pFieldType->bNullable ) || !pFieldDescr->IsNullable() ) { pFieldDescr->SetIsNullable(ColumnValue::NO_NULLS); // The type says so @@ -1015,11 +1015,11 @@ void OFieldDescControl::DisplayData(OFieldDescription* pFieldDescr ) if (m_xType) { - sal_Int32 nPos = pFieldType.get() ? m_xType->find_text(pFieldDescr->getTypeInfo()->aUIName) : -1; + sal_Int32 nPos = pFieldType ? m_xType->find_text(pFieldDescr->getTypeInfo()->aUIName) : -1; if (nPos == -1) { const OTypeInfoMap* pMap = getTypeInfo(); - OTypeInfoMap::const_iterator aIter = pMap->find(pFieldType.get() ? pFieldDescr->getTypeInfo()->nType : pFieldDescr->GetType()); + OTypeInfoMap::const_iterator aIter = pMap->find(pFieldType ? pFieldDescr->getTypeInfo()->nType : pFieldDescr->GetType()); if(aIter == pMap->end() && !pMap->empty()) { aIter = pMap->begin(); diff --git a/dbaccess/source/ui/control/RelationControl.cxx b/dbaccess/source/ui/control/RelationControl.cxx index 041e7a50378c..d9de91ba494b 100644 --- a/dbaccess/source/ui/control/RelationControl.cxx +++ b/dbaccess/source/ui/control/RelationControl.cxx @@ -145,7 +145,7 @@ namespace dbaui void ORelationControl::lateInit() { - if ( !m_pConnData.get() ) + if ( !m_pConnData ) return; m_xSourceDef = m_pConnData->getReferencingTable()->getTable(); m_xDestDef = m_pConnData->getReferencedTable()->getTable(); diff --git a/dbaccess/source/ui/misc/HtmlReader.cxx b/dbaccess/source/ui/misc/HtmlReader.cxx index c6e7f7ac37fb..6e3d329e3ef2 100644 --- a/dbaccess/source/ui/misc/HtmlReader.cxx +++ b/dbaccess/source/ui/misc/HtmlReader.cxx @@ -139,7 +139,7 @@ void OHTMLReader::NextToken( HtmlTokenId nToken ) } break; case HtmlTokenId::TABLEROW_ON: - if ( !m_pUpdateHelper.get() ) + if ( !m_pUpdateHelper ) m_bError = true; break; case HtmlTokenId::TEXTTOKEN: @@ -176,7 +176,7 @@ void OHTMLReader::NextToken( HtmlTokenId nToken ) } break; case HtmlTokenId::TABLEROW_OFF: - if ( !m_pUpdateHelper.get() ) + if ( !m_pUpdateHelper ) { m_bError = true; break; diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx index 062bdda820bd..865a580b3947 100644 --- a/dbaccess/source/ui/misc/UITools.cxx +++ b/dbaccess/source/ui/misc/UITools.cxx @@ -1066,12 +1066,12 @@ TOTypeInfoSP queryPrimaryKeyType(const OTypeInfoMap& _rTypeInfo) pTypeInfo = elem.second; // alternative break; } - else if ( !pTypeInfo.get() && elem.second->nType == DataType::DOUBLE ) + else if ( !pTypeInfo && elem.second->nType == DataType::DOUBLE ) pTypeInfo = elem.second; // alternative - else if ( !pTypeInfo.get() && elem.second->nType == DataType::REAL ) + else if ( !pTypeInfo && elem.second->nType == DataType::REAL ) pTypeInfo = elem.second; // alternative } - if ( !pTypeInfo.get() ) // just a fallback + if ( !pTypeInfo ) // just a fallback pTypeInfo = queryTypeInfoByType(DataType::VARCHAR,_rTypeInfo); OSL_ENSURE(pTypeInfo.get(),"checkColumns: can't find a type which is usable as a key!"); diff --git a/dbaccess/source/ui/misc/WCPage.cxx b/dbaccess/source/ui/misc/WCPage.cxx index 05cf7e802dd6..35c8a7fe0f18 100644 --- a/dbaccess/source/ui/misc/WCPage.cxx +++ b/dbaccess/source/ui/misc/WCPage.cxx @@ -263,7 +263,7 @@ bool OCopyTable::checkAppendData() return false; } - if ( pTypeInfo.get() ) + if ( pTypeInfo ) m_pParent->m_vColumnTypes[i] = pTypeInfo->nType; else m_pParent->m_vColumnTypes[i] = DataType::VARCHAR; diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx index 30ebf6f6a642..58dbc4d65327 100644 --- a/dbaccess/source/ui/misc/WCopyTable.cxx +++ b/dbaccess/source/ui/misc/WCopyTable.cxx @@ -729,7 +729,7 @@ bool OCopyTableWizard::CheckColumns(sal_Int32& _rnBreakPos) { // add extra column for the primary key TOTypeInfoSP pTypeInfo = queryPrimaryKeyType(m_aDestTypeInfo); - if ( pTypeInfo.get() ) + if ( pTypeInfo ) { if ( m_bAddPKFirstTime ) { @@ -1021,7 +1021,7 @@ void OCopyTableWizard::loadData( const ICopyTableSourceObject& _rSourceObject, // search for type bool bForce; TOTypeInfoSP pTypeInfo = ::dbaui::getTypeInfoFromType(m_aTypeInfo,nType,sTypeName,sCreateParam,nPrecision,nScale,bAutoIncrement,bForce); - if ( !pTypeInfo.get() ) + if ( !pTypeInfo ) pTypeInfo = m_pTypeInfo; pActFieldDescr->FillFromTypeInfo(pTypeInfo,true,false); @@ -1416,7 +1416,7 @@ TOTypeInfoSP OCopyTableWizard::convertType(const TOTypeInfoSP& _pType, bool& _bN bool bForce; TOTypeInfoSP pType = ::dbaui::getTypeInfoFromType(m_aDestTypeInfo,_pType->nType,_pType->aTypeName,_pType->aCreateParams,_pType->nPrecision,_pType->nMaximumScale,_pType->bAutoIncrement,bForce); - if ( !pType.get() || bForce ) + if ( !pType || bForce ) { // no type found so we have to find the correct one ourself sal_Int32 nDefaultType = DataType::VARCHAR; switch(_pType->nType) @@ -1492,12 +1492,12 @@ TOTypeInfoSP OCopyTableWizard::convertType(const TOTypeInfoSP& _pType, bool& _bN nDefaultType = DataType::VARCHAR; } pType = ::dbaui::getTypeInfoFromType(m_aDestTypeInfo,nDefaultType,_pType->aTypeName,_pType->aCreateParams,_pType->nPrecision,_pType->nMaximumScale,_pType->bAutoIncrement,bForce); - if ( !pType.get() ) + if ( !pType ) { _bNotConvert = false; OUString const sCreate("x"); pType = ::dbaui::getTypeInfoFromType(m_aDestTypeInfo,DataType::VARCHAR,_pType->aTypeName,sCreate,50,0,false,bForce); - if ( !pType.get() ) + if ( !pType ) pType = m_pTypeInfo; } else if ( bForce ) diff --git a/dbaccess/source/ui/misc/WNameMatch.cxx b/dbaccess/source/ui/misc/WNameMatch.cxx index 0dad92bbdf17..83ad642d887a 100644 --- a/dbaccess/source/ui/misc/WNameMatch.cxx +++ b/dbaccess/source/ui/misc/WNameMatch.cxx @@ -165,7 +165,7 @@ bool OWizNameMatching::LeavePage() } sal_Int32 nType = css::sdbc::DataType::VARCHAR; - if ( pTypeInfo.get() ) + if ( pTypeInfo ) nType = pTypeInfo->nType; m_pParent->m_vColumnTypes[nPos] = nType; } diff --git a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx index 76f05951541b..6882f12166a7 100644 --- a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx +++ b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx @@ -323,7 +323,7 @@ void OFieldDescription::SetAutoIncrementValue(const OUString& _sAutoIncValue) void OFieldDescription::SetType(const TOTypeInfoSP& _pType) { m_pType = _pType; - if ( !m_pType.get() ) + if ( !m_pType ) return; try @@ -348,7 +348,7 @@ void OFieldDescription::SetTypeValue(sal_Int32 _nType) else { m_nType = _nType; - OSL_ENSURE(!m_pType.get(),"Invalid call here!"); + OSL_ENSURE(!m_pType,"Invalid call here!"); } } catch( const Exception& ) @@ -504,7 +504,7 @@ sal_Int32 OFieldDescription::GetType() const if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_TYPE) ) return ::comphelper::getINT32(m_xDest->getPropertyValue(PROPERTY_TYPE)); else - return m_pType.get() ? m_pType->nType : m_nType; + return m_pType ? m_pType->nType : m_nType; } OUString OFieldDescription::GetTypeName() const @@ -512,7 +512,7 @@ OUString OFieldDescription::GetTypeName() const if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_TYPENAME) ) return ::comphelper::getString(m_xDest->getPropertyValue(PROPERTY_TYPENAME)); else - return m_pType.get() ? m_pType->aTypeName : m_sTypeName; + return m_pType ? m_pType->aTypeName : m_sTypeName; } sal_Int32 OFieldDescription::GetPrecision() const diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx b/dbaccess/source/ui/tabledesign/TEditControl.cxx index a17cf27bdf76..6f5128faa6e5 100644 --- a/dbaccess/source/ui/tabledesign/TEditControl.cxx +++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx @@ -891,7 +891,7 @@ void OTableEditorCtrl::SetCellData( long nRow, sal_uInt16 nColId, const TOTypeIn default: OSL_FAIL("OTableEditorCtrl::SetCellData: invalid column!"); } - SetControlText(nRow,nColId,_pTypeInfo.get() ? _pTypeInfo->aUIName : OUString()); + SetControlText(nRow,nColId,_pTypeInfo ? _pTypeInfo->aUIName : OUString()); } void OTableEditorCtrl::SetCellData( long nRow, sal_uInt16 nColId, const css::uno::Any& _rNewData ) @@ -1562,7 +1562,7 @@ void OTableEditorCtrl::SwitchType( const TOTypeInfoSP& _pType ) // Show the new description std::shared_ptr<OTableRow> pRow = (*m_pRowList)[nRow]; pRow->SetFieldType( _pType, true ); - if ( _pType.get() ) + if ( _pType ) { weld::ComboBox& rTypeList = pTypeCell->get_widget(); const sal_Int32 nCurrentlySelected = rTypeList.get_active(); diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx index d8174d69a09a..f88110b48362 100644 --- a/dbaccess/source/ui/tabledesign/TableController.cxx +++ b/dbaccess/source/ui/tabledesign/TableController.cxx @@ -812,7 +812,7 @@ void OTableController::loadData() bool bForce; OUString const sCreate("x"); TOTypeInfoSP pTypeInfo = ::dbaui::getTypeInfoFromType(m_aTypeInfo,nType,sTypeName,sCreate,nPrecision,nScale,bIsAutoIncrement,bForce); - if ( !pTypeInfo.get() ) + if ( !pTypeInfo ) pTypeInfo = m_pTypeInfo; pTabEdRow->SetFieldType( pTypeInfo, bForce ); @@ -921,7 +921,7 @@ bool OTableController::checkColumns(bool _bNew) { auto pNewRow = std::make_shared<OTableRow>(); TOTypeInfoSP pTypeInfo = ::dbaui::queryPrimaryKeyType(m_aTypeInfo); - if ( !pTypeInfo.get() ) + if ( !pTypeInfo ) break; pNewRow->SetFieldType( pTypeInfo ); diff --git a/dbaccess/source/ui/tabledesign/TableRow.cxx b/dbaccess/source/ui/tabledesign/TableRow.cxx index 989dd8d819bb..c84ebc834410 100644 --- a/dbaccess/source/ui/tabledesign/TableRow.cxx +++ b/dbaccess/source/ui/tabledesign/TableRow.cxx @@ -78,7 +78,7 @@ bool OTableRow::IsPrimaryKey() const void OTableRow::SetFieldType( const TOTypeInfoSP& _pType, bool _bForce ) { - if ( _pType.get() ) + if ( _pType ) { if( !m_pActFieldDescr ) { diff --git a/dbaccess/source/ui/uno/ColumnPeer.cxx b/dbaccess/source/ui/uno/ColumnPeer.cxx index 66904e79a13f..36bad3a1057d 100644 --- a/dbaccess/source/ui/uno/ColumnPeer.cxx +++ b/dbaccess/source/ui/uno/ColumnPeer.cxx @@ -90,7 +90,7 @@ void OColumnPeer::setColumn(const Reference< XPropertySet>& _xColumn) OUString const sCreateParam("x"); bool bForce; TOTypeInfoSP pTypeInfo = ::dbaui::getTypeInfoFromType(*pFieldControl->getTypeInfo(),nType,sTypeName,sCreateParam,nPrecision,nScale,bAutoIncrement,bForce); - if ( !pTypeInfo.get() ) + if ( !pTypeInfo ) pTypeInfo = pFieldControl->getDefaultTyp(); m_pActFieldDescr->FillFromTypeInfo(pTypeInfo,true,false); |