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.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2022-05-18 12:05:34 +02:00
parent f8560e0900
commit 75918e709a
10 changed files with 86 additions and 78 deletions

View file

@ -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_; }

View file

@ -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:

View file

@ -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
{}

View file

@ -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)

View file

@ -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 {}

View file

@ -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_; }

View file

@ -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)
{}

View file

@ -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;

View file

@ -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:

View file

@ -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)
{}