Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply clang-tidy fixes to cpp (nullptr, using, override) #3270

Merged
merged 3 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Checks:
'
WarningsAsErrors: '*'
HeaderFilterRegex: '.*'
ExcludeHeaderFilterRegex: 'include/.*'
ExcludeHeaderFilterRegex: 'include/lmdb.h|Grammar.h'
UseColor: true
FormatStyle: 'file'
ExtraArgs: ['-std=c++20']
Expand Down
12 changes: 6 additions & 6 deletions cpp/include/Ice/FactoryTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ namespace IceInternal
private:
mutable std::mutex _mutex;

typedef std::pair<Ice::UserExceptionFactory, int> EFPair;
typedef std::map<std::string, EFPair, std::less<>> EFTable;
using EFPair = std::pair<Ice::UserExceptionFactory, int>;
using EFTable = std::map<std::string, EFPair, std::less<>>;
EFTable _eft;

typedef std::pair<Ice::ValueFactory, int> VFPair;
typedef std::map<std::string, VFPair, std::less<>> VFTable;
using VFPair = std::pair<Ice::ValueFactory, int>;
using VFTable = std::map<std::string, VFPair, std::less<>>;
VFTable _vft;

typedef std::pair<std::string, int> TypeIdPair;
typedef std::map<int, TypeIdPair> TypeIdTable;
using TypeIdPair = std::pair<std::string, int>;
using TypeIdTable = std::map<int, TypeIdPair>;
TypeIdTable _typeIdTable;
};

Expand Down
4 changes: 2 additions & 2 deletions cpp/include/Ice/IconvStringConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ namespace IceInternal
//
// Reset cd
//
[[maybe_unused]] size_t rs = iconv(cd, 0, 0, 0, 0);
[[maybe_unused]] size_t rs = iconv(cd, nullptr, nullptr, nullptr, nullptr);

char* inbuf = reinterpret_cast<char*>(const_cast<charT*>(sourceStart));
size_t inbytesleft = static_cast<size_t>(sourceEnd - sourceStart) * sizeof(charT);
Expand Down Expand Up @@ -150,7 +150,7 @@ namespace IceInternal
//
// Reset cd
//
[[maybe_unused]] size_t rs = iconv(cd, 0, 0, 0, 0);
[[maybe_unused]] size_t rs = iconv(cd, nullptr, nullptr, nullptr, nullptr);
assert(rs == 0);
char* inbuf = reinterpret_cast<char*>(const_cast<std::byte*>(sourceStart));
assert(sourceEnd > sourceStart);
Expand Down
9 changes: 5 additions & 4 deletions cpp/include/Ice/Initialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,10 @@ namespace Ice
ThreadHookPlugin(const CommunicatorPtr& communicator, std::function<void()> start, std::function<void()> stop);

/** Not used. */
virtual void initialize();
void initialize() override;

/** Not used. */
virtual void destroy();
void destroy() override;
};

/**
Expand Down Expand Up @@ -546,8 +546,9 @@ namespace Ice
* @param args Additional arguments included in the plug-in's configuration.
* @return The new plug-in object. Returning nil will cause the run time to raise PluginInitializationException.
*/
typedef Ice::Plugin* (
*PluginFactory)(const Ice::CommunicatorPtr& communicator, const std::string& name, const Ice::StringSeq& args);
using PluginFactory = Ice::Plugin* (*)(const Ice::CommunicatorPtr& communicator,
const std::string& name,
const Ice::StringSeq& args);

/**
* Manually registers a plug-in factory function.
Expand Down
60 changes: 30 additions & 30 deletions cpp/include/Ice/InputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace Ice
class ICE_API InputStream final : public IceInternal::Buffer
{
public:
typedef size_t size_type;
using size_type = size_t;

/**
* Signature for a patch function, used to receive an unmarshaled value.
Expand Down Expand Up @@ -852,17 +852,17 @@ namespace Ice
void addPatchEntry(std::int32_t, const PatchFunc&, void*);
void unmarshal(std::int32_t, const ValuePtr&);

typedef std::map<std::int32_t, ValuePtr> IndexToPtrMap;
typedef std::map<std::int32_t, std::string> TypeIdMap;
using IndexToPtrMap = std::map<std::int32_t, ValuePtr>;
using TypeIdMap = std::map<std::int32_t, std::string>;

struct PatchEntry
{
PatchFunc patchFunc;
void* patchAddr;
size_t classGraphDepth;
};
typedef std::vector<PatchEntry> PatchList;
typedef std::map<std::int32_t, PatchList> PatchMap;
using PatchList = std::vector<PatchEntry>;
using PatchMap = std::map<std::int32_t, PatchList>;

InputStream* _stream;
Encaps* _encaps;
Expand Down Expand Up @@ -894,16 +894,16 @@ namespace Ice
{
}

virtual void read(PatchFunc, void*);
virtual void throwException(UserExceptionFactory);
void read(PatchFunc, void*) override;
void throwException(UserExceptionFactory) override;

virtual void startInstance(SliceType);
virtual SlicedDataPtr endInstance();
virtual const std::string& startSlice();
virtual void endSlice();
virtual void skipSlice();
void startInstance(SliceType) override;
SlicedDataPtr endInstance() override;
const std::string& startSlice() override;
void endSlice() override;
void skipSlice() override;

virtual void readPendingValues();
void readPendingValues() override;

private:
void readInstance();
Expand All @@ -926,22 +926,22 @@ namespace Ice
size_t classGraphDepthMax,
const Ice::ValueFactoryManagerPtr& f)
: EncapsDecoder(stream, encaps, classGraphDepthMax, f),
_preAllocatedInstanceData(0),
_current(0),
_preAllocatedInstanceData(nullptr),
_current(nullptr),
_valueIdIndex(1)
{
}

virtual void read(PatchFunc, void*);
virtual void throwException(UserExceptionFactory);
void read(PatchFunc, void*) override;
void throwException(UserExceptionFactory) override;

virtual void startInstance(SliceType);
virtual SlicedDataPtr endInstance();
virtual const std::string& startSlice();
virtual void endSlice();
virtual void skipSlice();
void startInstance(SliceType) override;
SlicedDataPtr endInstance() override;
const std::string& startSlice() override;
void endSlice() override;
void skipSlice() override;

virtual bool readOptional(std::int32_t, OptionalFormat);
bool readOptional(std::int32_t, OptionalFormat) override;

private:
std::int32_t readInstance(std::int32_t, const PatchFunc&, void*);
Expand All @@ -953,14 +953,14 @@ namespace Ice
PatchFunc patchFunc;
void* patchAddr;
};
typedef std::vector<IndirectPatchEntry> IndirectPatchList;
using IndirectPatchList = std::vector<IndirectPatchEntry>;

typedef std::vector<std::int32_t> IndexList;
typedef std::vector<IndexList> IndexListList;
using IndexList = std::vector<std::int32_t>;
using IndexListList = std::vector<IndexList>;

struct InstanceData
{
InstanceData(InstanceData* p) : previous(p), next(0)
InstanceData(InstanceData* p) : previous(p), next(nullptr)
{
if (previous)
{
Expand Down Expand Up @@ -1015,7 +1015,7 @@ namespace Ice
class Encaps
{
public:
Encaps() : start(0), decoder(0), previous(0)
Encaps() : start(0), decoder(nullptr), previous(nullptr)
{
// Inlined for performance reasons.
}
Expand All @@ -1032,9 +1032,9 @@ namespace Ice
{
// Inlined for performance reasons.
delete decoder;
decoder = 0;
decoder = nullptr;

previous = 0;
previous = nullptr;
}

Container::size_type start;
Expand Down
12 changes: 6 additions & 6 deletions cpp/include/Ice/LoggerUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace Ice
static char testex(Ice::Exception*);
static long testex(...);

static const bool value = sizeof(testex(static_cast<T*>(0))) == sizeof(char);
static const bool value = sizeof(testex(static_cast<T*>(nullptr))) == sizeof(char);
};

template<typename T, bool = false> struct LoggerOutputInserter
Expand Down Expand Up @@ -115,13 +115,13 @@ namespace Ice
};

/** Flushes output to Logger::print. */
typedef LoggerOutput<Logger, LoggerPtr, &Logger::print> Print;
using Print = LoggerOutput<Logger, LoggerPtr, &Logger::print>;

/** Flushes output to Logger::warning. */
typedef LoggerOutput<Logger, LoggerPtr, &Logger::warning> Warning;
using Warning = LoggerOutput<Logger, LoggerPtr, &Logger::warning>;

/** Flushes output to Logger::error. */
typedef LoggerOutput<Logger, LoggerPtr, &Logger::error> Error;
using Error = LoggerOutput<Logger, LoggerPtr, &Logger::error>;

/**
* Flushes output to Logger::trace.
Expand Down Expand Up @@ -155,10 +155,10 @@ namespace Ice
LoggerPlugin(const CommunicatorPtr& communicator, const LoggerPtr& logger);

/** This method is a no-op. */
virtual void initialize();
void initialize() override;

/** This method is a no-op. */
virtual void destroy();
void destroy() override;
};
}

Expand Down
32 changes: 16 additions & 16 deletions cpp/include/Ice/MetricsAdminI.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ namespace IceInternal
using TPtr = std::shared_ptr<MetricsType>;
using MetricsMapTPtr = std::shared_ptr<MetricsMapT>;

typedef IceMX::MetricsMap MetricsType::* SubMapMember;
using SubMapMember = IceMX::MetricsMap MetricsType::*;

class EntryT;
using EntryTPtr = std::shared_ptr<EntryT>;
Expand Down Expand Up @@ -160,7 +160,7 @@ namespace IceInternal
}
if (p == _subMaps.end())
{
return 0;
return nullptr;
}
m = p->second.first;
}
Expand Down Expand Up @@ -265,15 +265,15 @@ namespace IceInternal
return std::static_pointer_cast<MetricsMapT>(MetricsMapI::shared_from_this());
}

virtual void destroy()
void destroy() override
{
std::lock_guard lock(_mutex);
_destroyed = true;
_objects.clear(); // Break cyclic reference counts
_detachedQueue.clear(); // Break cyclic reference counts
}

virtual IceMX::MetricsMap getMetrics() const
IceMX::MetricsMap getMetrics() const override
{
IceMX::MetricsMap objects;

Expand All @@ -286,7 +286,7 @@ namespace IceInternal
return objects;
}

virtual IceMX::MetricsFailuresSeq getFailures()
IceMX::MetricsFailuresSeq getFailures() override
{
IceMX::MetricsFailuresSeq failures;

Expand All @@ -303,7 +303,7 @@ namespace IceInternal
return failures;
}

virtual IceMX::MetricsFailures getFailures(const std::string& id)
IceMX::MetricsFailures getFailures(const std::string& id) override
{
std::lock_guard lock(_mutex);
typename std::map<std::string, EntryTPtr>::const_iterator p = _objects.find(id);
Expand All @@ -324,7 +324,7 @@ namespace IceInternal
p->second.second->clone()->shared_from_this(),
p->second.first);
}
return std::pair<MetricsMapIPtr, SubMapMember>(MetricsMapIPtr(nullptr), static_cast<SubMapMember>(0));
return std::pair<MetricsMapIPtr, SubMapMember>(MetricsMapIPtr(nullptr), static_cast<SubMapMember>(nullptr));
}

EntryTPtr getMatching(const IceMX::MetricsHelperT<T>& helper, const EntryTPtr& previous = EntryTPtr())
Expand Down Expand Up @@ -412,7 +412,7 @@ namespace IceInternal
}

private:
virtual MetricsMapIPtr clone() const { return std::make_shared<MetricsMapT<MetricsType>>(*this); }
MetricsMapIPtr clone() const override { return std::make_shared<MetricsMapT<MetricsType>>(*this); }

void detached(EntryTPtr entry)
{
Expand Down Expand Up @@ -482,7 +482,7 @@ namespace IceInternal
public:
MetricsMapFactoryT(IceMX::Updater* updater) : MetricsMapFactory(updater) {}

virtual MetricsMapIPtr create(const std::string& mapPrefix, const Ice::PropertiesPtr& properties)
MetricsMapIPtr create(const std::string& mapPrefix, const Ice::PropertiesPtr& properties) override
{
return std::make_shared<MetricsMapT<MetricsType>>(mapPrefix, properties, _subMaps);
}
Expand Down Expand Up @@ -531,7 +531,7 @@ namespace IceInternal
{
public:
MetricsAdminI(const Ice::PropertiesPtr&, const Ice::LoggerPtr&);
~MetricsAdminI();
~MetricsAdminI() override;

void destroy();

Expand Down Expand Up @@ -580,15 +580,15 @@ namespace IceInternal

void unregisterMap(const std::string&);

virtual Ice::StringSeq getMetricsViewNames(Ice::StringSeq&, const Ice::Current&);
Ice::StringSeq getMetricsViewNames(Ice::StringSeq&, const Ice::Current&) override;

void updated(const Ice::PropertyDict&);

virtual void enableMetricsView(std::string, const Ice::Current&);
virtual void disableMetricsView(std::string, const Ice::Current&);
virtual IceMX::MetricsView getMetricsView(std::string, std::int64_t&, const Ice::Current&);
virtual IceMX::MetricsFailuresSeq getMapMetricsFailures(std::string, std::string, const Ice::Current&);
virtual IceMX::MetricsFailures getMetricsFailures(std::string, std::string, std::string, const Ice::Current&);
void enableMetricsView(std::string, const Ice::Current&) override;
void disableMetricsView(std::string, const Ice::Current&) override;
IceMX::MetricsView getMetricsView(std::string, std::int64_t&, const Ice::Current&) override;
IceMX::MetricsFailuresSeq getMapMetricsFailures(std::string, std::string, const Ice::Current&) override;
IceMX::MetricsFailures getMetricsFailures(std::string, std::string, std::string, const Ice::Current&) override;
std::vector<MetricsMapIPtr> getMaps(const std::string&) const;

const Ice::LoggerPtr& getLogger() const;
Expand Down
Loading
Loading