1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
11 This is a compile check.
13 Warns about functions with static keyword in an unnamed namespace.
20 : public loplugin::FilteringPlugin
<StaticAnonymous
>
23 explicit StaticAnonymous( const InstantiationData
& data
);
24 virtual void run() override
;
25 bool VisitFunctionDecl( FunctionDecl
* func
);
29 StaticAnonymous::StaticAnonymous( const InstantiationData
& data
)
30 : FilteringPlugin( data
)
34 void StaticAnonymous::run()
36 TraverseDecl( compiler
.getASTContext().getTranslationUnitDecl());
40 bool StaticAnonymous::VisitFunctionDecl( FunctionDecl
* func
)
43 if( ignoreLocation( func
) )
45 if( func
-> isInAnonymousNamespace () )
47 if ( !isa
<CXXMethodDecl
>(func
) && !func
->isInExternCContext() )
49 if(func
-> getStorageClass() == SC_Static
)
51 report( DiagnosticsEngine::Warning
,
52 "redundant 'static' keyword in unnamed namespace",
53 compat::getBeginLoc(func
));
61 // Register the plugin action with the LO plugin handling.
62 static Plugin::Registration
< StaticAnonymous
> X( "staticanonymous",true);
66 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */