1fd27a7931
I seem to have missed quite a few in
commit 9f4d23c151
filter out some of the AST in the plugins
This nets me another 14% improvement
Change-Id: I39b980b49ced560f768045dbedd3ddfef29306c1
Reviewed-on: https://gerrit.libreoffice.org/59501
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
66 lines
1.5 KiB
C++
66 lines
1.5 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/*
|
|
* This file is part of the LibreOffice project.
|
|
*
|
|
* Based on LLVM/Clang.
|
|
*
|
|
*/
|
|
#include "plugin.hxx"
|
|
|
|
/*
|
|
This is a compile check.
|
|
|
|
Warns about functions with static keyword in an unnamed namespace.
|
|
*/
|
|
|
|
namespace loplugin
|
|
{
|
|
|
|
class StaticAnonymous
|
|
: public loplugin::FilteringPlugin<StaticAnonymous>
|
|
{
|
|
public:
|
|
explicit StaticAnonymous( const InstantiationData& data );
|
|
virtual void run() override;
|
|
bool VisitFunctionDecl( FunctionDecl* func );
|
|
|
|
};
|
|
|
|
StaticAnonymous::StaticAnonymous( const InstantiationData& data )
|
|
: FilteringPlugin( data )
|
|
{
|
|
}
|
|
|
|
void StaticAnonymous::run()
|
|
{
|
|
TraverseDecl( compiler.getASTContext().getTranslationUnitDecl());
|
|
}
|
|
|
|
|
|
bool StaticAnonymous::VisitFunctionDecl( FunctionDecl* func )
|
|
|
|
{
|
|
if( ignoreLocation( func ) )
|
|
return true;
|
|
if( func -> isInAnonymousNamespace () )
|
|
{
|
|
if ( !isa<CXXMethodDecl>(func) && !func->isInExternCContext() )
|
|
{
|
|
if(func-> getStorageClass() == SC_Static)
|
|
{
|
|
report( DiagnosticsEngine::Warning,
|
|
"redundant 'static' keyword in unnamed namespace",
|
|
compat::getBeginLoc(func));
|
|
}
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
// Register the plugin action with the LO plugin handling.
|
|
static Plugin::Registration< StaticAnonymous > X( "staticanonymous",true);
|
|
|
|
} // namespace
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|