Kaydet (Commit) 5a7bf1b3 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Noel Grandin

loplugin:unusedmethods slideshow

Change-Id: I66b6cddb638a9fc1228d3ea9df5d112300a00eb3
Reviewed-on: https://gerrit.libreoffice.org/17128Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst 9b9e75a0
......@@ -35,9 +35,6 @@ to get it to work :-)
TODO deal with calls to superclass/member constructors from other constructors, so
we can find unused constructors
TODO deal with free functions and static methods
TODO track instantiations of template class constructor methods
TODO track instantiation of overridden methods when a template class is instantiated
*/
namespace {
......@@ -71,18 +68,20 @@ public:
}
bool VisitCallExpr(CallExpr* );
bool VisitCXXMethodDecl( const CXXMethodDecl* decl );
bool VisitFunctionDecl( const FunctionDecl* decl );
bool VisitDeclRefExpr( const DeclRefExpr* );
bool TraverseCXXMethodDecl(CXXMethodDecl * decl) { return RecursiveASTVisitor::TraverseCXXMethodDecl(decl); }
bool VisitCXXConstructExpr( const CXXConstructExpr* );
};
static std::string niceName(const CXXMethodDecl* functionDecl)
static std::string niceName(const FunctionDecl* functionDecl)
{
std::string s =
compat::getReturnType(*functionDecl).getCanonicalType().getAsString()
+ " " + functionDecl->getParent()->getQualifiedNameAsString()
+ "::" + functionDecl->getNameAsString()
+ "(";
+ " ";
if (isa<CXXMethodDecl>(functionDecl)) {
s += dyn_cast<CXXMethodDecl>(functionDecl)->getParent()->getQualifiedNameAsString() + "::";
}
s += functionDecl->getNameAsString() + "(";
bool bFirst = true;
for (const ParmVarDecl *pParmVarDecl : functionDecl->params()) {
if (bFirst)
......@@ -92,27 +91,30 @@ static std::string niceName(const CXXMethodDecl* functionDecl)
s += pParmVarDecl->getType().getCanonicalType().getAsString();
}
s += ")";
if (functionDecl->isConst()) {
if (isa<CXXMethodDecl>(functionDecl) && dyn_cast<CXXMethodDecl>(functionDecl)->isConst()) {
s += " const";
}
return s;
}
static void logCallToRootMethods(const CXXMethodDecl* decl)
static void logCallToRootMethods(const FunctionDecl* functionDecl)
{
// For virtual/overriding methods, we need to pretend we called the root method(s),
// so that they get marked as used.
decl = decl->getCanonicalDecl();
functionDecl = functionDecl->getCanonicalDecl();
bool bPrinted = false;
for(CXXMethodDecl::method_iterator it = decl->begin_overridden_methods();
it != decl->end_overridden_methods(); ++it)
{
logCallToRootMethods(*it);
bPrinted = true;
if (isa<CXXMethodDecl>(functionDecl)) {
// For virtual/overriding methods, we need to pretend we called the root method(s),
// so that they get marked as used.
const CXXMethodDecl* methodDecl = dyn_cast<CXXMethodDecl>(functionDecl);
for(CXXMethodDecl::method_iterator it = methodDecl->begin_overridden_methods();
it != methodDecl->end_overridden_methods(); ++it)
{
logCallToRootMethods(*it);
bPrinted = true;
}
}
if (!bPrinted)
{
std::string s = niceName(decl);
std::string s = niceName(functionDecl);
callSet.insert(s);
}
}
......@@ -154,18 +156,42 @@ bool UnusedMethods::VisitCallExpr(CallExpr* expr)
// if the function is templated. However, if we are inside a template function,
// calling another function on the same template, the same problem occurs.
// Rather than tracking all of that, just traverse anything we have not already traversed.
if (traversedFunctionSet.insert(calleeFunctionDecl->getQualifiedNameAsString()).second)
if (traversedFunctionSet.insert(niceName(calleeFunctionDecl)).second)
TraverseFunctionDecl(calleeFunctionDecl);
CXXMethodDecl* calleeMethodDecl = dyn_cast_or_null<CXXMethodDecl>(calleeFunctionDecl);
if (calleeMethodDecl == nullptr) {
logCallToRootMethods(calleeFunctionDecl);
return true;
}
bool UnusedMethods::VisitCXXConstructExpr(const CXXConstructExpr* expr)
{
// I don't use the normal ignoreLocation() here, because I __want__ to include files that are
// compiled in the $WORKDIR since they may refer to normal code
SourceLocation expansionLoc = compiler.getSourceManager().getExpansionLoc( expr->getLocStart() );
if( compiler.getSourceManager().isInSystemHeader( expansionLoc ))
return true;
const CXXConstructorDecl *consDecl = expr->getConstructor();
consDecl = consDecl->getCanonicalDecl();
if (consDecl->getTemplatedKind() == FunctionDecl::TemplatedKind::TK_NonTemplate
&& !consDecl->isFunctionTemplateSpecialization()) {
return true;
}
logCallToRootMethods(calleeMethodDecl);
// if we see a call to a constructor, it may effectively create a whole new class,
// if the constructor's class is templated.
if (!traversedFunctionSet.insert(niceName(consDecl)).second)
return true;
const CXXRecordDecl* parent = consDecl->getParent();
for( CXXRecordDecl::ctor_iterator it = parent->ctor_begin(); it != parent->ctor_end(); ++it)
TraverseCXXConstructorDecl(*it);
for( CXXRecordDecl::method_iterator it = parent->method_begin(); it != parent->method_end(); ++it)
TraverseCXXMethodDecl(*it);
return true;
}
bool UnusedMethods::VisitCXXMethodDecl( const CXXMethodDecl* functionDecl )
bool UnusedMethods::VisitFunctionDecl( const FunctionDecl* functionDecl )
{
// I don't use the normal ignoreLocation() here, because I __want__ to include files that are
// compiled in the $WORKDIR since they may refer to normal code
......@@ -174,12 +200,10 @@ bool UnusedMethods::VisitCXXMethodDecl( const CXXMethodDecl* functionDecl )
return true;
functionDecl = functionDecl->getCanonicalDecl();
const CXXMethodDecl* methodDecl = dyn_cast_or_null<CXXMethodDecl>(functionDecl);
// ignore method overrides, since the call will show up as being directed to the root method
if (functionDecl->size_overridden_methods() != 0 || functionDecl->hasAttr<OverrideAttr>()) {
return true;
}
// ignore static's for now. Would require generalising this plugin a little
if (functionDecl->isStatic()) {
if (methodDecl && (methodDecl->size_overridden_methods() != 0 || methodDecl->hasAttr<OverrideAttr>())) {
return true;
}
// ignore stuff that forms part of the stable URE interface
......@@ -187,7 +211,7 @@ bool UnusedMethods::VisitCXXMethodDecl( const CXXMethodDecl* functionDecl )
functionDecl->getNameInfo().getLoc()))) {
return true;
}
if (isStandardStuff(functionDecl->getParent()->getQualifiedNameAsString())) {
if (methodDecl && isStandardStuff(methodDecl->getParent()->getQualifiedNameAsString())) {
return true;
}
if (isa<CXXDestructorDecl>(functionDecl)) {
......@@ -196,7 +220,7 @@ bool UnusedMethods::VisitCXXMethodDecl( const CXXMethodDecl* functionDecl )
if (isa<CXXConstructorDecl>(functionDecl)) {
return true;
}
if (functionDecl->isDeleted()) {
if (methodDecl && methodDecl->isDeleted()) {
return true;
}
......@@ -214,10 +238,10 @@ bool UnusedMethods::VisitDeclRefExpr( const DeclRefExpr* declRefExpr )
return true;
const Decl* functionDecl = declRefExpr->getDecl();
if (!isa<CXXMethodDecl>(functionDecl)) {
if (!isa<FunctionDecl>(functionDecl)) {
return true;
}
logCallToRootMethods(dyn_cast<CXXMethodDecl>(functionDecl)->getCanonicalDecl());
logCallToRootMethods(dyn_cast<FunctionDecl>(functionDecl)->getCanonicalDecl());
return true;
}
......
......@@ -296,10 +296,6 @@ public:
*/
void pushTriangle(const glm::vec2& SlideLocation0,const glm::vec2& SlideLocation1,const glm::vec2& SlideLocation2);
/** clear all the vertices, normals, tex coordinates, and normals
*/
void clearTriangles();
/** guards against directly changing the vertices
@return
......@@ -307,18 +303,6 @@ public:
*/
const std::vector<glm::vec3>& getVertices() const {return Vertices;}
/** guards against directly changing the vertices
*/
const std::vector<glm::vec3>& getNormals() const {return Normals;}
/** guards against directly changing the vertices
@return
the list of Texture Coordinates
*/
const std::vector<glm::vec2>& getTexCoords() const {return TexCoords;}
/** list of Operations to be performed on this primitive.These operations will be called in the order they were pushed back in. In OpenGL this effectively uses the operations in the opposite order they were pushed back.
@return
......
......@@ -78,9 +78,6 @@ private:
bool isDependentSubsettedShape() const
{ return mpShapeSubset && !mbIsIndependentSubset; }
ShapeAttributeLayerHolder const & getAttributeLayerHolder() const
{ return maAttributeLayerHolder; }
private:
::com::sun::star::uno::Reference<
::com::sun::star::animations::XAnimate> mxAnimateNode;
......
......@@ -53,12 +53,6 @@ struct NodeContext
mbIsIndependentSubset( true )
{}
void dispose()
{
maContext.dispose();
mpMasterShapeSubset.reset();
}
/// Context as passed to createAnimationNode()
SlideShowContext maContext;
......
......@@ -45,13 +45,6 @@ public:
EventMultiplexer& rEventMultiplexer,
const UnoViewContainer& rViewContainer );
/** Shows the pointer symbol.
*/
void show() { setVisible(true); }
/** Hides the pointer symbol.
*/
void hide() { setVisible(false); }
/** Use this method to update the pointer's position
*/
void setVisible( const bool bVisible );
......
......@@ -120,8 +120,6 @@ public:
// MouseEventHandler
virtual bool handleMousePressed( awt::MouseEvent const & evt ) SAL_OVERRIDE;
virtual bool handleMouseReleased( awt::MouseEvent const & evt ) SAL_OVERRIDE;
virtual bool handleMouseEntered( awt::MouseEvent const & evt ) SAL_OVERRIDE;
virtual bool handleMouseExited( awt::MouseEvent const & evt ) SAL_OVERRIDE;
virtual bool handleMouseDragged( awt::MouseEvent const & evt ) SAL_OVERRIDE;
virtual bool handleMouseMoved( awt::MouseEvent const & evt ) SAL_OVERRIDE;
......@@ -541,18 +539,6 @@ bool RehearseTimingsActivity::MouseHandler::handleMouseReleased(
return false;
}
bool RehearseTimingsActivity::MouseHandler::handleMouseEntered(
awt::MouseEvent const & /*evt*/ )
{
return false;
}
bool RehearseTimingsActivity::MouseHandler::handleMouseExited(
awt::MouseEvent const & /*evt*/ )
{
return false;
}
bool RehearseTimingsActivity::MouseHandler::handleMouseDragged(
awt::MouseEvent const & evt )
{
......
......@@ -277,16 +277,6 @@ namespace slideshow
const VectorOfDocTreeNodes& rSubsets,
bool bIsVisible ) const;
/** Calc sprite size in pixel
Converts user coordinate system to device pixel, and
adds antialiasing border.
@param rUserSize
Size of the sprite in user coordinate system (doc coordinates)
*/
::basegfx::B2DSize calcSpriteSizePixel( const ::basegfx::B2DSize& rUserSize ) const;
enum{ MAX_RENDER_CACHE_ENTRIES=2 };
/** Retrieve a valid iterator to renderer cache entry
......
......@@ -182,18 +182,6 @@ bool ShapeManagerImpl::handleMouseReleased( awt::MouseEvent const& e )
return false; // did not handle this event
}
bool ShapeManagerImpl::handleMouseEntered( const awt::MouseEvent& )
{
// not used here
return false; // did not handle the event
}
bool ShapeManagerImpl::handleMouseExited( const awt::MouseEvent& )
{
// not used here
return false; // did not handle the event
}
bool ShapeManagerImpl::handleMouseDragged( const awt::MouseEvent& )
{
// not used here
......@@ -256,12 +244,6 @@ bool ShapeManagerImpl::update()
return false;
}
bool ShapeManagerImpl::update( ViewSharedPtr const& /*rView*/ )
{
// am not doing view-specific updates here.
return false;
}
bool ShapeManagerImpl::needsUpdate() const
{
if( mbEnabled && mpLayerManager )
......@@ -301,11 +283,6 @@ void ShapeManagerImpl::addHyperlinkArea( const HyperlinkAreaSharedPtr& rArea )
maHyperlinkShapes.insert(rArea);
}
void ShapeManagerImpl::removeHyperlinkArea( const HyperlinkAreaSharedPtr& rArea )
{
maHyperlinkShapes.erase(rArea);
}
AttributableShapeSharedPtr ShapeManagerImpl::getSubsetShape( const AttributableShapeSharedPtr& rOrigShape,
const DocTreeNode& rTreeNode )
{
......
......@@ -98,10 +98,6 @@ private:
::com::sun::star::awt::MouseEvent const& evt ) SAL_OVERRIDE;
virtual bool handleMouseReleased(
::com::sun::star::awt::MouseEvent const& evt ) SAL_OVERRIDE;
virtual bool handleMouseEntered(
::com::sun::star::awt::MouseEvent const& evt ) SAL_OVERRIDE;
virtual bool handleMouseExited(
::com::sun::star::awt::MouseEvent const& evt ) SAL_OVERRIDE;
virtual bool handleMouseDragged(
::com::sun::star::awt::MouseEvent const& evt ) SAL_OVERRIDE;
virtual bool handleMouseMoved(
......@@ -112,7 +108,6 @@ private:
virtual bool update() SAL_OVERRIDE;
virtual bool update( ViewSharedPtr const& rView ) SAL_OVERRIDE;
virtual bool needsUpdate() const SAL_OVERRIDE;
......@@ -126,7 +121,6 @@ private:
::com::sun::star::uno::Reference<
::com::sun::star::drawing::XShape > const & xShape ) const SAL_OVERRIDE;
virtual void addHyperlinkArea( const boost::shared_ptr<HyperlinkArea>& rArea ) SAL_OVERRIDE;
virtual void removeHyperlinkArea( const boost::shared_ptr<HyperlinkArea>& rArea ) SAL_OVERRIDE;
// SubsettableShapeManager interface
......
......@@ -296,29 +296,6 @@ namespace slideshow
return true;
}
virtual bool handleMouseEntered( const awt::MouseEvent& e ) SAL_OVERRIDE
{
if( !mbActive )
return false;
mbIsLastPointValid = true;
maLastPoint.setX( e.X );
maLastPoint.setY( e.Y );
return true;
}
virtual bool handleMouseExited( const awt::MouseEvent& ) SAL_OVERRIDE
{
if( !mbActive )
return false;
mbIsLastPointValid = false;
mbIsLastMouseDownPosValid = false;
return true;
}
virtual bool handleMouseDragged( const awt::MouseEvent& e ) SAL_OVERRIDE
{
if( !mbActive )
......
......@@ -184,9 +184,6 @@ private:
void addSprites( ViewEntry& rEntry );
static void clearViewEntry( ViewEntry& rEntry );
ViewsVecT::iterator lookupView( UnoViewSharedPtr const & pView );
ViewsVecT::const_iterator lookupView( UnoViewSharedPtr const & pView ) const;
SoundPlayerSharedPtr mpSoundPlayer;
EventMultiplexer& mrEventMultiplexer;
......
......@@ -65,8 +65,6 @@ class MouseEventHandler_ : public MouseEventHandler
public:
virtual bool handleMousePressed( awt::MouseEvent const& /*e*/ ) SAL_OVERRIDE { return false;}
virtual bool handleMouseReleased( awt::MouseEvent const& /*e*/) SAL_OVERRIDE { return false;}
virtual bool handleMouseEntered( awt::MouseEvent const& /*e*/ ) SAL_OVERRIDE { return false;}
virtual bool handleMouseExited( awt::MouseEvent const& /*e*/ ) SAL_OVERRIDE { return false; }
virtual bool handleMouseDragged( awt::MouseEvent const& /*e*/ ) SAL_OVERRIDE { return false;}
virtual bool handleMouseMoved( awt::MouseEvent const& /*e*/ ) SAL_OVERRIDE { return false; }
};
......
......@@ -86,13 +86,6 @@ namespace slideshow
::boost::shared_ptr< ::canvas::tools::ElapsedTime > const &
getTimer() const { return mpTimer; }
/** returns number of all activities, waiting, reinserted and dequeued
*/
std::size_t size() const
{
return maCurrentActivitiesWaiting.size() + maCurrentActivitiesReinsert.size() + maDequeuedActivities.size();
}
private:
::boost::shared_ptr< ::canvas::tools::ElapsedTime > mpTimer;
......
......@@ -68,10 +68,6 @@ namespace slideshow
NODETYPE_LOGICAL_CHARACTER_CELL=132
};
// classificators for above text entity types
static bool isLogicalNodeType( NodeType eType ) { return eType > 127; }
static bool isFormattingNodeType( NodeType eType ) { return eType > 0 && eType < 128; }
/** Create empty tree node
*/
DocTreeNode() :
......@@ -107,11 +103,8 @@ namespace slideshow
sal_Int32 getStartIndex() const { return mnStartIndex; }
sal_Int32 getEndIndex() const { return mnEndIndex; }
void setStartIndex( sal_Int32 nIndex ) { mnStartIndex = nIndex; }
void setEndIndex( sal_Int32 nIndex ) { mnEndIndex = nIndex; }
NodeType getType() const { return meType; }
void reset()
{
mnStartIndex = -1;
......
......@@ -34,7 +34,6 @@ struct EmptyBase
{
explicit EmptyClearableGuard(EmptyBase) {}
static void clear() {}
static void reset() {}
};
typedef EmptyGuard Guard;
......
......@@ -76,36 +76,6 @@ namespace slideshow
*/
virtual bool handleMouseReleased( const ::com::sun::star::awt::MouseEvent& e ) = 0;
/** Handle a mouse entered the view event.
@param e
The mouse event that occurred. The x,y coordinates of
the event are already transformed back to user
coordinate space, taking the inverse transform of the
view in which the event occurred.
@return true, if this handler has successfully
processed the pause event. When this method returns
false, possibly other, less prioritized handlers are
called, too.
*/
virtual bool handleMouseEntered( const ::com::sun::star::awt::MouseEvent& e ) = 0;
/** Handle a mouse exited the view event.
@param e
The mouse event that occurred. The x,y coordinates of
the event are already transformed back to user
coordinate space, taking the inverse transform of the
view in which the event occurred.
@return true, if this handler has successfully
processed the pause event. When this method returns
false, possibly other, less prioritized handlers are
called, too.
*/
virtual bool handleMouseExited( const ::com::sun::star::awt::MouseEvent& e ) = 0;
/** Handle a mouse was moved with a pressed button event.
@param e
......
......@@ -100,14 +100,6 @@ namespace slideshow
space coordinates.
*/
virtual void addHyperlinkArea( const boost::shared_ptr<HyperlinkArea>& rArea ) = 0;
/** Unregister given shape as a hyperlink target
@param rArea
Hyperlink sensitive area. Will cease to participate in
hyperlink region lookup.
*/
virtual void removeHyperlinkArea( const boost::shared_ptr<HyperlinkArea>& rArea ) = 0;
};
typedef ::boost::shared_ptr< ShapeManager > ShapeManagerSharedPtr;
......
......@@ -64,7 +64,6 @@ namespace slideshow
bool draw( const ::cppcanvas::CanvasSharedPtr& rCanvas ) const;
::basegfx::B2ISize getSize() const;
::basegfx::B2DPoint getOutputPos() const{return maOutputPos;}
void move( const ::basegfx::B2DPoint& rNewPos );
void clip( const ::basegfx::B2DPolyPolygon& rClipPoly );
......
......@@ -71,12 +71,8 @@ namespace slideshow
// the following parrots STL container concept methods
// ===================================================
std::size_t size() const { return maViews.size(); }
bool empty() const { return maViews.empty(); }
void clear() { maViews.clear(); }
UnoViewVector::iterator begin() { return maViews.begin(); }
UnoViewVector::const_iterator begin() const { return maViews.begin(); }
UnoViewVector::iterator end() { return maViews.end(); }
......
......@@ -46,13 +46,6 @@ namespace slideshow
*/
virtual bool update() = 0;
/** Perform the update action on given view only
@return true, if the update was performed
successfully, false otherwise.
*/
virtual bool update( ViewSharedPtr const& rView ) = 0;
/** Query whether updates are pending
@return true, if updates are pending. Calling update()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment