From 5f8a2dc3985c705e822b0c3ed5eb1e53bcfbd95e Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Sun, 7 Apr 2013 14:18:28 +0200 Subject: removeforwardstringdecl clang plugin has been used, move it Change-Id: I3bccfa773448e17ac3c8ece6b99f85c6d399b0cf --- compilerplugins/clang/removeforwardstringdecl.cxx | 75 ---------------------- compilerplugins/clang/removeforwardstringdecl.hxx | 34 ---------- .../clang/store/removeforwardstringdecl.cxx | 75 ++++++++++++++++++++++ .../clang/store/removeforwardstringdecl.hxx | 34 ++++++++++ 4 files changed, 109 insertions(+), 109 deletions(-) delete mode 100644 compilerplugins/clang/removeforwardstringdecl.cxx delete mode 100644 compilerplugins/clang/removeforwardstringdecl.hxx create mode 100644 compilerplugins/clang/store/removeforwardstringdecl.cxx create mode 100644 compilerplugins/clang/store/removeforwardstringdecl.hxx (limited to 'compilerplugins') diff --git a/compilerplugins/clang/removeforwardstringdecl.cxx b/compilerplugins/clang/removeforwardstringdecl.cxx deleted file mode 100644 index 8350c777abd1..000000000000 --- a/compilerplugins/clang/removeforwardstringdecl.cxx +++ /dev/null @@ -1,75 +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 "removeforwardstringdecl.hxx" - -/* -This is a rewriter. - -Remove all forward declarations of rtl strings. I.e. 'namespace rtl { class OUString; }' etc. -*/ - -namespace loplugin -{ - -RemoveForwardStringDecl::RemoveForwardStringDecl( CompilerInstance& compiler, Rewriter& rewriter ) - : RewritePlugin( compiler, rewriter ) - { - } - -void RemoveForwardStringDecl::run() - { - TraverseDecl( compiler.getASTContext().getTranslationUnitDecl()); - } - -bool RemoveForwardStringDecl::VisitNamespaceDecl( NamespaceDecl* declaration ) - { - if( ignoreLocation( declaration )) - return true; - if( declaration->getQualifiedNameAsString() != "rtl" ) - return true; - bool canRemove = true; - for( NamespaceDecl::decl_iterator it = declaration->decls_begin(); - it != declaration->decls_end(); - ++it ) - { - if( *it != NULL ) - { - if( !tryRemoveStringForwardDecl( *it )) - canRemove = false; - } - } - if( canRemove ) // contained only forward decls that we removed - removeText( declaration->getSourceRange(), RemoveLineIfEmpty ); - return true; - } - -bool RemoveForwardStringDecl::tryRemoveStringForwardDecl( const Decl* decl ) - { - const CXXRecordDecl* classdecl = dyn_cast< CXXRecordDecl >( decl ); - if( classdecl == NULL ) - return false; - if( !classdecl->isFreeStanding() || classdecl->isCompleteDefinition()) - return false; // not a simple forward declaration - if( classdecl->getName() == "OString" || classdecl->getName() == "OUString" - || classdecl->getName() == "OStringBuffer" || classdecl->getName() == "OUStringBuffer" - || classdecl->getName() == "OStringHash" || classdecl->getName() == "OUStringHash" - || classdecl->getName() == "OStringLiteral" || classdecl->getName() == "OUStringLiteral" ) - { - removeText( SourceRange( classdecl->getOuterLocStart(), classdecl->getLocEnd()), - RemoveLineIfEmpty | RemoveWholeStatement ); - return true; - } - return false; - } - -static Plugin::Registration< RemoveForwardStringDecl > X( "removeforwardstringdecl" ); - -} // namespace diff --git a/compilerplugins/clang/removeforwardstringdecl.hxx b/compilerplugins/clang/removeforwardstringdecl.hxx deleted file mode 100644 index b57afebe2db3..000000000000 --- a/compilerplugins/clang/removeforwardstringdecl.hxx +++ /dev/null @@ -1,34 +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 REMOVEFORWARDSTRINGDECL_H -#define REMOVEFORWARDSTRINGDECL_H - -#include "plugin.hxx" - -namespace loplugin -{ - -class RemoveForwardStringDecl - : public RecursiveASTVisitor< RemoveForwardStringDecl > - , public RewritePlugin - { - public: - explicit RemoveForwardStringDecl( CompilerInstance& compiler, Rewriter& rewriter ); - virtual void run(); - bool VisitNamespaceDecl( NamespaceDecl* declaration ); - private: - bool tryRemoveStringForwardDecl( const Decl* decl ); - }; - -} // namespace - -#endif // REMOVEFORWARDSTRINGDECL_H - diff --git a/compilerplugins/clang/store/removeforwardstringdecl.cxx b/compilerplugins/clang/store/removeforwardstringdecl.cxx new file mode 100644 index 000000000000..8350c777abd1 --- /dev/null +++ b/compilerplugins/clang/store/removeforwardstringdecl.cxx @@ -0,0 +1,75 @@ +/* + * 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 "removeforwardstringdecl.hxx" + +/* +This is a rewriter. + +Remove all forward declarations of rtl strings. I.e. 'namespace rtl { class OUString; }' etc. +*/ + +namespace loplugin +{ + +RemoveForwardStringDecl::RemoveForwardStringDecl( CompilerInstance& compiler, Rewriter& rewriter ) + : RewritePlugin( compiler, rewriter ) + { + } + +void RemoveForwardStringDecl::run() + { + TraverseDecl( compiler.getASTContext().getTranslationUnitDecl()); + } + +bool RemoveForwardStringDecl::VisitNamespaceDecl( NamespaceDecl* declaration ) + { + if( ignoreLocation( declaration )) + return true; + if( declaration->getQualifiedNameAsString() != "rtl" ) + return true; + bool canRemove = true; + for( NamespaceDecl::decl_iterator it = declaration->decls_begin(); + it != declaration->decls_end(); + ++it ) + { + if( *it != NULL ) + { + if( !tryRemoveStringForwardDecl( *it )) + canRemove = false; + } + } + if( canRemove ) // contained only forward decls that we removed + removeText( declaration->getSourceRange(), RemoveLineIfEmpty ); + return true; + } + +bool RemoveForwardStringDecl::tryRemoveStringForwardDecl( const Decl* decl ) + { + const CXXRecordDecl* classdecl = dyn_cast< CXXRecordDecl >( decl ); + if( classdecl == NULL ) + return false; + if( !classdecl->isFreeStanding() || classdecl->isCompleteDefinition()) + return false; // not a simple forward declaration + if( classdecl->getName() == "OString" || classdecl->getName() == "OUString" + || classdecl->getName() == "OStringBuffer" || classdecl->getName() == "OUStringBuffer" + || classdecl->getName() == "OStringHash" || classdecl->getName() == "OUStringHash" + || classdecl->getName() == "OStringLiteral" || classdecl->getName() == "OUStringLiteral" ) + { + removeText( SourceRange( classdecl->getOuterLocStart(), classdecl->getLocEnd()), + RemoveLineIfEmpty | RemoveWholeStatement ); + return true; + } + return false; + } + +static Plugin::Registration< RemoveForwardStringDecl > X( "removeforwardstringdecl" ); + +} // namespace diff --git a/compilerplugins/clang/store/removeforwardstringdecl.hxx b/compilerplugins/clang/store/removeforwardstringdecl.hxx new file mode 100644 index 000000000000..b57afebe2db3 --- /dev/null +++ b/compilerplugins/clang/store/removeforwardstringdecl.hxx @@ -0,0 +1,34 @@ +/* + * 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 REMOVEFORWARDSTRINGDECL_H +#define REMOVEFORWARDSTRINGDECL_H + +#include "plugin.hxx" + +namespace loplugin +{ + +class RemoveForwardStringDecl + : public RecursiveASTVisitor< RemoveForwardStringDecl > + , public RewritePlugin + { + public: + explicit RemoveForwardStringDecl( CompilerInstance& compiler, Rewriter& rewriter ); + virtual void run(); + bool VisitNamespaceDecl( NamespaceDecl* declaration ); + private: + bool tryRemoveStringForwardDecl( const Decl* decl ); + }; + +} // namespace + +#endif // REMOVEFORWARDSTRINGDECL_H + -- cgit