Skip to content

Commit

Permalink
Use modernize-use-default-member-init in cpp/srcs (#3426)
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier authored Jan 27, 2025
1 parent bd5d7aa commit b578f4e
Show file tree
Hide file tree
Showing 141 changed files with 372 additions and 638 deletions.
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Checks:
modernize-*,
-modernize-avoid-c-arrays,
-modernize-use-trailing-return-type,
-modernize-use-default-member-init,
-modernize-macro-to-enum,
performance-*,
-performance-avoid-endl,
Expand Down
4 changes: 2 additions & 2 deletions cpp/include/DataStorm/InternalT.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ namespace DataStormI
} _deleter;

public:
AbstractFactoryT() : _nextId(1) {}
AbstractFactoryT() = default;

void init()
{
Expand Down Expand Up @@ -237,7 +237,7 @@ namespace DataStormI
mutable std::mutex _mutex;
std::map<K, std::weak_ptr<V>> _elements;
std::map<std::int64_t, std::weak_ptr<V>> _elementsById;
std::int64_t _nextId;
std::int64_t _nextId{1};
};

template<typename K> class KeyT final : public Key, public AbstractElementT<K>
Expand Down
43 changes: 15 additions & 28 deletions cpp/include/Ice/InputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -838,9 +838,7 @@ namespace Ice
: _stream(stream),
_encaps(encaps),
_classGraphDepthMax(classGraphDepthMax),
_classGraphDepth(0),
_valueFactoryManager(std::move(f)),
_typeIdIndex(0)
_valueFactoryManager(std::move(f))
{
}

Expand All @@ -865,7 +863,7 @@ namespace Ice
InputStream* _stream;
Encaps* _encaps;
const size_t _classGraphDepthMax;
size_t _classGraphDepth;
size_t _classGraphDepth{0};
Ice::ValueFactoryManagerPtr _valueFactoryManager;

// Encapsulation attributes for object un-marshaling
Expand All @@ -875,7 +873,7 @@ namespace Ice
// Encapsulation attributes for object un-marshaling
IndexToPtrMap _unmarshaledMap;
TypeIdMap _typeIdMap;
std::int32_t _typeIdIndex;
std::int32_t _typeIdIndex{0};
ValueList _valueList;
};

Expand All @@ -887,8 +885,7 @@ namespace Ice
Encaps* encaps,
size_t classGraphDepthMax,
const Ice::ValueFactoryManagerPtr& f)
: EncapsDecoder(stream, encaps, classGraphDepthMax, f),
_sliceType(NoSlice)
: EncapsDecoder(stream, encaps, classGraphDepthMax, f)
{
}

Expand All @@ -907,7 +904,7 @@ namespace Ice
void readInstance();

// Instance attributes
SliceType _sliceType;
SliceType _sliceType{NoSlice};
bool _skipFirstSlice;

// Slice attributes
Expand All @@ -924,9 +921,7 @@ namespace Ice
size_t classGraphDepthMax,
const Ice::ValueFactoryManagerPtr& f)
: EncapsDecoder(stream, encaps, classGraphDepthMax, f),
_preAllocatedInstanceData(nullptr),
_current(nullptr),
_valueIdIndex(1)
_preAllocatedInstanceData(nullptr)
{
}

Expand Down Expand Up @@ -958,7 +953,7 @@ namespace Ice

struct InstanceData
{
InstanceData(InstanceData* p) : previous(p), next(nullptr)
InstanceData(InstanceData* p) : previous(p)
{
if (previous)
{
Expand Down Expand Up @@ -988,10 +983,10 @@ namespace Ice
IndirectPatchList indirectPatchList;

InstanceData* previous;
InstanceData* next;
InstanceData* next{nullptr};
};
InstanceData _preAllocatedInstanceData;
InstanceData* _current;
InstanceData* _current{nullptr};

void push(SliceType sliceType)
{
Expand All @@ -1007,23 +1002,15 @@ namespace Ice
_current->skipFirstSlice = false;
}

std::int32_t _valueIdIndex; // The ID of the next value to unmarshal.
std::int32_t _valueIdIndex{1}; // The ID of the next value to unmarshal.
};

class Encaps
{
public:
Encaps() : start(0), decoder(nullptr), previous(nullptr)
{
// Inlined for performance reasons.
}
Encaps() = default;
Encaps(const Encaps&) = delete;
~Encaps()
{
// Inlined for performance reasons.
delete decoder;
}

~Encaps() { delete decoder; }
Encaps& operator=(const Encaps&) = delete;

void reset()
Expand All @@ -1035,13 +1022,13 @@ namespace Ice
previous = nullptr;
}

Container::size_type start;
Container::size_type start{0};
std::int32_t sz;
EncodingVersion encoding;

EncapsDecoder* decoder;
EncapsDecoder* decoder{nullptr};

Encaps* previous;
Encaps* previous{nullptr};
};

// Optimization. The instance may not be deleted while a stack-allocated stream still holds it.
Expand Down
8 changes: 3 additions & 5 deletions cpp/include/Ice/MetricsAdminI.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ namespace IceInternal
using MetricsMapIPtr = std::shared_ptr<MetricsMapI>;

class ICE_API MetricsMapI : public std::enable_shared_from_this<MetricsMapI>

{
public:
class ICE_API RegExp
Expand Down Expand Up @@ -222,8 +221,7 @@ namespace IceInternal
const std::string& mapPrefix,
const Ice::PropertiesPtr& properties,
const std::map<std::string, std::pair<SubMapMember, MetricsMapFactoryPtr>>& subMaps)
: MetricsMapI(mapPrefix, properties),
_destroyed(false)
: MetricsMapI(mapPrefix, properties)
{
std::vector<std::string> subMapNames;
typename std::map<std::string, std::pair<SubMapMember, MetricsMapFactoryPtr>>::const_iterator p;
Expand All @@ -249,7 +247,7 @@ namespace IceInternal
}
}

MetricsMapT(const MetricsMapT& other) : MetricsMapI(other), _destroyed(false) {}
MetricsMapT(const MetricsMapT& other) : MetricsMapI(other) {}

std::shared_ptr<MetricsMapT> shared_from_this()
{
Expand Down Expand Up @@ -459,7 +457,7 @@ namespace IceInternal

friend class EntryT;

bool _destroyed;
bool _destroyed{false};
std::map<std::string, EntryTPtr> _objects;
std::list<EntryTPtr> _detachedQueue;
std::map<std::string, std::pair<SubMapMember, MetricsMapIPtr>> _subMaps;
Expand Down
12 changes: 6 additions & 6 deletions cpp/include/Ice/OutgoingAsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ namespace IceInternal

const InstancePtr _instance;
Ice::ConnectionPtr _cachedConnection;
bool _sentSynchronously;
bool _doneInSent;
unsigned char _state;
bool _sentSynchronously{false};
bool _doneInSent{false};
unsigned char _state{0};

std::mutex _m;
using Lock = std::lock_guard<std::mutex>;
Expand Down Expand Up @@ -172,14 +172,14 @@ namespace IceInternal

const Ice::ObjectPrx _proxy;
RequestHandlerPtr _handler;
Ice::OperationMode _mode;
Ice::OperationMode _mode{Ice::OperationMode::Normal};

private:
int handleRetryAfterException(std::exception_ptr);
int checkRetryAfterException(std::exception_ptr);

int _cnt;
bool _sent;
int _cnt{0};
bool _sent{false};
};

using ProxyOutgoingAsyncBasePtr = std::shared_ptr<ProxyOutgoingAsyncBase>;
Expand Down
45 changes: 15 additions & 30 deletions cpp/include/Ice/OutputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ namespace Ice
virtual void writePendingValues() {}

protected:
EncapsEncoder(OutputStream* stream, Encaps* encaps) : _stream(stream), _encaps(encaps), _typeIdIndex(0) {}
EncapsEncoder(OutputStream* stream, Encaps* encaps) : _stream(stream), _encaps(encaps) {}

std::int32_t registerTypeId(std::string_view);

Expand All @@ -843,18 +843,13 @@ namespace Ice
private:
// Encapsulation attributes for value marshaling.
TypeIdMap _typeIdMap;
std::int32_t _typeIdIndex;
std::int32_t _typeIdIndex{0};
};

class ICE_API EncapsEncoder10 : public EncapsEncoder
{
public:
EncapsEncoder10(OutputStream* stream, Encaps* encaps)
: EncapsEncoder(stream, encaps),
_sliceType(NoSlice),
_valueIdIndex(0)
{
}
EncapsEncoder10(OutputStream* stream, Encaps* encaps) : EncapsEncoder(stream, encaps) {}

void write(const ValuePtr&) override;
void write(const UserException&) override;
Expand All @@ -870,13 +865,13 @@ namespace Ice
std::int32_t registerValue(const ValuePtr&);

// Instance attributes
SliceType _sliceType;
SliceType _sliceType{NoSlice};

// Slice attributes
Container::size_type _writeSlice; // Position of the slice data members

// Encapsulation attributes for value marshaling.
std::int32_t _valueIdIndex;
std::int32_t _valueIdIndex{0};
PtrToIndexMap _toBeMarshaledMap;
};

Expand All @@ -885,9 +880,7 @@ namespace Ice
public:
EncapsEncoder11(OutputStream* stream, Encaps* encaps)
: EncapsEncoder(stream, encaps),
_preAllocatedInstanceData(nullptr),
_current(nullptr),
_valueIdIndex(1)
_preAllocatedInstanceData(nullptr)
{
}

Expand All @@ -907,7 +900,7 @@ namespace Ice

struct InstanceData
{
InstanceData(InstanceData* p) : previous(p), next(nullptr)
InstanceData(InstanceData* p) : previous(p)
{
if (previous)
{
Expand Down Expand Up @@ -935,28 +928,20 @@ namespace Ice
ValueList indirectionTable;

InstanceData* previous;
InstanceData* next;
InstanceData* next{nullptr};
};
InstanceData _preAllocatedInstanceData;
InstanceData* _current;
InstanceData* _current{nullptr};

std::int32_t _valueIdIndex; // The ID of the next value to marshal
std::int32_t _valueIdIndex{1}; // The ID of the next value to marshal
};

class Encaps
{
public:
Encaps() : format(FormatType::CompactFormat), encoder(nullptr), previous(nullptr)
{
// Inlined for performance reasons.
}
Encaps() = default;
Encaps(const Encaps&) = delete;
~Encaps()
{
// Inlined for performance reasons.
delete encoder;
}

~Encaps() { delete encoder; }
Encaps& operator=(const Encaps&) = delete;

void reset()
Expand All @@ -970,11 +955,11 @@ namespace Ice

Container::size_type start;
EncodingVersion encoding;
FormatType format;
FormatType format{FormatType::CompactFormat};

EncapsEncoder* encoder;
EncapsEncoder* encoder{nullptr};

Encaps* previous;
Encaps* previous{nullptr};
};

//
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/Ice/Timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ namespace IceInternal
std::condition_variable _condition;
std::set<Token> _tokens;
std::map<TimerTaskPtr, std::chrono::steady_clock::time_point> _tasks;
bool _destroyed;
bool _destroyed{false};
std::chrono::steady_clock::time_point _wakeUpTime;
std::thread _worker;
};
Expand Down
12 changes: 6 additions & 6 deletions cpp/include/Ice/VersionFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@
namespace Ice
{
/** Identifies protocol version 1.0. */
constexpr ProtocolVersion Protocol_1_0 = {1, 0};
constexpr ProtocolVersion Protocol_1_0{.major = 1, .minor = 0};

/** Identifies encoding version 1.0. */
constexpr EncodingVersion Encoding_1_0 = {1, 0};
constexpr EncodingVersion Encoding_1_0{.major = 1, .minor = 0};

/** Identifies encoding version 1.1. */
constexpr EncodingVersion Encoding_1_1 = {1, 1};
constexpr EncodingVersion Encoding_1_1{.major = 1, .minor = 1};

/** Identifies the latest protocol version. */
constexpr ProtocolVersion currentProtocol = Protocol_1_0;
constexpr ProtocolVersion currentProtocol{Protocol_1_0};

/** Identifies the latest protocol encoding version. */
constexpr EncodingVersion currentProtocolEncoding = Encoding_1_0;
constexpr EncodingVersion currentProtocolEncoding{Encoding_1_0};

/** Identifies the latest encoding version. */
constexpr EncodingVersion currentEncoding = Encoding_1_1;
constexpr EncodingVersion currentEncoding{Encoding_1_1};

/**
* Converts a protocol version into a string.
Expand Down
3 changes: 0 additions & 3 deletions cpp/src/DataStorm/TraceUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ using namespace Ice;

TraceLevels::TraceLevels(const PropertiesPtr& properties, LoggerPtr logger)
: topic(properties->getIcePropertyAsInt("DataStorm.Trace.Topic")),
topicCat("Topic"),
data(properties->getIcePropertyAsInt("DataStorm.Trace.Data")),
dataCat("Data"),
session(properties->getIcePropertyAsInt("DataStorm.Trace.Session")),
sessionCat("Session"),
logger(std::move(logger))
{
}
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/DataStorm/TraceUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ namespace DataStormI
TraceLevels(const Ice::PropertiesPtr&, Ice::LoggerPtr);

const int topic;
const char* topicCat;
const char* topicCat{"Topic"};

const int data;
const char* dataCat;
const char* dataCat{"Data"};

const int session;
const char* sessionCat;
const char* sessionCat{"Session"};

const Ice::LoggerPtr logger;
};
Expand Down
Loading

0 comments on commit b578f4e

Please sign in to comment.