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 RecursiveASTVisitor
< StaticAnonymous
>
24 explicit StaticAnonymous( const InstantiationData
& data
);
25 virtual void run() override
;
26 bool VisitFunctionDecl( FunctionDecl
* func
);
30 StaticAnonymous::StaticAnonymous( const InstantiationData
& data
)
35 void StaticAnonymous::run()
37 TraverseDecl( compiler
.getASTContext().getTranslationUnitDecl());
41 bool StaticAnonymous::VisitFunctionDecl( FunctionDecl
* func
)
44 if( ignoreLocation( func
) )
46 if( func
-> isInAnonymousNamespace () )
48 if ( !isa
<CXXMethodDecl
>(func
) && !func
->isInExternCContext() )
50 if(func
-> getStorageClass() == SC_Static
)
52 report( DiagnosticsEngine::Warning
,
53 "redundant 'static' keyword in unnamed namespace",
62 // Register the plugin action with the LO plugin handling.
63 static Plugin::Registration
< StaticAnonymous
> X( "staticanonymous",true);
67 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */