diff options
-rw-r--r-- | compilerplugins/clang/redundantcast.cxx | 74 | ||||
-rw-r--r-- | cppu/source/helper/purpenv/helper_purpenv_Proxy.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/core/dataaccess/intercept.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/app/AppDetailView.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/app/sdmod1.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/sidebar/PreviewValueSet.cxx | 3 | ||||
-rw-r--r-- | sfx2/source/appl/newhelp.cxx | 2 | ||||
-rw-r--r-- | shell/source/unix/sysshell/recently_used_file.cxx | 4 | ||||
-rw-r--r-- | svtools/source/graphic/grfmgr.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/gtk/window/gtksalframe.cxx | 2 |
10 files changed, 55 insertions, 42 deletions
diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx index 3abf66a853b3..474dafa11e85 100644 --- a/compilerplugins/clang/redundantcast.cxx +++ b/compilerplugins/clang/redundantcast.cxx @@ -207,45 +207,59 @@ bool RedundantCast::VisitImplicitCastExpr(const ImplicitCastExpr * expr) { bool RedundantCast::VisitCXXReinterpretCastExpr( CXXReinterpretCastExpr const * expr) { - if (ignoreLocation(expr) - || !expr->getSubExpr()->getType()->isVoidPointerType()) - { - return true; - } - auto t = expr->getType()->getAs<PointerType>(); - if (t == nullptr || !t->getPointeeType()->isObjectType()) { + if (ignoreLocation(expr)) { return true; } - if (rewriter != nullptr) { - auto loc = expr->getLocStart(); - while (compiler.getSourceManager().isMacroArgExpansion(loc)) { - loc = compiler.getSourceManager().getImmediateMacroCallerLoc(loc); + if (expr->getSubExpr()->getType()->isVoidPointerType()) { + auto t = expr->getType()->getAs<PointerType>(); + if (t == nullptr || !t->getPointeeType()->isObjectType()) { + return true; } - if (compat::isMacroBodyExpansion(compiler, loc)) { - auto loc2 = expr->getLocEnd(); - while (compiler.getSourceManager().isMacroArgExpansion(loc2)) { - loc2 = compiler.getSourceManager().getImmediateMacroCallerLoc( - loc2); + if (rewriter != nullptr) { + auto loc = expr->getLocStart(); + while (compiler.getSourceManager().isMacroArgExpansion(loc)) { + loc = compiler.getSourceManager().getImmediateMacroCallerLoc( + loc); } - if (compat::isMacroBodyExpansion(compiler, loc2)) { - //TODO: check loc, loc2 are in same macro body expansion - loc = compiler.getSourceManager().getSpellingLoc(loc); + if (compat::isMacroBodyExpansion(compiler, loc)) { + auto loc2 = expr->getLocEnd(); + while (compiler.getSourceManager().isMacroArgExpansion(loc2)) { + loc2 = compiler.getSourceManager() + .getImmediateMacroCallerLoc(loc2); + } + if (compat::isMacroBodyExpansion(compiler, loc2)) { + //TODO: check loc, loc2 are in same macro body expansion + loc = compiler.getSourceManager().getSpellingLoc(loc); + } + } + auto s = compiler.getSourceManager().getCharacterData(loc); + auto n = Lexer::MeasureTokenLength( + loc, compiler.getSourceManager(), compiler.getLangOpts()); + std::string tok(s, n); + if (tok == "reinterpret_cast" && replaceText(loc, n, "static_cast")) + { + return true; } } - auto s = compiler.getSourceManager().getCharacterData(loc); - auto n = Lexer::MeasureTokenLength( - loc, compiler.getSourceManager(), compiler.getLangOpts()); - std::string tok(s, n); - if (tok == "reinterpret_cast" && replaceText(loc, n, "static_cast")) { + report( + DiagnosticsEngine::Warning, + "reinterpret_cast from %0 to %1 can be simplified to static_cast", + expr->getExprLoc()) + << expr->getSubExprAsWritten()->getType() << expr->getType() + << expr->getSourceRange(); + } else if (expr->getType()->isVoidPointerType()) { + auto t = expr->getSubExpr()->getType()->getAs<PointerType>(); + if (t == nullptr || !t->getPointeeType()->isObjectType()) { return true; } + report( + DiagnosticsEngine::Warning, + ("reinterpret_cast from %0 to %1 can be simplified to static_cast" + " or an implicit conversion"), + expr->getExprLoc()) + << expr->getSubExprAsWritten()->getType() << expr->getType() + << expr->getSourceRange(); } - report( - DiagnosticsEngine::Warning, - "reinterpret_cast from %0 to %1 can be simplified to static_cast", - expr->getExprLoc()) - << expr->getSubExprAsWritten()->getType() << expr->getType() - << expr->getSourceRange(); return true; } diff --git a/cppu/source/helper/purpenv/helper_purpenv_Proxy.cxx b/cppu/source/helper/purpenv/helper_purpenv_Proxy.cxx index e366b9478d58..90ee6b052a6f 100644 --- a/cppu/source/helper/purpenv/helper_purpenv_Proxy.cxx +++ b/cppu/source/helper/purpenv/helper_purpenv_Proxy.cxx @@ -242,7 +242,7 @@ extern "C" { static void s_releaseAndRevoke_v(va_list * pParam) uno_ExtEnvironment * pEnv = va_arg(*pParam, uno_ExtEnvironment *); uno_Interface * pUnoI = va_arg(*pParam, uno_Interface *); - pEnv->revokeInterface(pEnv, reinterpret_cast<void *>(pUnoI)); + pEnv->revokeInterface(pEnv, pUnoI); pUnoI->release(pUnoI); }} diff --git a/dbaccess/source/core/dataaccess/intercept.cxx b/dbaccess/source/core/dataaccess/intercept.cxx index 96751d7e88fc..d0560ab92c38 100644 --- a/dbaccess/source/core/dataaccess/intercept.cxx +++ b/dbaccess/source/core/dataaccess/intercept.cxx @@ -176,7 +176,7 @@ void SAL_CALL OInterceptor::dispatch( const URL& _URL,const Sequence<PropertyVal DispatchHelper* pHelper = new DispatchHelper; pHelper->aArguments = Arguments; pHelper->aURL = _URL; - Application::PostUserEvent( LINK( this, OInterceptor, OnDispatch ), reinterpret_cast< void* >( pHelper ) ); + Application::PostUserEvent( LINK( this, OInterceptor, OnDispatch ), pHelper ); return; } } diff --git a/dbaccess/source/ui/app/AppDetailView.cxx b/dbaccess/source/ui/app/AppDetailView.cxx index 8fa399e363d2..325cc9b4c521 100644 --- a/dbaccess/source/ui/app/AppDetailView.cxx +++ b/dbaccess/source/ui/app/AppDetailView.cxx @@ -496,7 +496,7 @@ void OTasksWindow::fillTaskEntryList( const TaskEntryList& _rList ) for ( TaskEntryList::const_iterator pTask = _rList.begin(); pTask != aEnd; ++pTask, ++pImages ) { SvTreeListEntry* pEntry = m_aCreation->InsertEntry( pTask->sTitle ); - pEntry->SetUserData( reinterpret_cast< void* >( new TaskEntry( *pTask ) ) ); + pEntry->SetUserData( new TaskEntry( *pTask ) ); Image aImage = Image( *pImages ); m_aCreation->SetExpandedEntryBmp( pEntry, aImage ); diff --git a/sd/source/ui/app/sdmod1.cxx b/sd/source/ui/app/sdmod1.cxx index 47a6bc004336..448dd30947f9 100644 --- a/sd/source/ui/app/sdmod1.cxx +++ b/sd/source/ui/app/sdmod1.cxx @@ -927,7 +927,7 @@ OutlineToImpressFinalizer::OutlineToImpressFinalizer ( const ErrCode nErrorCode ( rBytes.ReadAt( nReadPosition, - reinterpret_cast<void*>(pBuffer.get()), + pBuffer.get(), nBufferSize, &nReadByteCount)); @@ -951,7 +951,7 @@ OutlineToImpressFinalizer::OutlineToImpressFinalizer ( // Append the read bytes to the end of the memory stream. if (nReadByteCount > 0) { - mpStream->Write(reinterpret_cast<void*>(pBuffer.get()), nReadByteCount); + mpStream->Write(pBuffer.get(), nReadByteCount); nReadPosition += nReadByteCount; } } diff --git a/sd/source/ui/sidebar/PreviewValueSet.cxx b/sd/source/ui/sidebar/PreviewValueSet.cxx index 3e4a6f599541..7c1145cf9c60 100644 --- a/sd/source/ui/sidebar/PreviewValueSet.cxx +++ b/sd/source/ui/sidebar/PreviewValueSet.cxx @@ -55,8 +55,7 @@ void PreviewValueSet::SetRightMouseClickHandler (const Link<>& rLink) void PreviewValueSet::MouseButtonDown (const MouseEvent& rEvent) { if (rEvent.IsRight()) - maRightMouseClickHandler.Call(reinterpret_cast<void*>( - &const_cast<MouseEvent&>(rEvent))); + maRightMouseClickHandler.Call(&const_cast<MouseEvent&>(rEvent)); else ValueSet::MouseButtonDown (rEvent); diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx index 82fc78d3562a..207f8b483a78 100644 --- a/sfx2/source/appl/newhelp.cxx +++ b/sfx2/source/appl/newhelp.cxx @@ -590,7 +590,7 @@ namespace sfx2 { } #define NEW_ENTRY( url, bool ) \ - reinterpret_cast<void*>( new IndexEntry_Impl( url, bool ) ) + new IndexEntry_Impl( url, bool ) #define UNIFY_AND_INSERT_TOKEN( aToken ) \ it = aInfo.insert( sfx2::KeywordInfo::value_type( aToken, 0 ) ).first; \ diff --git a/shell/source/unix/sysshell/recently_used_file.cxx b/shell/source/unix/sysshell/recently_used_file.cxx index 08f96a389dbc..16b0a373ad1b 100644 --- a/shell/source/unix/sysshell/recently_used_file.cxx +++ b/shell/source/unix/sysshell/recently_used_file.cxx @@ -108,7 +108,7 @@ void recently_used_file::truncate(off_t length) size_t recently_used_file::read(char* buffer, size_t size) const { - size_t r = fread(reinterpret_cast<void*>(buffer), sizeof(char), size, file_); + size_t r = fread(buffer, sizeof(char), size, file_); if ((r < size) && ferror(file_)) throw "I/O error: read failed"; @@ -119,7 +119,7 @@ size_t recently_used_file::read(char* buffer, size_t size) const void recently_used_file::write(const char* buffer, size_t size) const { - if (size != fwrite(reinterpret_cast<const void*>(buffer), sizeof(char), size, file_)) + if (size != fwrite(buffer, sizeof(char), size, file_)) throw "I/O error: write failed"; } diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx index f6eae59e5281..a6ff51dc78c3 100644 --- a/svtools/source/graphic/grfmgr.cxx +++ b/svtools/source/graphic/grfmgr.cxx @@ -396,7 +396,7 @@ OString GraphicObject::GetUniqueID() const SvStream* GraphicObject::GetSwapStream() const { if( HasSwapStreamHdl() ) - return reinterpret_cast<SvStream*>( mpSwapStreamHdl->Call( const_cast<void*>(reinterpret_cast<const void*>(this)) ) ); + return reinterpret_cast<SvStream*>( mpSwapStreamHdl->Call( const_cast<void*>(static_cast<const void*>(this)) ) ); else return GRFMGR_AUTOSWAPSTREAM_NONE; } diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/window/gtksalframe.cxx index 32193bbddaed..357393328638 100644 --- a/vcl/unx/gtk/window/gtksalframe.cxx +++ b/vcl/unx/gtk/window/gtksalframe.cxx @@ -668,7 +668,7 @@ gboolean ensure_dbus_setup( gpointer data ) // Create menu model and action group attached to this frame. GMenuModel* pMenuModel = G_MENU_MODEL( g_lo_menu_new() ); - GActionGroup* pActionGroup = reinterpret_cast<GActionGroup*>(g_lo_action_group_new( reinterpret_cast< gpointer >( pSalFrame ) )); + GActionGroup* pActionGroup = reinterpret_cast<GActionGroup*>(g_lo_action_group_new( static_cast< gpointer >( pSalFrame ) )); // Generate menu paths. ::Window windowId = GDK_WINDOW_XID( gdkWindow ); |