diff options
author | Noel Grandin <noel@peralex.com> | 2015-07-20 10:19:58 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2015-07-20 11:56:11 +0000 |
commit | e103bf6cfd19470b84e5742bcd649d93f26d198c (patch) | |
tree | 260d39124c8385e68fffd159dc8de84d5b601aea /compilerplugins | |
parent | editeng: replace boost::ptr_vector with std::vector<std::unique_ptr>> (diff) | |
download | core-e103bf6cfd19470b84e5742bcd649d93f26d198c.tar.gz core-e103bf6cfd19470b84e5742bcd649d93f26d198c.zip |
loplugin:unusedmethods dbaccess
Change-Id: Ifa16acc6d90ebd4f56c5662959010f6228228cb5
Reviewed-on: https://gerrit.libreoffice.org/17209
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/unusedmethods.cxx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/compilerplugins/clang/unusedmethods.cxx b/compilerplugins/clang/unusedmethods.cxx index 6627fe90a0cc..848f0bfd302c 100644 --- a/compilerplugins/clang/unusedmethods.cxx +++ b/compilerplugins/clang/unusedmethods.cxx @@ -71,6 +71,7 @@ public: bool VisitFunctionDecl( const FunctionDecl* decl ); bool VisitDeclRefExpr( const DeclRefExpr* ); bool VisitCXXConstructExpr( const CXXConstructExpr* ); + bool VisitVarDecl( const VarDecl* ); }; static std::string niceName(const FunctionDecl* functionDecl) @@ -252,6 +253,31 @@ bool UnusedMethods::VisitDeclRefExpr( const DeclRefExpr* declRefExpr ) return true; } +// this is for declarations of static variables that involve a template +bool UnusedMethods::VisitVarDecl( const VarDecl* varDecl ) +{ + varDecl = varDecl->getCanonicalDecl(); + // 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( varDecl->getLocStart() ); + if( compiler.getSourceManager().isInSystemHeader( expansionLoc )) + return true; + + if (varDecl->getStorageClass() != SC_Static) + return true; + const CXXRecordDecl* recordDecl = varDecl->getType()->getAsCXXRecordDecl(); + if (!recordDecl) + return true; + if (!recordDecl->getTemplateInstantiationPattern()) + return true; + + for( CXXRecordDecl::ctor_iterator it = recordDecl->ctor_begin(); it != recordDecl->ctor_end(); ++it) + TraverseCXXConstructorDecl(*it); + for( CXXRecordDecl::method_iterator it = recordDecl->method_begin(); it != recordDecl->method_end(); ++it) + TraverseCXXMethodDecl(*it); + return true; +} + loplugin::Plugin::Registration< UnusedMethods > X("unusedmethods", false); } |