[Libreoffice-commits] core.git: compilerplugins/clang cppuhelper/source
compilerplugins/clang/mergeclasses.results |1 cppuhelper/source/factory.cxx | 327 +++-- 2 files changed, 127 insertions(+), 201 deletions(-) New commits: commit e001703df46d601a9ba21512a259c1caf266edac Author: Stephan Bergmann AuthorDate: Thu Jan 12 22:39:58 2023 +0100 Commit: Stephan Bergmann CommitDate: Fri Jan 13 07:50:57 2023 + Merge OSingleFactoryHelper into OFactoryComponentHelper Change-Id: I7faf7a3ad54c80bd3c53525c92c26c0f980110f9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145423 Tested-by: Jenkins Reviewed-by: Stephan Bergmann diff --git a/compilerplugins/clang/mergeclasses.results b/compilerplugins/clang/mergeclasses.results index 1682b3ea21bf..7b002c436974 100644 --- a/compilerplugins/clang/mergeclasses.results +++ b/compilerplugins/clang/mergeclasses.results @@ -289,7 +289,6 @@ merge cppcanvas::PolyPolygon with cppcanvas::internal::ImplPolyPolygon merge cppcanvas::Renderer with cppcanvas::internal::ImplRenderer merge cppcanvas::SpriteCanvas with cppcanvas::internal::ImplSpriteCanvas merge cppcanvas::internal::ImplSprite with cppcanvas::internal::ImplCustomSprite -merge cppu::(anonymous namespace)::OSingleFactoryHelper with cppu::(anonymous namespace)::OFactoryComponentHelper merge cppu::PropertySetMixinImpl with cppu::PropertySetMixin merge dbaccess::IPropertyContainer with dbaccess::OColumn merge dbaccess::IRefreshListener with dbaccess::OConnection diff --git a/cppuhelper/source/factory.cxx b/cppuhelper/source/factory.cxx index 37ac44ffa1a5..6d5cdc7b23bc 100644 --- a/cppuhelper/source/factory.cxx +++ b/cppuhelper/source/factory.cxx @@ -58,192 +58,6 @@ namespace cppu namespace { -class OSingleFactoryHelper -: public XServiceInfo -, public XSingleServiceFactory -, public lang::XSingleComponentFactory -, public XUnloadingPreference -{ -public: -OSingleFactoryHelper( -const Reference & rServiceManager, -OUString aImplementationName_, -ComponentInstantiation pCreateFunction_, -ComponentFactoryFunc fptr, -const Sequence< OUString > * pServiceNames_ ) -: xSMgr( rServiceManager ) -, pCreateFunction( pCreateFunction_ ) -, m_fptr( fptr ) -, aImplementationName(std::move( aImplementationName_ )) -{ -if( pServiceNames_ ) -aServiceNames = *pServiceNames_; -} - -virtual ~OSingleFactoryHelper(); - -// XInterface -Any SAL_CALL queryInterface( const Type & rType ) override; - -// XSingleServiceFactory -Reference SAL_CALL createInstance() override; -virtual Reference SAL_CALL createInstanceWithArguments(const Sequence& Arguments) override; -// XSingleComponentFactory -virtual Reference< XInterface > SAL_CALL createInstanceWithContext( -Reference< XComponentContext > const & xContext ) override; -virtual Reference< XInterface > SAL_CALL createInstanceWithArgumentsAndContext( -Sequence< Any > const & rArguments, -Reference< XComponentContext > const & xContext ) override; - -// XServiceInfo -OUString SAL_CALL getImplementationName() override; -sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; -Sequence< OUString > SAL_CALL getSupportedServiceNames() override; - -protected: -/** - * Create an instance specified by the factory. The one instance logic is implemented - * in the createInstance and createInstanceWithArguments methods. - * @return the newly created instance. Do not return a previous (one instance) instance. - * @throw css::uno::Exception - * @throw css::uno::RuntimeException - */ -virtual Reference createInstanceEveryTime( -Reference< XComponentContext > const & xContext ); - -Reference xSMgr; -ComponentInstantiation pCreateFunction; -ComponentFactoryFunc m_fptr; -Sequence< OUString > aServiceNames; -OUString aImplementationName; - -private: -css::uno::Reference createInstanceWithArgumentsEveryTime( -css::uno::Sequence const & rArguments, -css::uno::Reference const & xContext); -}; - -} - -OSingleFactoryHelper::~OSingleFactoryHelper() -{ -} - - -Any OSingleFactoryHelper::queryInterface( const Type & rType ) -{ -return ::cppu::queryInterface( -rType, -static_cast< XSingleComponentFactory * >( this ), -static_cast< XSingleServiceFactory * >( this ), -static_cast< XServiceInfo * >( this ) , -static_cast< XUnloadingPreference * >( this )); -} - -// OSingleFactoryHelper -Reference OSingleFactoryHelper::createInstanceEveryTime( -Reference< XComponentContext > const & xContext ) -{ -if (m_fptr) -{ -return (*m_fptr)( xContext ); -} -if( pCreateFunction ) -{ -if (xContext.is()) -{ -Reference< lang::XMultiServiceFactory > xCon
[Libreoffice-commits] core.git: compilerplugins/clang cppuhelper/source drawinglayer/source formula/source i18nlangtag/source i18npool/qa idlc/source l10ntools/source lingucomponent/source linguistic/
compilerplugins/clang/reducevarscope.cxx | 550 + compilerplugins/clang/test/reducevarscope.cxx | 96 ++ cppuhelper/source/servicemanager.cxx |2 drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx |2 formula/source/core/api/FormulaCompiler.cxx|2 formula/source/core/api/token.cxx |3 i18nlangtag/source/languagetag/languagetag.cxx |3 i18npool/qa/cppunit/test_breakiterator.cxx |6 idlc/source/idlc.cxx |2 idlc/source/options.cxx|2 l10ntools/source/cfgmerge.cxx |2 l10ntools/source/helpmerge.cxx |3 lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx |3 linguistic/source/hyphdsp.cxx |2 sc/qa/unit/ucalc_sort.cxx |4 slideshow/source/engine/shapes/drawinglayeranimation.cxx |2 solenv/CompilerTest_compilerplugins_clang.mk |1 sot/source/sdstor/stgavl.cxx |3 stoc/source/defaultregistry/defaultregistry.cxx|9 sw/source/core/txtnode/fntcache.cxx|4 writerfilter/source/dmapper/PropertyMap.cxx|4 xmlhelp/source/cxxhelp/provider/databases.cxx |2 22 files changed, 672 insertions(+), 35 deletions(-) New commits: commit 242320d303d43a34ce2255a07783fbd51e253cd0 Author: Noel Grandin AuthorDate: Sat Sep 5 11:53:35 2020 +0200 Commit: Noel Grandin CommitDate: Tue Nov 10 17:11:00 2020 +0100 new loplugin:reducevarscope Change-Id: Iefe922c2e0d605114d54673d63eccc5e4abd545d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102143 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/compilerplugins/clang/reducevarscope.cxx b/compilerplugins/clang/reducevarscope.cxx new file mode 100644 index ..c293fd432e6a --- /dev/null +++ b/compilerplugins/clang/reducevarscope.cxx @@ -0,0 +1,550 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "plugin.hxx" +#include "check.hxx" +#include "clang/AST/CXXInheritance.h" +#include "clang/AST/StmtVisitor.h" + +// Original idea from mike kaganski. +// Look for variables that can have their scoped reduced, which makes the code easier to read. + +// TODO when dealing with vars that are referenced in multiple child blocks, the check is very primitive +// and could be greatly improved. + +namespace +{ +class ReduceVarScope : public loplugin::FilteringPlugin +{ +public: +explicit ReduceVarScope(loplugin::InstantiationData const& data) +: FilteringPlugin(data) +{ +} + +bool preRun() override +{ +if (!compiler.getLangOpts().CPlusPlus) +return false; +// ignore some files with problematic macros +std::string fn(handler.getMainFileName()); +loplugin::normalizeDotDotInFilePath(fn); +// some declarations look better all together +if (fn == SRCDIR "/package/source/manifest/ManifestExport.cxx") +return false; +// storing pointer to OUString internal data +if (fn == SRCDIR "/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx" +|| fn == SRCDIR "/sc/source/filter/excel/xestyle.cxx" +|| fn == SRCDIR "/sw/source/filter/html/htmlflywriter.cxx" +|| fn == SRCDIR "/unoxml/source/dom/element.cxx" +|| fn == SRCDIR "/unoxml/source/dom/document.cxx" +|| fn == SRCDIR "/sd/source/filter/eppt/pptx-animations.cxx") +return false; +if (fn == SRCDIR "/sal/qa/rtl/strings/nonconstarray.cxx") +return false; +return true; +} + +virtual void run() override +{ +if (!preRun()) +return; + +TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); +postRun(); +} + +virtual void postRun() override +{ +for (auto const& pair : maVarDeclMap) +{ +auto varDecl = pair.first; +auto const& depthInfo = pair.second; +if (depthInfo.maDeclBlockPath.size() == depthInfo.maCommonBlockPath.size()) +continue; +if (maVarDeclToIgnoreSet.find(varDecl) != maVarDeclToIgnoreSet.end()) +continue; +auto it = maVarUseSourceRangeMap.find(varDecl); +
[Libreoffice-commits] core.git: compilerplugins/clang cppuhelper/source framework/source include/framework l10ntools/source lingucomponent/source pyuno/source salhelper/source sfx2/source solenv/bin s
compilerplugins/clang/constparams.cxx |5 + cppuhelper/source/implbase_ex.cxx |2 +- cppuhelper/source/servicemanager.cxx|2 +- cppuhelper/source/servicemanager.hxx|2 +- framework/source/fwe/classes/sfxhelperfunctions.cxx |2 +- include/framework/sfxhelperfunctions.hxx|2 +- l10ntools/source/localize.cxx |2 +- lingucomponent/source/lingutil/lingutil.cxx |4 ++-- pyuno/source/module/pyuno_dlopenwrapper.c |2 +- salhelper/source/timer.cxx |4 ++-- sfx2/source/doc/doctemplates.cxx|1 + solenv/bin/concat-deps.c|4 ++-- soltools/cpp/_include.c |2 +- soltools/cpp/_lex.c |2 +- soltools/cpp/_macro.c |2 +- soltools/cpp/_mcrvalid.c|2 +- soltools/cpp/_tokens.c |8 soltools/cpp/cpp.h | 16 soltools/mkdepend/cppsetup.c|2 +- soltools/mkdepend/def.h | 16 soltools/mkdepend/include.c | 10 +- soltools/mkdepend/main.c|8 soltools/mkdepend/parse.c |6 +++--- soltools/mkdepend/pr.c |2 +- 24 files changed, 57 insertions(+), 51 deletions(-) New commits: commit ec340697d682bd7d0a361c8c701e513329c032bd Author: Noel Grandin Date: Fri Jul 21 11:52:04 2017 +0200 loplugin:constparams in soltools and various Change-Id: I5e8e4a9a31aa7c3ff54cc7ce137d08770ea297e1 Reviewed-on: https://gerrit.libreoffice.org/40279 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/compilerplugins/clang/constparams.cxx b/compilerplugins/clang/constparams.cxx index d2d779c4d1c4..15936c9e593d 100644 --- a/compilerplugins/clang/constparams.cxx +++ b/compilerplugins/clang/constparams.cxx @@ -108,6 +108,11 @@ bool ConstParams::VisitFunctionDecl(FunctionDecl * functionDecl) || name == "file_write" || name == "SalMainPipeExchangeSignal_impl" || name.startswith("SbRtl_") +|| name == "my_if_errors" +|| name == "my_eval_defined" +|| name == "my_eval_variable" + // #ifdef win32 +|| name == "convert_slashes" // UNO component entry points || name.endswith("component_getFactory") // in Scheduler::, wants to loop until a reference to a bool becomes true diff --git a/cppuhelper/source/implbase_ex.cxx b/cppuhelper/source/implbase_ex.cxx index 6025db018543..2b7b792e718a 100644 --- a/cppuhelper/source/implbase_ex.cxx +++ b/cppuhelper/source/implbase_ex.cxx @@ -163,7 +163,7 @@ bool recursivelyFindType( } static inline void * queryDeepNoXInterface( -typelib_TypeDescriptionReference * pDemandedTDR, class_data * cd, void * that ) +typelib_TypeDescriptionReference const * pDemandedTDR, class_data * cd, void * that ) { type_entry * pEntries = getTypeEntries( cd ); sal_Int32 nTypes = cd->m_nTypes; diff --git a/cppuhelper/source/servicemanager.cxx b/cppuhelper/source/servicemanager.cxx index e3ddaee00798..5faee9a129b0 100644 --- a/cppuhelper/source/servicemanager.cxx +++ b/cppuhelper/source/servicemanager.cxx @@ -756,7 +756,7 @@ void cppuhelper::ServiceManager::addSingletonContextEntries( void cppuhelper::ServiceManager::loadImplementation( css::uno::Reference< css::uno::XComponentContext > const & context, -std::shared_ptr< Data::Implementation > & implementation) +std::shared_ptr< Data::Implementation > const & implementation) { assert(implementation.get() != nullptr); { diff --git a/cppuhelper/source/servicemanager.hxx b/cppuhelper/source/servicemanager.hxx index 1252b9dab37f..e36cff41e984 100644 --- a/cppuhelper/source/servicemanager.hxx +++ b/cppuhelper/source/servicemanager.hxx @@ -218,7 +218,7 @@ public: void loadImplementation( css::uno::Reference< css::uno::XComponentContext > const & context, -std::shared_ptr< Data::Implementation > & implementation); +std::shared_ptr< Data::Implementation > const & implementation); private: virtual ~ServiceManager() override; diff --git a/framework/source/fwe/classes/sfxhelperfunctions.cxx b/framework/source/fwe/classes/sfxhelperfunctions.cxx index 4926874cee64..fd2684b4991a 100644 --- a/framework/source/fwe/classes/sfxhelperfunctions.cxx +++ b/framework/source/fwe/classes/sfxhelperfunctions.cxx @@ -88,7 +88,7 @@ pfunc_getRefreshToolbars SAL_CALL SetRefreshToolbars( pfunc_getRefreshToolbars p return pOldFunc; } -void SAL_CALL RefreshToolbars( css::uno::Referenc
[Libreoffice-commits] core.git: compilerplugins/clang cppuhelper/source cui/source forms/source reportdesign/source sc/qa sd/source sw/qa sw/source xmloff/source
compilerplugins/clang/stringconstant.cxx | 11 ++- compilerplugins/clang/test/stringconstant.cxx |3 +++ cppuhelper/source/unourl.cxx | 25 ++--- cui/source/tabpages/tpbitmap.cxx |2 +- forms/source/component/GroupManager.cxx |2 +- reportdesign/source/ui/report/ViewsWindow.cxx |2 +- sc/qa/extras/check_data_pilot_table.cxx |2 +- sc/qa/extras/scdatapilottableobj.cxx |2 +- sc/qa/extras/scnamedrangeobj.cxx |2 +- sc/qa/extras/sctablesheetsobj.cxx |2 +- sd/source/ui/dlg/navigatr.cxx |2 +- sw/qa/core/uwriter.cxx|2 +- sw/qa/extras/uiwriter/uiwriter.cxx|4 ++-- sw/source/filter/basflt/iodetect.cxx |8 sw/source/uibase/dochdl/gloshdl.cxx |2 +- sw/source/uibase/uiview/view.cxx |2 +- xmloff/source/forms/elementimport.cxx |2 +- 17 files changed, 41 insertions(+), 34 deletions(-) New commits: commit dce867e8c4863c969eea3515a988630b74708a43 Author: Noel Grandin Date: Tue Jan 31 13:24:13 2017 +0200 loplugin:stringconstant handle calls to constructors with one arg Change-Id: Ide9148a908bef46ba14640dfa6f556beaf6e3f60 Reviewed-on: https://gerrit.libreoffice.org/33772 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/compilerplugins/clang/stringconstant.cxx b/compilerplugins/clang/stringconstant.cxx index 32382461..9ae672a 100644 --- a/compilerplugins/clang/stringconstant.cxx +++ b/compilerplugins/clang/stringconstant.cxx @@ -66,6 +66,10 @@ bool hasOverloads(FunctionDecl const * decl, unsigned arguments) { if (f != nullptr && f->getMinRequiredArguments() <= arguments && f->getNumParams() >= arguments) { +auto consDecl = dyn_cast(f); +if (consDecl && consDecl->isCopyConstructor()) { +break; +} ++n; if (n == 2) { return true; @@ -1058,12 +1062,17 @@ bool StringConstant::VisitCXXConstructExpr(CXXConstructExpr const * expr) { return true; } -std::string file(compiler.getSourceManager().getFilename( +StringRef file(compiler.getSourceManager().getFilename( compiler.getSourceManager().getSpellingLoc(expr->getLocStart(; if (file == SRCDIR "/sal/qa/rtl/oustringbuffer/test_oustringbuffer_tostring.cxx") { return true; } +// there is some template magic here I don't know how to work around +if (file.startswith(SRCDIR "/connectivity")) +{ +return true; +} if (isInUnoIncludeFile(expr->getLocStart())) { return true; } diff --git a/compilerplugins/clang/test/stringconstant.cxx b/compilerplugins/clang/test/stringconstant.cxx index f2cf48c..392567f 100644 --- a/compilerplugins/clang/test/stringconstant.cxx +++ b/compilerplugins/clang/test/stringconstant.cxx @@ -18,6 +18,7 @@ extern void foo(OUString const &); // expected-error {{extern prototype in main struct Foo { Foo(OUString const &, int) {} +Foo(OUString const &) {} }; int main() { @@ -57,6 +58,8 @@ int main() { foo(OUString("xxx")); // expected-error {{in call of 'foo', replace 'OUString' constructed from a string literal directly with the string literal [loplugin:stringconstant}} Foo aFoo(OUString("xxx"), 1); // expected-error {{in call of 'Foo::Foo', replace 'OUString' constructed from a string literal directly with the string literal}} (void)aFoo; +Foo aFoo2(OUString("xxx")); // expected-error {{in call of 'Foo::Foo', replace 'OUString' constructed from a string literal directly with the string literal}} +(void)aFoo2; } diff --git a/cppuhelper/source/unourl.cxx b/cppuhelper/source/unourl.cxx index b73f176..8895119 100644 --- a/cppuhelper/source/unourl.cxx +++ b/cppuhelper/source/unourl.cxx @@ -79,7 +79,7 @@ inline UnoUrlDescriptor::Impl::Impl(rtl::OUString const & rDescriptor) case STATE_NAME0: if (bEnd || !isAlphanum(c)) throw rtl::MalformedUriException( -rtl::OUString("UNO URL contains bad descriptor name")); +"UNO URL contains bad descriptor name"); nStart = i; eState = STATE_NAME; break; @@ -93,13 +93,13 @@ inline UnoUrlDescriptor::Impl::Impl(rtl::OUString const & rDescriptor) } else if (!isAlphanum(c)) throw rtl::MalformedUriException( -rtl::OUString("UNO URL contains bad descriptor name")); +"UNO URL contains bad descriptor name"); break; case STATE_KEY0: if (bEnd || !isAlphanum(c)) throw rtl::MalformedUriException( -rtl::OUString("UNO URL contains bad parameter key")); +