Skip to content

Commit

Permalink
Fix weak vtables warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier committed Jan 23, 2025
1 parent 0fe7198 commit 1a83167
Show file tree
Hide file tree
Showing 62 changed files with 185 additions and 50 deletions.
7 changes: 3 additions & 4 deletions config/Make.rules.Darwin
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ cppflags = -fvisibility=hidden -Wall -Wextra -Wshadow -Wshadow-all -Wredu
$(if $(filter yes,$(OPTIMIZE)),-O2 -DNDEBUG,-g) \
-std=c++20

# TODO review this setting
ifeq ($(MAXWARN),yes)
cppflags += -Wweak-vtables
endif
# When we export an API from a shared library, we check for weak vtables. This flag also works for static
# libraries/exes, but is not necessary.
api_exports_cppflags = -Wweak-vtables

# We compile static and shared with the same flags so we want their .o to share directories.
static_objdir = obj
Expand Down
1 change: 1 addition & 0 deletions cpp/include/DataStorm/InternalI.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wshadow-field-in-constructor"
# pragma clang diagnostic ignored "-Wweak-vtables"
#elif defined(__GNUC__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wshadow"
Expand Down
6 changes: 4 additions & 2 deletions cpp/include/Ice/BatchRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#ifndef ICE_BATCH_REQUEST_H
#define ICE_BATCH_REQUEST_H

#include "Config.h"

#include <string_view>

namespace Ice
Expand All @@ -13,10 +15,10 @@ namespace Ice
* Represents an invocation on a proxy configured for batch-oneway or batch-datagram.
* \headerfile Ice/Ice.h
*/
class BatchRequest
class ICE_API BatchRequest
{
public:
virtual ~BatchRequest() = default;
virtual ~BatchRequest();

/**
* Queues the request for an eventual flush.
Expand Down
4 changes: 3 additions & 1 deletion cpp/include/Ice/Connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace Ice
class ICE_API Connection
{
public:
virtual ~Connection() = 0;
virtual ~Connection();

/**
* Aborts this connection.
Expand Down Expand Up @@ -265,6 +265,8 @@ namespace Ice
IPConnectionInfo(const IPConnectionInfo&) = delete;
IPConnectionInfo& operator=(const IPConnectionInfo&) = delete;

~IPConnectionInfo() override;

/**
* The local address.
*/
Expand Down
2 changes: 2 additions & 0 deletions cpp/include/Ice/Endpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ namespace Ice
IPEndpointInfo(const IPEndpointInfo&) = delete;
IPEndpointInfo& operator=(const IPEndpointInfo&) = delete;

~IPEndpointInfo() override;

/**
* The host or address configured with the endpoint.
*/
Expand Down
9 changes: 9 additions & 0 deletions cpp/include/Ice/Instrumentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
#include <memory>
#include <optional>

#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wweak-vtables"
#endif

namespace Ice
{
struct Current;
Expand Down Expand Up @@ -372,4 +377,8 @@ namespace Ice::Instrumentation
};
}

#if defined(__clang__)
# pragma clang diagnostic pop
#endif

#endif
6 changes: 4 additions & 2 deletions cpp/include/Ice/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#ifndef ICE_LOGGER_H
#define ICE_LOGGER_H

#include "Config.h"

#include <memory>
#include <string>

Expand All @@ -15,10 +17,10 @@ namespace Ice
* The Ice message logger. Applications can provide their own logger by implementing this interface and installing
* it in a communicator. \headerfile Ice/Ice.h
*/
class Logger
class ICE_API Logger
{
public:
virtual ~Logger() = default;
virtual ~Logger();

// We use const std::string& and not std::string_view for the log messages because implementations commonly
// send the message to C APIs that require null-terminated strings.
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/Ice/MarshaledResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Ice
MarshaledResult(const MarshaledResult&) = delete;
MarshaledResult(MarshaledResult&&) = default;

virtual ~MarshaledResult() = default;
virtual ~MarshaledResult();

MarshaledResult& operator=(const MarshaledResult&) = delete;
MarshaledResult& operator=(MarshaledResult&&) = default;
Expand Down
9 changes: 9 additions & 0 deletions cpp/include/Ice/MetricsObserverI.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
#include <sstream>
#include <stdexcept>

#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wweak-vtables"
#endif

namespace IceInternal
{
class StopWatch
Expand Down Expand Up @@ -577,4 +582,8 @@ namespace IceMX
/// \endcond
}

#if defined(__clang__)
# pragma clang diagnostic pop
#endif

#endif
2 changes: 1 addition & 1 deletion cpp/include/Ice/NativePropertiesAdmin.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Ice
class ICE_API NativePropertiesAdmin
{
public:
virtual ~NativePropertiesAdmin() = 0;
virtual ~NativePropertiesAdmin();

/**
* Register an update callback that will be invoked when property updates occur.
Expand Down
4 changes: 2 additions & 2 deletions cpp/include/Ice/ObjectAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ namespace Ice
* @see ServantLocator
* \headerfile Ice/Ice.h
*/
class ObjectAdapter
class ICE_API ObjectAdapter
{
public:
virtual ~ObjectAdapter() = default;
virtual ~ObjectAdapter();

/**
* Get the name of this object adapter.
Expand Down
1 change: 1 addition & 0 deletions cpp/include/Ice/OutgoingAsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# pragma clang diagnostic push
// See #2747
# pragma clang diagnostic ignored "-Wshadow-uncaptured-local"
# pragma clang diagnostic ignored "-Wweak-vtables"
#endif

namespace IceInternal
Expand Down
8 changes: 4 additions & 4 deletions cpp/include/Ice/Plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ namespace Ice
* invokes {@link Plugin#initialize} on each one.
* \headerfile Ice/Ice.h
*/
class Plugin
class ICE_API Plugin
{
public:
virtual ~Plugin() = default;
virtual ~Plugin();

/**
* Perform any necessary initialization steps.
Expand All @@ -36,10 +36,10 @@ namespace Ice
* Each communicator has a plug-in manager to administer the set of plug-ins.
* \headerfile Ice/Ice.h
*/
class PluginManager
class ICE_API PluginManager
{
public:
virtual ~PluginManager() = default;
virtual ~PluginManager();

/**
* Initialize the configured plug-ins. The communicator automatically initializes the plug-ins by default, but
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/Ice/Proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ namespace Ice

ObjectPrx(const Ice::CommunicatorPtr& communicator, std::string_view proxyString);

virtual ~ObjectPrx() = default;
virtual ~ObjectPrx();

ObjectPrx& operator=(const ObjectPrx& rhs) noexcept = default;
ObjectPrx& operator=(ObjectPrx&& rhs) noexcept = default;
Expand Down
4 changes: 2 additions & 2 deletions cpp/include/Ice/ServantLocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ namespace Ice
* @see ObjectAdapter#findServantLocator
* \headerfile Ice/Ice.h
*/
class ServantLocator
class ICE_API ServantLocator
{
public:
virtual ~ServantLocator() = default;
virtual ~ServantLocator();

/**
* Called before a request is dispatched if a servant cannot be found in the object adapter's active servant
Expand Down
9 changes: 9 additions & 0 deletions cpp/include/Ice/Timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ namespace IceInternal
};
using TimerTaskPtr = std::shared_ptr<TimerTask>;

#ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wweak-vtables"
#endif

// Adapts a function<void()> to a TimerTask.
class InlineTimerTask final : public TimerTask
{
Expand All @@ -42,6 +47,10 @@ namespace IceInternal
std::function<void()> _function;
};

#ifdef __clang__
# pragma clang diagnostic pop
#endif

// The timer class is used to schedule tasks for one-time execution or repeated execution. Tasks are executed by a
// dedicated timer thread sequentially.
class ICE_API Timer
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/Ice/ValueFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace Ice
class ICE_API ValueFactoryManager
{
public:
virtual ~ValueFactoryManager() = 0;
virtual ~ValueFactoryManager();

/**
* Adds a value factory. Attempting to add a factory with a type ID for which a factory is already registered
Expand Down
4 changes: 2 additions & 2 deletions cpp/include/IceBox/Service.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ namespace IceBox
* An application service managed by a {@link ServiceManager}.
* \headerfile IceBox/IceBox.h
*/
class Service
class ICEBOX_API Service
{
public:
virtual ~Service() = default;
virtual ~Service();

/**
* Start the service. The given communicator is created by the {@link ServiceManager} for use by the service.
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/DataStorm/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ $(project)_generated_includedir := $(project)/generated/DataStorm

DataStorm_sliceflags := --include-dir DataStorm
DataStorm_targetdir := $(libdir)
DataStorm_cppflags := -DDATASTORM_API_EXPORTS
DataStorm_cppflags := -DDATASTORM_API_EXPORTS $(api_exports_cppflags)
DataStorm_dependencies := Ice

projects += $(project)
2 changes: 1 addition & 1 deletion cpp/src/Glacier2CryptPermissionsVerifier/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $(project)_libraries += Glacier2CryptPermissionsVerif

Glacier2CryptPermissionsVerifier_targetdir := $(libdir)
Glacier2CryptPermissionsVerifier_dependencies := Glacier2 Ice
Glacier2CryptPermissionsVerifier_cppflags := -DCRYPT_PERMISSIONS_VERIFIER_API_EXPORTS
Glacier2CryptPermissionsVerifier_cppflags := -DCRYPT_PERMISSIONS_VERIFIER_API_EXPORTS $(api_exports_cppflags)
Glacier2CryptPermissionsVerifier_devinstall := no

projects += $(project)
2 changes: 1 addition & 1 deletion cpp/src/Glacier2Lib/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $(project)_libraries := Glacier2

Glacier2_targetdir := $(libdir)
Glacier2_dependencies := Ice
Glacier2_cppflags := -DGLACIER2_API_EXPORTS
Glacier2_cppflags := $(api_exports_cppflags)
Glacier2_sliceflags := --include-dir Glacier2

projects += $(project)
9 changes: 9 additions & 0 deletions cpp/src/Ice/Acceptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
#include "Network.h"
#include "TransceiverF.h"

#ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wweak-vtables"
#endif

namespace IceInternal
{
class Acceptor
Expand All @@ -29,4 +34,8 @@ namespace IceInternal
};
}

#ifdef __clang__
# pragma clang diagnostic pop
#endif

#endif
2 changes: 2 additions & 0 deletions cpp/src/Ice/BatchRequestQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ namespace
};
}

BatchRequest::~BatchRequest() = default; // avoid weak vtable

BatchRequestQueue::BatchRequestQueue(const InstancePtr& instance, bool datagram)
: _interceptor(instance->initializationData().batchRequestInterceptor),
_batchStream(instance.get(), Ice::currentProtocolEncoding),
Expand Down
3 changes: 2 additions & 1 deletion cpp/src/Ice/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ using namespace std;

// Implement virtual destructors out of line to avoid weak vtables.
Ice::ConnectionInfo::~ConnectionInfo() = default;
Ice::IPConnectionInfo::~IPConnectionInfo() = default;
Ice::TCPConnectionInfo::~TCPConnectionInfo() = default;
Ice::UDPConnectionInfo::~UDPConnectionInfo() = default;
Ice::WSConnectionInfo::~WSConnectionInfo() = default;
Ice::IAPConnectionInfo::~IAPConnectionInfo() = default;

Ice::Connection::~Connection() = default;
Ice::Connection::~Connection() = default; // avoid weak vtable

void
Ice::Connection::flushBatchRequests(CompressBatch compress)
Expand Down
9 changes: 9 additions & 0 deletions cpp/src/Ice/Connector.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
#include <cstdint>
#include <string>

#ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wweak-vtables"
#endif

namespace IceInternal
{
class Connector
Expand All @@ -26,4 +31,8 @@ namespace IceInternal
};
}

#ifdef __clang__
# pragma clang diagnostic pop
#endif

#endif
5 changes: 1 addition & 4 deletions cpp/src/Ice/EndpointI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,11 @@ Ice::EndpointInfo::secure() const noexcept
return underlying ? underlying->secure() : false;
}

Ice::IPEndpointInfo::~IPEndpointInfo() = default;
Ice::TCPEndpointInfo::~TCPEndpointInfo() = default;

Ice::UDPEndpointInfo::~UDPEndpointInfo() = default;

Ice::WSEndpointInfo::~WSEndpointInfo() = default;

Ice::IAPEndpointInfo::~IAPEndpointInfo() = default;

Ice::OpaqueEndpointInfo::~OpaqueEndpointInfo() = default;

void
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/Ice/LocatorInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ IceInternal::LocatorInfo::Request::addCallback(
}
}

IceInternal::LocatorInfo::GetEndpointsCallback::~GetEndpointsCallback() = default; // avoid weak vtable

IceInternal::LocatorInfo::Request::Request(LocatorInfoPtr locatorInfo, ReferencePtr ref)
: _locatorInfo(std::move(locatorInfo)),
_reference(std::move(ref)),
Expand All @@ -404,6 +406,8 @@ IceInternal::LocatorInfo::Request::Request(LocatorInfoPtr locatorInfo, Reference
{
}

IceInternal::LocatorInfo::Request::~Request() = default; // avoid weak vtable

void
IceInternal::LocatorInfo::Request::response(const optional<ObjectPrx>& proxy)
{
Expand Down
Loading

0 comments on commit 1a83167

Please sign in to comment.