compilerplugins/clang/redundantcast.cxx | 20 +- compilerplugins/clang/test/redundantcast.cxx | 112 +++++++++++++++- dbaccess/source/core/dataaccess/ModelImpl.cxx | 4 dbaccess/source/ui/querydesign/JoinController.cxx | 2 sc/source/core/data/column.cxx | 4 sc/source/core/data/column2.cxx | 2 sc/source/core/data/column3.cxx | 2 sc/source/core/tool/interpr6.cxx | 4 sd/source/ui/unoidl/SdUnoOutlineView.cxx | 2 svx/source/form/fmpgeimp.cxx | 2 sw/source/core/doc/DocumentContentOperationsManager.cxx | 2 sw/source/core/doc/tblafmt.cxx | 2 sw/source/core/docnode/ndtbl.cxx | 2 sw/source/core/layout/flowfrm.cxx | 2 sw/source/core/txtnode/ndtxt.cxx | 2 sw/source/core/unocore/unoframe.cxx | 4 sw/source/core/unocore/unoidx.cxx | 2 sw/source/core/view/vdraw.cxx | 2 sw/source/filter/ww8/docxattributeoutput.cxx | 2 sw/source/filter/ww8/rtfattributeoutput.cxx | 2 vcl/unx/generic/fontmanager/fontsubst.cxx | 2 xmloff/source/draw/XMLShapeStyleContext.cxx | 2 22 files changed, 143 insertions(+), 37 deletions(-)
New commits: commit 95645cbf0a220c338600130bdeca49743b252972 Author: Stephan Bergmann <sberg...@redhat.com> Date: Fri Jun 2 13:31:37 2017 +0200 Improved loplugin:redundantcast const_cast handling Change-Id: I4c24ff5d9d5e74bef2a4040c6308c504282af55d diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx index 6bc97e5351a3..6d740ddca883 100644 --- a/compilerplugins/clang/redundantcast.cxx +++ b/compilerplugins/clang/redundantcast.cxx @@ -37,9 +37,12 @@ bool isVoidPointer(QualType type) { } bool isRedundantConstCast(CXXConstCastExpr const * expr) { - return expr->getTypeAsWritten().getCanonicalType().getTypePtr() - == (expr->getSubExprAsWritten()->getType().getCanonicalType() - .getTypePtr()); + auto const sub = compat::getSubExprAsWritten(expr); + return + (expr->getType().getCanonicalType() + == sub->getType().getCanonicalType()) + && (expr->getValueKind() != VK_XValue + || sub->getValueKind() == VK_XValue); } bool isArithmeticOp(Expr const * expr) { @@ -511,11 +514,14 @@ bool RedundantCast::VisitCXXConstCastExpr(CXXConstCastExpr const * expr) { return true; } if (isRedundantConstCast(expr)) { + auto const sub = compat::getSubExprAsWritten(expr); report( - DiagnosticsEngine::Warning, "redundant const_cast from %0 to %1", - expr->getExprLoc()) - << expr->getSubExprAsWritten()->getType() - << expr->getTypeAsWritten() << expr->getSourceRange(); + DiagnosticsEngine::Warning, + "redundant const_cast from %0 %1 to %2 %3", expr->getExprLoc()) + << sub->getType() << printExprValueKind(sub->getValueKind()) + << expr->getTypeAsWritten() + << printExprValueKind(expr->getValueKind()) + << expr->getSourceRange(); } return true; } diff --git a/compilerplugins/clang/test/redundantcast.cxx b/compilerplugins/clang/test/redundantcast.cxx index 6e5a8d42e589..1d2646a0f463 100644 --- a/compilerplugins/clang/test/redundantcast.cxx +++ b/compilerplugins/clang/test/redundantcast.cxx @@ -19,24 +19,124 @@ void testConstCast() { char const * p2; p1 = nullptr; p2 = ""; - f1(const_cast<char *>(p1)); // expected-error {{redundant const_cast from 'char *' to 'char *' [loplugin:redundantcast]}} - f1(const_cast<char * const>(p1)); // expected-error {{redundant const_cast from 'char *' to 'char *const' [loplugin:redundantcast]}} + f1(const_cast<char *>(p1)); // expected-error {{redundant const_cast from 'char *' lvalue to 'char *' prvalue [loplugin:redundantcast]}} + f1(const_cast<char * const>(p1)); // expected-error {{redundant const_cast from 'char *' lvalue to 'char *const' prvalue [loplugin:redundantcast]}} f1(const_cast<char *>(p2)); f1(const_cast<char * const>(p2)); - f2(const_cast<char *>(p1)); // expected-error {{redundant const_cast from 'char *' to 'char *' [loplugin:redundantcast]}} - f2(const_cast<char * const>(p1)); // expected-error {{redundant const_cast from 'char *' to 'char *const' [loplugin:redundantcast]}} + f2(const_cast<char *>(p1)); // expected-error {{redundant const_cast from 'char *' lvalue to 'char *' prvalue [loplugin:redundantcast]}} + f2(const_cast<char * const>(p1)); // expected-error {{redundant const_cast from 'char *' lvalue to 'char *const' prvalue [loplugin:redundantcast]}} f2(const_cast<char const *>(p1)); f2(const_cast<char const * const>(p1)); f2(const_cast<char *>(p2)); // expected-error {{redundant const_cast from 'const char *' to 'char *', result is implicitly cast to 'const char *' [loplugin:redundantcast]}} f2(const_cast<char * const>(p2)); // expected-error {{redundant const_cast from 'const char *' to 'char *', result is implicitly cast to 'const char *' [loplugin:redundantcast]}} - f2(const_cast<char const *>(p2)); // expected-error {{redundant const_cast from 'const char *' to 'const char *' [loplugin:redundantcast]}} - f2(const_cast<char const * const>(p2)); // expected-error {{redundant const_cast from 'const char *' to 'const char *const' [loplugin:redundantcast]}} + f2(const_cast<char const *>(p2)); // expected-error {{redundant const_cast from 'const char *' lvalue to 'const char *' prvalue [loplugin:redundantcast]}} + f2(const_cast<char const * const>(p2)); // expected-error {{redundant const_cast from 'const char *' lvalue to 'const char *const' prvalue [loplugin:redundantcast]}} S const s{}; const_cast<S &>(s).f1(); const_cast<S &>(s).f2(); // expected-error {{redundant const_cast from 'const S' to 'S', result is implicitly cast to 'const S' [loplugin:redundantcast]}} const_cast<S &>(s).f3(); s.f3(); + + // non-class lvalue, non-const: + int ni{}; +// (void) const_cast<int>(ni); + (void) const_cast<int &>(ni); // expected-error {{redundant const_cast from 'int' lvalue to 'int &' lvalue [loplugin:redundantcast]}} + (void) const_cast<int &&>(ni); +// (void) const_cast<int const>(ni); + (void) const_cast<int const &>(ni); + (void) const_cast<int const &&>(ni); + + // non-class lvalue, const: + int const ci{}; +// (void) const_cast<int>(ci); + (void) const_cast<int &>(ci); + (void) const_cast<int &&>(ci); +// (void) const_cast<int const>(ci); + (void) const_cast<int const &>(ci); // expected-error {{redundant const_cast from 'const int' lvalue to 'const int &' lvalue [loplugin:redundantcast]}} + (void) const_cast<int const &&>(ci); + + // non-class xvalue, non-const: +// (void) const_cast<int>(nix()); +// (void) const_cast<int &>(nix()); + (void) const_cast<int &&>(nix()); // expected-error {{redundant const_cast from 'int' xvalue to 'int &&' xvalue [loplugin:redundantcast]}} +// (void) const_cast<int const>(nix()); +// (void) const_cast<int const &>(nix()); + (void) const_cast<int const &&>(nix()); + + // non-class xvalue, const: +// (void) const_cast<int>(cix()); +// (void) const_cast<int &>(cix()); + (void) const_cast<int &&>(cix()); +// (void) const_cast<int const>(cix()); +// (void) const_cast<int const &>(cix()); + (void) const_cast<int const &&>(cix()); // expected-error {{redundant const_cast from 'const int' xvalue to 'const int &&' xvalue [loplugin:redundantcast]}} + + // non-class prvalue, non-const: +// (void) const_cast<int>(nir()); +// (void) const_cast<int &>(nir()); +// (void) const_cast<int &&>(nir()); +// (void) const_cast<int const>(nir()); +// (void) const_cast<int const &>(nir()); +// (void) const_cast<int const &&>(nir()); + + // non-class prvalue, const: +// (void) const_cast<int>(cir()); +// (void) const_cast<int &>(cir()); +// (void) const_cast<int &&>(cir()); +// (void) const_cast<int const>(cir()); +// (void) const_cast<int const &>(cir()); +// (void) const_cast<int const &&>(cir()); + + // class lvalue, non-const: + S ns{}; +// (void) const_cast<S>(ns); + (void) const_cast<S &>(ns); // expected-error {{redundant const_cast from 'S' lvalue to 'S &' lvalue [loplugin:redundantcast]}} + (void) const_cast<S &&>(ns); +// (void) const_cast<S const>(ns); + (void) const_cast<S const &>(ns); + (void) const_cast<S const &&>(ns); + + // class lvalue, const: + S const cs{}; +// (void) const_cast<S>(cs); + (void) const_cast<S &>(cs); + (void) const_cast<S &&>(cs); +// (void) const_cast<S const>(cs); + (void) const_cast<S const &>(cs); // expected-error {{redundant const_cast from 'const S' lvalue to 'const S &' lvalue [loplugin:redundantcast]}} + (void) const_cast<S const &&>(cs); + + // class xvalue, non-const: +// (void) const_cast<S>(nsx()); +// (void) const_cast<S &>(nsx()); + (void) const_cast<S &&>(nsx()); // expected-error {{redundant const_cast from 'S' xvalue to 'S &&' xvalue [loplugin:redundantcast]}} +// (void) const_cast<S const>(nsx()); +// (void) const_cast<S const &>(nsx()); + (void) const_cast<S const &&>(nsx()); + + // class xvalue, const: +// (void) const_cast<S>(csx()); +// (void) const_cast<S &>(csx()); + (void) const_cast<S &&>(csx()); +// (void) const_cast<S const>(csx()); +// (void) const_cast<S const &>(csx()); + (void) const_cast<S const &&>(csx()); // expected-error {{redundant const_cast from 'const S' xvalue to 'const S &&' xvalue [loplugin:redundantcast]}} + + // class prvalue, non-const: +// (void) const_cast<S>(nsr()); +// (void) const_cast<S &>(nsr()); + (void) const_cast<S &&>(nsr()); +// (void) const_cast<S const>(nsr()); +// (void) const_cast<S const &>(nsr()); + (void) const_cast<S const &&>(nsr()); + + // class prvalue, const: +// (void) const_cast<S>(csr()); +// (void) const_cast<S &>(csr()); + (void) const_cast<S &&>(csr()); +// (void) const_cast<S const>(csr()); +// (void) const_cast<S const &>(csr()); + (void) const_cast<S const &&>(csr()); } void testStaticCast() { commit ff77fdbe29f0cf93f93d6e75ba5ca101e2e321a5 Author: Stephan Bergmann <sberg...@redhat.com> Date: Fri Jun 2 13:31:31 2017 +0200 Improved loplugin:redundantcast const_cast handling: dbaccess Change-Id: I7a40549601a9a396c8adec16806b1f76f78734a2 diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx index 03b15fe59ca9..6146002303ad 100644 --- a/dbaccess/source/core/dataaccess/ModelImpl.cxx +++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx @@ -1297,8 +1297,8 @@ ODatabaseModelImpl::EmbeddedMacros ODatabaseModelImpl::determineEmbeddedMacros() { m_aEmbeddedMacros.reset( eDocumentWideMacros ); } - else if ( lcl_hasObjectsWithMacros_nothrow( const_cast< ODatabaseModelImpl& >( *this ), E_FORM ) - || lcl_hasObjectsWithMacros_nothrow( const_cast< ODatabaseModelImpl& >( *this ), E_REPORT ) + else if ( lcl_hasObjectsWithMacros_nothrow( *this, E_FORM ) + || lcl_hasObjectsWithMacros_nothrow( *this, E_REPORT ) ) { m_aEmbeddedMacros.reset( eSubDocumentMacros ); diff --git a/dbaccess/source/ui/querydesign/JoinController.cxx b/dbaccess/source/ui/querydesign/JoinController.cxx index 0c92646b4ba6..28f72782687f 100644 --- a/dbaccess/source/ui/querydesign/JoinController.cxx +++ b/dbaccess/source/ui/querydesign/JoinController.cxx @@ -116,7 +116,7 @@ bool AddTableDialogContext::allowQueries() const bool AddTableDialogContext::allowAddition() const { - return const_cast< OJoinController& >( m_rController ).getJoinView()->getTableView()->IsAddAllowed(); + return m_rController.getJoinView()->getTableView()->IsAddAllowed(); } void AddTableDialogContext::addTableWindow( const OUString& _rQualifiedTableName, const OUString& _rAliasName ) commit 12f933a81d4b036cee5f33f146237b6f5f58c85e Author: Stephan Bergmann <sberg...@redhat.com> Date: Fri Jun 2 13:31:24 2017 +0200 Improved loplugin:redundantcast const_cast handling: sc Change-Id: I6984f6d5273cd2a7dcc87524cfde9d03c7a5b20d diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 45f211cbedd1..565ce5be9afe 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -1124,7 +1124,7 @@ void ScColumn::CopyStaticToDocument( { SCROW nRow = nCurRow + i; - ScFormulaCell& rFC = const_cast<ScFormulaCell&>(**itData); + ScFormulaCell& rFC = **itData; if (rFC.GetDirty() && pDocument->GetAutoCalc()) rFC.Interpret(); @@ -1643,7 +1643,7 @@ public: std::advance(itEnd, nDataSize); for (; it != itEnd; ++it, ++nRow) - cloneFormulaCell(nRow, const_cast<ScFormulaCell&>(**it)); + cloneFormulaCell(nRow, **it); } break; default: diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index e846e381d250..162fbcff9b95 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -2297,7 +2297,7 @@ public: size_t nPrevRow = 0, nThisRow = node.position + nOffset; for (; it != itEnd; ++it, nPrevRow = nThisRow, ++nThisRow) { - ScFormulaCell& rCell = const_cast<ScFormulaCell&>(**it); + ScFormulaCell& rCell = **it; if (rCell.IsEmpty()) { diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 249489b01e64..d481a354f4a2 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -973,7 +973,7 @@ public: std::advance(itEnd, nDataSize); for (SCROW nSrcRow = nSrcRow1; it != itEnd; ++it, ++nSrcRow) { - ScFormulaCell& rSrcCell = const_cast<ScFormulaCell&>(**it); + ScFormulaCell& rSrcCell = **it; bool bForceFormula = false; if (bBoolean) { diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx index cff34f262ad8..15b46a9d7d5b 100644 --- a/sc/source/core/tool/interpr6.cxx +++ b/sc/source/core/tool/interpr6.cxx @@ -253,7 +253,7 @@ public: { double fVal = 0.0; FormulaError nErr = FormulaError::NONE; - ScFormulaCell& rCell = const_cast<ScFormulaCell&>(*(*it)); + ScFormulaCell& rCell = *(*it); if (!rCell.GetErrorOrValue(nErr, fVal)) // The cell has neither error nor value. Perhaps string result. continue; @@ -303,7 +303,7 @@ public: std::advance(itEnd, nDataSize); for (; it != itEnd; ++it) { - ScFormulaCell& rCell = const_cast<ScFormulaCell&>(**it); + ScFormulaCell& rCell = **it; if (rCell.IsValueNoError()) ++mnCount; } commit 883d4be1615458d1ce7bb7bd102f244b068119dc Author: Stephan Bergmann <sberg...@redhat.com> Date: Fri Jun 2 13:31:20 2017 +0200 Improved loplugin:redundantcast const_cast handling: sd Change-Id: I3a34d9192ff405ee14df0f9b6c40ead80faa1738 diff --git a/sd/source/ui/unoidl/SdUnoOutlineView.cxx b/sd/source/ui/unoidl/SdUnoOutlineView.cxx index 1449026e967c..3ad8b504486f 100644 --- a/sd/source/ui/unoidl/SdUnoOutlineView.cxx +++ b/sd/source/ui/unoidl/SdUnoOutlineView.cxx @@ -127,7 +127,7 @@ Any SAL_CALL SdUnoOutlineView::getFastPropertyValue ( { case DrawController::PROPERTY_CURRENTPAGE: { - SdPage* pPage = const_cast<OutlineViewShell&>(mrOutlineViewShell).GetActualPage(); + SdPage* pPage = mrOutlineViewShell.GetActualPage(); if (pPage != nullptr) aValue <<= pPage->getUnoPage(); } commit 434ccf734addc8f26b955bcc418fe3047e0cfdfc Author: Stephan Bergmann <sberg...@redhat.com> Date: Fri Jun 2 13:31:15 2017 +0200 Improved loplugin:redundantcast const_cast handling: svx Change-Id: I6a504593e6331c75053bce4743d2671277c9204f diff --git a/svx/source/form/fmpgeimp.cxx b/svx/source/form/fmpgeimp.cxx index e97ba5832b8f..e4eb82b6531a 100644 --- a/svx/source/form/fmpgeimp.cxx +++ b/svx/source/form/fmpgeimp.cxx @@ -149,7 +149,7 @@ namespace void FmFormPageImpl::initFrom( FmFormPageImpl& i_foreignImpl ) { // clone the Forms collection - const Reference< css::form::XForms > xForeignForms( const_cast< FmFormPageImpl& >( i_foreignImpl ).getForms( false ) ); + const Reference< css::form::XForms > xForeignForms( i_foreignImpl.getForms( false ) ); if ( !xForeignForms.is() ) return; commit b6aac4e597263f16703feeeab4007c96ad5ac209 Author: Stephan Bergmann <sberg...@redhat.com> Date: Fri Jun 2 13:31:09 2017 +0200 Improved loplugin:redundantcast const_cast handling: sw Change-Id: I7a420427f7be1b42907272b314cf3b864e1fe7ba diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 585c8c81afc2..4694f5593d10 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -674,7 +674,7 @@ namespace // iterate over relevant redlines and decide for each whether it should // be saved, or split + saved - SwRedlineTable& rRedlineTable = const_cast<SwRedlineTable&>( pDoc->getIDocumentRedlineAccess().GetRedlineTable() ); + SwRedlineTable& rRedlineTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable(); for( ; nCurrentRedline < rRedlineTable.size(); nCurrentRedline++ ) { SwRangeRedline* pCurrent = rRedlineTable[ nCurrentRedline ]; diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx index 1864b6e1d6ba..3787418e9e78 100644 --- a/sw/source/core/doc/tblafmt.cxx +++ b/sw/source/core/doc/tblafmt.cxx @@ -1278,7 +1278,7 @@ SwTableAutoFormatTable::SwTableAutoFormatTable() { aBox.SetLine( i <= 3 ? &aLn : nullptr, SvxBoxItemLine::TOP ); aBox.SetLine( (3 == ( i & 3 )) ? &aLn : nullptr, SvxBoxItemLine::RIGHT ); - const_cast<SwBoxAutoFormat&>(pNew->GetBoxFormat( i )).SetBox( aBox ); + pNew->GetBoxFormat( i ).SetBox( aBox ); } pNew->SetUserDefined(false); diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 9a1bdbd8eea2..90b952ab52e7 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -4212,7 +4212,7 @@ void SwDoc::ClearLineNumAttrs( SwPosition & rPos ) && pTextNode->GetText().isEmpty()) { const SfxPoolItem* pFormatItem = nullptr; - SfxItemSet rSet( const_cast<SwAttrPool&>(pTextNode->GetDoc()->GetAttrPool()), + SfxItemSet rSet( pTextNode->GetDoc()->GetAttrPool(), RES_PARATR_BEGIN, RES_PARATR_END - 1, 0); pTextNode->SwContentNode::GetAttr( rSet ); diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx index cf10f8805a96..bfb1b8be3b8b 100644 --- a/sw/source/core/layout/flowfrm.cxx +++ b/sw/source/core/layout/flowfrm.cxx @@ -1828,7 +1828,7 @@ bool SwFlowFrame::MoveFwd( bool bMakePage, bool bPageBreak, bool bMoveAlways ) ( !m_rThis.IsTabFrame() || ( m_rThis.GetUpper()->IsInTab() && m_rThis.GetUpper()->FindTabFrame()->IsFwdMoveAllowed() ) ) && - nullptr != const_cast<SwFrame&>(m_rThis).GetNextCellLeaf() ) + nullptr != m_rThis.GetNextCellLeaf() ) { bNoFwd = false; } diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index e7e91f37ad7e..f25c70d3250a 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -1172,7 +1172,7 @@ void SwTextNode::Update( if (!pCursor) continue; - SwIndex& rIndex = const_cast<SwIndex&>(pCursor->Start()->nContent); + SwIndex& rIndex = pCursor->Start()->nContent; if (&pCursor->Start()->nNode.GetNode() == this && rIndex.GetIndex() == rPos.GetIndex()) { // The cursor position of this other shell is exactly our insert position. diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 740f645701e9..34f94890c817 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -867,11 +867,11 @@ bool BaseFrameProperties_Impl::FillBaseProperties(SfxItemSet& rToSet, const SfxI if(pRelH ) bRet &= ((SfxPoolItem&)aFrameSz).PutValue(*pRelH, MID_FRMSIZE_REL_HEIGHT); if (pRelHRelation) - bRet &= const_cast<SwFormatFrameSize&>(aFrameSz).PutValue(*pRelHRelation, MID_FRMSIZE_REL_HEIGHT_RELATION); + bRet &= aFrameSz.PutValue(*pRelHRelation, MID_FRMSIZE_REL_HEIGHT_RELATION); if(pRelW ) bRet &= ((SfxPoolItem&)aFrameSz).PutValue(*pRelW, MID_FRMSIZE_REL_WIDTH); if (pRelWRelation) - bRet &= const_cast<SwFormatFrameSize&>(aFrameSz).PutValue(*pRelWRelation, MID_FRMSIZE_REL_WIDTH_RELATION); + bRet &= aFrameSz.PutValue(*pRelWRelation, MID_FRMSIZE_REL_WIDTH_RELATION); if(pSyncWidth) bRet &= ((SfxPoolItem&)aFrameSz).PutValue(*pSyncWidth, MID_FRMSIZE_IS_SYNC_WIDTH_TO_HEIGHT); if(pSyncHeight) diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index dbdd6e13d971..123f4405fa40 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -1994,7 +1994,7 @@ void SwXDocumentIndexMark::Impl::InsertTOXMark( m_pDoc = pDoc; m_pTOXMark = & pTextAttr->GetTOXMark(); const_cast<SwTOXMark*>(m_pTOXMark)->Add(this); - const_cast<SwTOXType &>(rTOXType).Add(& m_TypeDepend); + rTOXType.Add(& m_TypeDepend); } uno::Reference< text::XTextRange > SAL_CALL diff --git a/sw/source/core/view/vdraw.cxx b/sw/source/core/view/vdraw.cxx index 8ef6860d25ff..969f2e033e23 100644 --- a/sw/source/core/view/vdraw.cxx +++ b/sw/source/core/view/vdraw.cxx @@ -138,7 +138,7 @@ void SwViewShellImp::PaintLayer( const SdrLayerID _nLayerID, if (pPrintData) { // hide drawings but not form controls (form controls are handled elsewhere) - SdrView &rSdrView = const_cast< SdrView & >(GetPageView()->GetView()); + SdrView &rSdrView = GetPageView()->GetView(); rSdrView.setHideDraw( !pPrintData->IsPrintDraw() ); } basegfx::B2IRectangle const pageFrame( diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index d7dbd1d575bf..add0ba01426b 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -3286,7 +3286,7 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t SwFrameFormat *pTableFormat = pTable->GetFrameFormat( ); const SwFormatFrameSize &rSize = pTableFormat->GetFrameSize(); int nWidthPercent = rSize.GetWidthPercent(); - uno::Reference<beans::XPropertySet> xPropertySet(SwXTextTables::GetObject(const_cast<SwTableFormat&>(*pTable->GetFrameFormat( ))),uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPropertySet(SwXTextTables::GetObject(*pTable->GetFrameFormat( )),uno::UNO_QUERY); bool isWidthRelative = false; xPropertySet->getPropertyValue("IsWidthRelative") >>= isWidthRelative; diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index a4f312bac620..76af28b3dc49 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -3831,7 +3831,7 @@ void RtfAttributeOutput::FlyFrameOLEReplacement(const SwFlyFrameFormat* pFlyFram bool RtfAttributeOutput::FlyFrameOLEMath(const SwFlyFrameFormat* pFlyFrameFormat, SwOLENode& rOLENode, const Size& rSize) { - uno::Reference <embed::XEmbeddedObject> xObj(const_cast<SwOLENode&>(rOLENode).GetOLEObj().GetOleRef()); + uno::Reference <embed::XEmbeddedObject> xObj(rOLENode.GetOLEObj().GetOleRef()); sal_Int64 nAspect = rOLENode.GetAspect(); svt::EmbeddedObjectRef aObjRef(xObj, nAspect); SvGlobalName aObjName(aObjRef->getClassID()); commit 6d96156778b11ceb076d1e51c38379be44fb06da Author: Stephan Bergmann <sberg...@redhat.com> Date: Fri Jun 2 13:31:05 2017 +0200 Improved loplugin:redundantcast const_cast handling: vcl Change-Id: I7ecc72d4a5a68db8755ff0147fa1326e33827a82 diff --git a/vcl/unx/generic/fontmanager/fontsubst.cxx b/vcl/unx/generic/fontmanager/fontsubst.cxx index 2f050c8c23be..f55d4cbb7d0c 100644 --- a/vcl/unx/generic/fontmanager/fontsubst.cxx +++ b/vcl/unx/generic/fontmanager/fontsubst.cxx @@ -105,7 +105,7 @@ bool FcPreMatchSubstitution::FindFontSubstitute( FontSelectPattern &rFontSelData //just on the name, cache map all the input and all the output not just map //from original selection to output fontname FontSelectPattern& rPatternAttributes = rFontSelData; - CachedFontMapType &rCachedFontMap = const_cast<CachedFontMapType &>(maCachedFontMap); + CachedFontMapType &rCachedFontMap = maCachedFontMap; CachedFontMapType::iterator itr = std::find_if(rCachedFontMap.begin(), rCachedFontMap.end(), equal(rPatternAttributes)); if (itr != rCachedFontMap.end()) { commit 903bd0db0977f35c7d2cdfd82783591bbd374a7e Author: Stephan Bergmann <sberg...@redhat.com> Date: Fri Jun 2 13:31:00 2017 +0200 Improved loplugin:redundantcast const_cast handling: xmloff Change-Id: I61873d1a1d26db0b757b242c395f9bf96702b055 diff --git a/xmloff/source/draw/XMLShapeStyleContext.cxx b/xmloff/source/draw/XMLShapeStyleContext.cxx index 9941adce2b00..78ee86693777 100644 --- a/xmloff/source/draw/XMLShapeStyleContext.cxx +++ b/xmloff/source/draw/XMLShapeStyleContext.cxx @@ -79,7 +79,7 @@ void XMLShapeStyleContext::SetAttribute( sal_uInt16 nPrefixKey, const OUString& { if( !GetName().isEmpty() && !GetDisplayName().isEmpty() && GetName() != GetDisplayName() ) { - const_cast< SvXMLImport&>( GetImport() ). + GetImport(). AddStyleDisplayName( GetFamily(), GetName(), GetDisplayName() ); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits