From 108a95630d5f4a8cf8aa075cee950a75d2628dfe Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Sat, 2 Feb 2013 18:39:10 +0100 Subject: move clang plugin that's no longer needed But still keep it in case it'd be needed again, or simply as a starting reference. Change-Id: If519e1320e1bd6dce7746b57172324b33504051e --- compilerplugins/clang/lclstaticfix.cxx | 54 ---------------------------- compilerplugins/clang/lclstaticfix.hxx | 32 ----------------- compilerplugins/clang/store/README | 3 ++ compilerplugins/clang/store/lclstaticfix.cxx | 54 ++++++++++++++++++++++++++++ compilerplugins/clang/store/lclstaticfix.hxx | 32 +++++++++++++++++ 5 files changed, 89 insertions(+), 86 deletions(-) delete mode 100644 compilerplugins/clang/lclstaticfix.cxx delete mode 100644 compilerplugins/clang/lclstaticfix.hxx create mode 100644 compilerplugins/clang/store/README create mode 100644 compilerplugins/clang/store/lclstaticfix.cxx create mode 100644 compilerplugins/clang/store/lclstaticfix.hxx (limited to 'compilerplugins') diff --git a/compilerplugins/clang/lclstaticfix.cxx b/compilerplugins/clang/lclstaticfix.cxx deleted file mode 100644 index e966139dbaa1..000000000000 --- a/compilerplugins/clang/lclstaticfix.cxx +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * Based on LLVM/Clang. - * - * This file is distributed under the University of Illinois Open Source - * License. See LICENSE.TXT for details. - * - */ - -#include "lclstaticfix.hxx" - -#include -#include - -/* -This is a rewriter. - -Check all lcl_ functions and prepend static if needed. -*/ - -namespace loplugin -{ - -LclStaticFix::LclStaticFix( ASTContext& context, Rewriter& rewriter ) - : RewritePlugin( context, rewriter ) - { - } - -void LclStaticFix::run() - { - TraverseDecl( context.getTranslationUnitDecl()); - } - -bool LclStaticFix::VisitFunctionDecl( FunctionDecl* declaration ) - { - if( ignoreLocation( declaration )) - return true; - if( declaration->isCXXClassMember()) - return true; - if( declaration->getStorageClass() == SC_Static ) - return true; - string name = declaration->getQualifiedNameAsString(); - if( name.find( "::" ) != string::npos ) - return true; - if( name.compare( 0, 4, "lcl_" ) != 0 ) - return true; - insertText( declaration->getLocStart(), "static " ); - return true; - } - -static Plugin::Registration< LclStaticFix > X( "lclstaticfix" ); - -} // namespace diff --git a/compilerplugins/clang/lclstaticfix.hxx b/compilerplugins/clang/lclstaticfix.hxx deleted file mode 100644 index 64e5b2919461..000000000000 --- a/compilerplugins/clang/lclstaticfix.hxx +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * Based on LLVM/Clang. - * - * This file is distributed under the University of Illinois Open Source - * License. See LICENSE.TXT for details. - * - */ - -#ifndef LCLSTATICFIX_H -#define LCLSTATICFIX_H - -#include "plugin.hxx" - -namespace loplugin -{ - -class LclStaticFix - : public RecursiveASTVisitor< LclStaticFix > - , public RewritePlugin - { - public: - explicit LclStaticFix( ASTContext& context, Rewriter& rewriter ); - virtual void run(); - bool VisitFunctionDecl( FunctionDecl* declaration ); - }; - -} // namespace - -#endif // POSTFIXINCREMENTFIX_H - diff --git a/compilerplugins/clang/store/README b/compilerplugins/clang/store/README new file mode 100644 index 000000000000..b562544128f2 --- /dev/null +++ b/compilerplugins/clang/store/README @@ -0,0 +1,3 @@ +This plugin actions are not used. They are still kept in case they would be useful again +(they can be activated again by simply moving them back in the clang/ source directory) +or simply as a reference when writing new plugins. diff --git a/compilerplugins/clang/store/lclstaticfix.cxx b/compilerplugins/clang/store/lclstaticfix.cxx new file mode 100644 index 000000000000..e966139dbaa1 --- /dev/null +++ b/compilerplugins/clang/store/lclstaticfix.cxx @@ -0,0 +1,54 @@ +/* + * This file is part of the LibreOffice project. + * + * Based on LLVM/Clang. + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + */ + +#include "lclstaticfix.hxx" + +#include +#include + +/* +This is a rewriter. + +Check all lcl_ functions and prepend static if needed. +*/ + +namespace loplugin +{ + +LclStaticFix::LclStaticFix( ASTContext& context, Rewriter& rewriter ) + : RewritePlugin( context, rewriter ) + { + } + +void LclStaticFix::run() + { + TraverseDecl( context.getTranslationUnitDecl()); + } + +bool LclStaticFix::VisitFunctionDecl( FunctionDecl* declaration ) + { + if( ignoreLocation( declaration )) + return true; + if( declaration->isCXXClassMember()) + return true; + if( declaration->getStorageClass() == SC_Static ) + return true; + string name = declaration->getQualifiedNameAsString(); + if( name.find( "::" ) != string::npos ) + return true; + if( name.compare( 0, 4, "lcl_" ) != 0 ) + return true; + insertText( declaration->getLocStart(), "static " ); + return true; + } + +static Plugin::Registration< LclStaticFix > X( "lclstaticfix" ); + +} // namespace diff --git a/compilerplugins/clang/store/lclstaticfix.hxx b/compilerplugins/clang/store/lclstaticfix.hxx new file mode 100644 index 000000000000..64e5b2919461 --- /dev/null +++ b/compilerplugins/clang/store/lclstaticfix.hxx @@ -0,0 +1,32 @@ +/* + * This file is part of the LibreOffice project. + * + * Based on LLVM/Clang. + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + */ + +#ifndef LCLSTATICFIX_H +#define LCLSTATICFIX_H + +#include "plugin.hxx" + +namespace loplugin +{ + +class LclStaticFix + : public RecursiveASTVisitor< LclStaticFix > + , public RewritePlugin + { + public: + explicit LclStaticFix( ASTContext& context, Rewriter& rewriter ); + virtual void run(); + bool VisitFunctionDecl( FunctionDecl* declaration ); + }; + +} // namespace + +#endif // POSTFIXINCREMENTFIX_H + -- cgit