include/unoidl/unoidl.hxx | 79 +++++++++++------------ unoidl/source/legacyprovider.cxx | 11 +-- unoidl/source/sourceprovider-parser-requires.hxx | 13 ++- unoidl/source/sourceprovider-scanner.hxx | 25 +++---- unoidl/source/sourcetreeprovider.cxx | 3 unoidl/source/unoidl-check.cxx | 3 unoidl/source/unoidl-read.cxx | 4 - unoidl/source/unoidl-write.cxx | 4 - unoidl/source/unoidl.cxx | 9 +- unoidl/source/unoidlprovider.cxx | 13 ++- 10 files changed, 86 insertions(+), 78 deletions(-)
New commits: commit 75918e709a6d0e2b94b5e4fd9c2eb248ef912e00 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed May 18 12:05:34 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed May 18 14:45:27 2022 +0200 clang-tidy modernize-pass-by-value in unoidl Change-Id: Ibeb6aa656d6ed8b8ba78e800c9e28ba63ec0ec40 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134521 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/unoidl/unoidl.hxx b/include/unoidl/unoidl.hxx index e2ae024d06f7..7791fcd41c91 100644 --- a/include/unoidl/unoidl.hxx +++ b/include/unoidl/unoidl.hxx @@ -13,6 +13,7 @@ #include <sal/config.h> #include <cassert> +#include <utility> #include <vector> #include <osl/mutex.hxx> @@ -26,7 +27,7 @@ namespace unoidl { class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL NoSuchFileException final { public: - SAL_DLLPRIVATE NoSuchFileException(OUString const & uri): uri_(uri) {} + SAL_DLLPRIVATE NoSuchFileException(OUString uri): uri_(std::move(uri)) {} SAL_DLLPRIVATE NoSuchFileException(NoSuchFileException const & other): uri_(other.uri_) {} @@ -44,8 +45,8 @@ private: class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL FileFormatException final { public: SAL_DLLPRIVATE FileFormatException( - OUString const & uri, OUString const & detail): - uri_(uri), detail_(detail) + OUString uri, OUString detail): + uri_(std::move(uri)), detail_(std::move(detail)) {} SAL_DLLPRIVATE FileFormatException(FileFormatException const & other): @@ -67,9 +68,9 @@ private: struct AnnotatedReference { AnnotatedReference( - OUString const & theName, + OUString theName, std::vector< OUString > && theAnnotations): - name(theName), annotations(std::move(theAnnotations)) + name(std::move(theName)), annotations(std::move(theAnnotations)) {} OUString name; @@ -149,9 +150,9 @@ class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL EnumTypeEntity final : public Publisha public: struct Member { Member( - OUString const & theName, sal_Int32 theValue, + OUString theName, sal_Int32 theValue, std::vector< OUString >&& theAnnotations): - name(theName), value(theValue), annotations(std::move(theAnnotations)) + name(std::move(theName)), value(theValue), annotations(std::move(theAnnotations)) {} OUString name; @@ -179,9 +180,9 @@ private: class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL PlainStructTypeEntity final : public PublishableEntity { public: struct Member { - Member(OUString const & theName, OUString const & theType, + Member(OUString theName, OUString theType, std::vector< OUString >&& theAnnotations): - name(theName), type(theType), annotations(std::move(theAnnotations)) + name(std::move(theName)), type(std::move(theType)), annotations(std::move(theAnnotations)) {} OUString name; @@ -192,11 +193,11 @@ public: }; SAL_DLLPRIVATE PlainStructTypeEntity( - bool published, OUString const & directBase, + bool published, OUString directBase, std::vector< Member >&& directMembers, std::vector< OUString > && annotations): PublishableEntity(SORT_PLAIN_STRUCT_TYPE, published, std::move(annotations)), - directBase_(directBase), directMembers_(std::move(directMembers)) + directBase_(std::move(directBase)), directMembers_(std::move(directMembers)) {} const OUString& getDirectBase() const { return directBase_; } @@ -217,10 +218,10 @@ class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL PolymorphicStructTypeTemplateEntity fi public: struct Member { Member( - OUString const & theName, OUString const & theType, + OUString theName, OUString theType, bool theParameterized, std::vector< OUString >&& theAnnotations): - name(theName), type(theType), parameterized(theParameterized), + name(std::move(theName)), type(std::move(theType)), parameterized(theParameterized), annotations(std::move(theAnnotations)) {} @@ -258,9 +259,9 @@ class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ExceptionTypeEntity final : public Pub public: struct Member { Member( - OUString const & theName, OUString const & theType, + OUString theName, OUString theType, std::vector< OUString >&& theAnnotations): - name(theName), type(theType), annotations(std::move(theAnnotations)) + name(std::move(theName)), type(std::move(theType)), annotations(std::move(theAnnotations)) {} OUString name; @@ -271,11 +272,11 @@ public: }; SAL_DLLPRIVATE ExceptionTypeEntity( - bool published, OUString const & directBase, + bool published, OUString directBase, std::vector< Member >&& directMembers, std::vector< OUString >&& annotations): PublishableEntity(SORT_EXCEPTION_TYPE, published, std::move(annotations)), - directBase_(directBase), directMembers_(std::move(directMembers)) + directBase_(std::move(directBase)), directMembers_(std::move(directMembers)) {} const OUString& getDirectBase() const { return directBase_; } @@ -294,12 +295,12 @@ class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL InterfaceTypeEntity final : public Pub public: struct Attribute { Attribute( - OUString const & theName, OUString const & theType, + OUString theName, OUString theType, bool theBound, bool theReadOnly, std::vector< OUString >&& theGetExceptions, std::vector< OUString >&& theSetExceptions, std::vector< OUString >&& theAnnotations): - name(theName), type(theType), bound(theBound), + name(std::move(theName)), type(std::move(theType)), bound(theBound), readOnly(theReadOnly), getExceptions(std::move(theGetExceptions)), setExceptions(std::move(theSetExceptions)), annotations(std::move(theAnnotations)) { assert(!theReadOnly || setExceptions.empty()); } @@ -324,9 +325,9 @@ public: enum Direction { DIRECTION_IN, DIRECTION_OUT, DIRECTION_IN_OUT }; Parameter( - OUString const & theName, OUString const & theType, + OUString theName, OUString theType, Direction theDirection): - name(theName), type(theType), direction(theDirection) + name(std::move(theName)), type(std::move(theType)), direction(theDirection) {} OUString name; @@ -337,11 +338,11 @@ public: }; Method( - OUString const & theName, OUString const & theReturnType, + OUString theName, OUString theReturnType, std::vector< Parameter >&& theParameters, std::vector< OUString >&& theExceptions, std::vector< OUString >&& theAnnotations): - name(theName), returnType(theReturnType), parameters(std::move(theParameters)), + name(std::move(theName)), returnType(std::move(theReturnType)), parameters(std::move(theParameters)), exceptions(std::move(theExceptions)), annotations(std::move(theAnnotations)) {} @@ -394,9 +395,9 @@ private: class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL TypedefEntity final : public PublishableEntity { public: SAL_DLLPRIVATE TypedefEntity( - bool published, OUString const & type, + bool published, OUString type, std::vector< OUString >&& annotations): - PublishableEntity(SORT_TYPEDEF, published, std::move(annotations)), type_(type) + PublishableEntity(SORT_TYPEDEF, published, std::move(annotations)), type_(std::move(type)) {} const OUString& getType() const { return type_; } @@ -459,9 +460,9 @@ class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ConstantGroupEntity final : public Pub public: struct Member { Member( - OUString const & theName, ConstantValue const & theValue, + OUString theName, ConstantValue const & theValue, std::vector< OUString >&& theAnnotations): - name(theName), value(theValue), annotations(std::move(theAnnotations)) + name(std::move(theName)), value(theValue), annotations(std::move(theAnnotations)) {} OUString name; @@ -493,9 +494,9 @@ public: struct Constructor { struct Parameter { Parameter( - OUString const & theName, OUString const & theType, + OUString theName, OUString theType, bool theRest): - name(theName), type(theType), rest(theRest) + name(std::move(theName)), type(std::move(theType)), rest(theRest) {} OUString name; @@ -509,11 +510,11 @@ public: defaultConstructor(true) {} Constructor( - OUString const & theName, + OUString theName, std::vector< Parameter >&& theParameters, std::vector< OUString >&& theExceptions, std::vector< OUString >&& theAnnotations): - name(theName), parameters(std::move(theParameters)), + name(std::move(theName)), parameters(std::move(theParameters)), exceptions(std::move(theExceptions)), annotations(std::move(theAnnotations)), defaultConstructor(false) @@ -531,12 +532,12 @@ public: }; SAL_DLLPRIVATE SingleInterfaceBasedServiceEntity( - bool published, OUString const & base, + bool published, OUString base, std::vector< Constructor >&& constructors, std::vector< OUString >&& annotations): PublishableEntity( SORT_SINGLE_INTERFACE_BASED_SERVICE, published, std::move(annotations)), - base_(base), constructors_(std::move(constructors)) + base_(std::move(base)), constructors_(std::move(constructors)) {} const OUString& getBase() const { return base_; } @@ -569,10 +570,10 @@ public: }; Property( - OUString const & theName, OUString const & theType, + OUString theName, OUString theType, Attributes theAttributes, std::vector< OUString >&& theAnnotations): - name(theName), type(theType), attributes(theAttributes), + name(std::move(theName)), type(std::move(theType)), attributes(theAttributes), annotations(std::move(theAnnotations)) {} @@ -636,11 +637,11 @@ class LO_DLLPUBLIC_UNOIDL InterfaceBasedSingletonEntity final : { public: SAL_DLLPRIVATE InterfaceBasedSingletonEntity( - bool published, OUString const & base, + bool published, OUString base, std::vector< OUString >&& annotations): PublishableEntity( SORT_INTERFACE_BASED_SINGLETON, published, std::move(annotations)), - base_(base) + base_(std::move(base)) {} const OUString& getBase() const { return base_; } @@ -655,10 +656,10 @@ class SAL_WARN_UNUSED LO_DLLPUBLIC_UNOIDL ServiceBasedSingletonEntity final : pu { public: SAL_DLLPRIVATE ServiceBasedSingletonEntity( - bool published, OUString const & base, + bool published, OUString base, std::vector< OUString >&& annotations): PublishableEntity(SORT_SERVICE_BASED_SINGLETON, published, std::move(annotations)), - base_(base) + base_(std::move(base)) {} const OUString& getBase() const { return base_; } diff --git a/unoidl/source/legacyprovider.cxx b/unoidl/source/legacyprovider.cxx index ab99fcf59dd1..9299ae7ce046 100644 --- a/unoidl/source/legacyprovider.cxx +++ b/unoidl/source/legacyprovider.cxx @@ -10,6 +10,7 @@ #include <sal/config.h> #include <cassert> +#include <utility> #include <vector> #include <registry/reader.hxx> @@ -75,7 +76,7 @@ rtl::Reference< Entity > readEntity( class Cursor: public MapCursor { public: Cursor( - rtl::Reference< Manager > const & manager, RegistryKey const & ucr, + rtl::Reference< Manager > manager, RegistryKey const & ucr, RegistryKey const & key); private: @@ -92,9 +93,9 @@ private: }; Cursor::Cursor( - rtl::Reference< Manager > const & manager, RegistryKey const & ucr, + rtl::Reference< Manager > manager, RegistryKey const & ucr, RegistryKey const & key): - manager_(manager), ucr_(ucr), key_(key), index_(0) + manager_(std::move(manager)), ucr_(ucr), key_(key), index_(0) { if (!ucr_.isValid()) return; @@ -129,9 +130,9 @@ rtl::Reference< Entity > Cursor::getNext(OUString * name) { class Module: public ModuleEntity { public: Module( - rtl::Reference< Manager > const & manager, RegistryKey const & ucr, + rtl::Reference< Manager > manager, RegistryKey const & ucr, RegistryKey const & key): - manager_(manager), ucr_(ucr), key_(key) + manager_(std::move(manager)), ucr_(ucr), key_(key) {} private: diff --git a/unoidl/source/sourceprovider-parser-requires.hxx b/unoidl/source/sourceprovider-parser-requires.hxx index 59c79b39943c..5d9e5f6e3fda 100644 --- a/unoidl/source/sourceprovider-parser-requires.hxx +++ b/unoidl/source/sourceprovider-parser-requires.hxx @@ -11,6 +11,7 @@ #include <sal/config.h> +#include <utility> #include <vector> #include <rtl/ustring.hxx> @@ -97,25 +98,25 @@ struct SourceProviderType { { assert(componentType != nullptr); subtypes.push_back(*componentType); } SourceProviderType( - Type theType, OUString const & theName, + Type theType, OUString theName, SourceProviderEntity const * theEntity): - type(theType), name(theName), entity(theEntity) + type(theType), name(std::move(theName)), entity(theEntity) { assert(theType >= TYPE_ENUM && theType <= TYPE_INTERFACE); assert(theEntity != nullptr); } SourceProviderType( - OUString const & polymorphicStructTypeTemplateName, + OUString polymorphicStructTypeTemplateName, SourceProviderEntity const * theEntity, std::vector<SourceProviderType>&& typeArguments): type(TYPE_INSTANTIATED_POLYMORPHIC_STRUCT), - name(polymorphicStructTypeTemplateName), entity(theEntity), + name(std::move(polymorphicStructTypeTemplateName)), entity(theEntity), subtypes(std::move(typeArguments)) { assert(theEntity != nullptr); } - explicit SourceProviderType(OUString const & identifier): - type(TYPE_PARAMETER), name(identifier), + explicit SourceProviderType(OUString identifier): + type(TYPE_PARAMETER), name(std::move(identifier)), entity() // avoid false warnings about uninitialized member {} diff --git a/unoidl/source/sourceprovider-scanner.hxx b/unoidl/source/sourceprovider-scanner.hxx index 8c973b9db169..08ed189f9f6b 100644 --- a/unoidl/source/sourceprovider-scanner.hxx +++ b/unoidl/source/sourceprovider-scanner.hxx @@ -14,6 +14,7 @@ #include <cassert> #include <map> #include <set> +#include <utility> #include <vector> #include <rtl/ref.hxx> @@ -107,10 +108,10 @@ class SourceProviderInterfaceTypeEntityPad: public SourceProviderEntityPad { public: struct DirectBase { DirectBase( - OUString const & theName, + OUString theName, rtl::Reference<unoidl::InterfaceTypeEntity> const & theEntity, std::vector<OUString>&& theAnnotations): - name(theName), entity(theEntity), annotations(std::move(theAnnotations)) + name(std::move(theName)), entity(theEntity), annotations(std::move(theAnnotations)) { assert(theEntity.is()); } OUString name; @@ -127,7 +128,7 @@ public: OUString mandatory; std::set<OUString> optional; - explicit Member(const OUString & theMandatory): mandatory(theMandatory) {} + explicit Member(OUString theMandatory): mandatory(std::move(theMandatory)) {} }; SourceProviderInterfaceTypeEntityPad(bool published, bool theSingleBase): @@ -196,9 +197,9 @@ public: struct Constructor { struct Parameter { Parameter( - OUString const & theName, - SourceProviderType const & theType, bool theRest): - name(theName), type(theType), rest(theRest) + OUString theName, + SourceProviderType theType, bool theRest): + name(std::move(theName)), type(std::move(theType)), rest(theRest) {} OUString name; @@ -209,9 +210,9 @@ public: }; Constructor( - OUString const & theName, + OUString theName, std::vector< OUString >&& theAnnotations): - name(theName), annotations(std::move(theAnnotations)) + name(std::move(theName)), annotations(std::move(theAnnotations)) {} OUString name; @@ -224,8 +225,8 @@ public: }; explicit SourceProviderSingleInterfaceBasedServiceEntityPad( - bool published, OUString const & theBase): - SourceProviderEntityPad(published), base(theBase) + bool published, OUString theBase): + SourceProviderEntityPad(published), base(std::move(theBase)) {} OUString const base; @@ -284,8 +285,8 @@ struct SourceProviderEntity { struct SourceProviderScannerData { explicit SourceProviderScannerData( - rtl::Reference<unoidl::Manager> const & theManager): - manager(theManager), + rtl::Reference<unoidl::Manager> theManager): + manager(std::move(theManager)), sourcePosition(), sourceEnd(), // avoid false warnings about uninitialized members errorLine(0), publishedContext(false) diff --git a/unoidl/source/sourcetreeprovider.cxx b/unoidl/source/sourcetreeprovider.cxx index fea67405cd54..399329f30e40 100644 --- a/unoidl/source/sourcetreeprovider.cxx +++ b/unoidl/source/sourcetreeprovider.cxx @@ -11,6 +11,7 @@ #include <sal/log.hxx> #include <map> +#include <utility> #include <vector> #include <osl/file.h> @@ -111,7 +112,7 @@ private: class SourceModuleEntity: public ModuleEntity { public: - SourceModuleEntity(Manager& manager, OUString const & uri): manager_(manager), uri_(uri) {} + SourceModuleEntity(Manager& manager, OUString uri): manager_(manager), uri_(std::move(uri)) {} private: virtual ~SourceModuleEntity() noexcept override {} diff --git a/unoidl/source/unoidl-check.cxx b/unoidl/source/unoidl-check.cxx index 253079024106..892793eab395 100644 --- a/unoidl/source/unoidl-check.cxx +++ b/unoidl/source/unoidl-check.cxx @@ -14,6 +14,7 @@ #include <cstdlib> #include <iostream> #include <string_view> +#include <utility> #include <vector> #include <osl/file.hxx> @@ -150,7 +151,7 @@ OUString showDirection( } struct EqualsAnnotation { - explicit EqualsAnnotation(OUString const & name): name_(name) {} + explicit EqualsAnnotation(OUString name): name_(std::move(name)) {} bool operator ()(unoidl::AnnotatedReference const & ref) { return ref.name == name_; } diff --git a/unoidl/source/unoidl-read.cxx b/unoidl/source/unoidl-read.cxx index 706fe7f3d64c..283c660ce974 100644 --- a/unoidl/source/unoidl-read.cxx +++ b/unoidl/source/unoidl-read.cxx @@ -143,8 +143,8 @@ struct Entity { enum class Written { NO, DECLARATION, DEFINITION }; explicit Entity( - rtl::Reference<unoidl::Entity> const & theEntity, bool theRelevant, Entity * theParent): - entity(theEntity), relevant(theRelevant), sorted(Sorted::NO), + rtl::Reference<unoidl::Entity> theEntity, bool theRelevant, Entity * theParent): + entity(std::move(theEntity)), relevant(theRelevant), sorted(Sorted::NO), written(Written::NO), parent(theParent) {} diff --git a/unoidl/source/unoidl-write.cxx b/unoidl/source/unoidl-write.cxx index 5ddd98468359..84cad5bdda69 100644 --- a/unoidl/source/unoidl-write.cxx +++ b/unoidl/source/unoidl-write.cxx @@ -298,8 +298,8 @@ void writeKind( } struct Item { - explicit Item(rtl::Reference< unoidl::Entity > const & theEntity): - entity(theEntity), nameOffset(0), dataOffset(0) + explicit Item(rtl::Reference< unoidl::Entity > theEntity): + entity(std::move(theEntity)), nameOffset(0), dataOffset(0) {} rtl::Reference< unoidl::Entity > entity; diff --git a/unoidl/source/unoidl.cxx b/unoidl/source/unoidl.cxx index 749f9afe4f25..2022bcd058ac 100644 --- a/unoidl/source/unoidl.cxx +++ b/unoidl/source/unoidl.cxx @@ -11,6 +11,7 @@ #include <sal/log.hxx> #include <set> +#include <utility> #include <vector> #include <osl/file.h> @@ -33,8 +34,8 @@ class AggregatingModule: public ModuleEntity { public: AggregatingModule( std::vector< rtl::Reference< Provider > >&& providers, - OUString const & name): - providers_(std::move(providers)), name_(name) + OUString name): + providers_(std::move(providers)), name_(std::move(name)) {} private: @@ -65,8 +66,8 @@ class AggregatingCursor: public MapCursor { public: AggregatingCursor( std::vector< rtl::Reference< Provider > >&& providers, - OUString const & name): - providers_(std::move(providers)), name_(name), iterator_(providers_.begin()) + OUString name): + providers_(std::move(providers)), name_(std::move(name)), iterator_(providers_.begin()) { findCursor(); } private: diff --git a/unoidl/source/unoidlprovider.cxx b/unoidl/source/unoidlprovider.cxx index 216bf564e14d..d6f4d4ddd51a 100644 --- a/unoidl/source/unoidlprovider.cxx +++ b/unoidl/source/unoidlprovider.cxx @@ -14,6 +14,7 @@ #include <cstring> #include <set> #include <string_view> +#include <utility> #include <vector> #include <o3tl/string_view.hxx> @@ -35,7 +36,7 @@ namespace unoidl::detail { class MappedFile: public salhelper::SimpleReferenceObject { public: - explicit MappedFile(OUString const & fileUrl); + explicit MappedFile(OUString fileUrl); sal_uInt8 read8(sal_uInt32 offset) const; @@ -258,7 +259,7 @@ void checkEntityName( } -MappedFile::MappedFile(OUString const & fileUrl): uri(fileUrl), handle(nullptr) { +MappedFile::MappedFile(OUString fileUrl): uri(std::move(fileUrl)), handle(nullptr) { oslFileError e = osl_openFile(uri.pData, &handle, osl_File_OpenFlag_Read); switch (e) { case osl_File_E_None: @@ -657,11 +658,11 @@ class UnoidlModuleEntity; class UnoidlCursor: public MapCursor { public: UnoidlCursor( - rtl::Reference< MappedFile > const & file, - rtl::Reference<UnoidlProvider> const & reference1, - rtl::Reference<UnoidlModuleEntity> const & reference2, + rtl::Reference< MappedFile > file, + rtl::Reference<UnoidlProvider> reference1, + rtl::Reference<UnoidlModuleEntity> reference2, NestedMap const & map): - file_(file), reference1_(reference1), reference2_(reference2), + file_(std::move(file)), reference1_(std::move(reference1)), reference2_(std::move(reference2)), map_(map), index_(0) {}