bump product version to 6.3.0.0.beta1
[LibreOffice.git] / compilerplugins / clang / staticanonymous.cxx
blobf31499af6f73a95b323c3fafad35a7698f2e907d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * Based on LLVM/Clang.
7 */
8 #include "plugin.hxx"
11 This is a compile check.
13 Warns about functions with static keyword in an unnamed namespace.
16 namespace loplugin
19 class StaticAnonymous
20 : public loplugin::FilteringPlugin<StaticAnonymous>
22 public:
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 ) )
44 return true;
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));
58 return true;
61 // Register the plugin action with the LO plugin handling.
62 static Plugin::Registration< StaticAnonymous > X( "staticanonymous",true);
64 } // namespace
66 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */