Skip to content

Commit

Permalink
build: mark virtual functions called in ctor/dtor final (#12558)
Browse files Browse the repository at this point in the history
Signed-off-by: Lizan Zhou <[email protected]>

Prevents undefined behavior and let clang-tidy not warn about it.
  • Loading branch information
lizan authored Aug 10, 2020
1 parent dc560df commit 9ed8092
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions source/common/network/connection_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ConnectionImpl : public ConnectionImplBase, public TransportSocketCallback
// Network::Connection
void addBytesSentCallback(BytesSentCb cb) override;
void enableHalfClose(bool enabled) override;
void close(ConnectionCloseType type) override;
void close(ConnectionCloseType type) final;
std::string nextProtocol() const override { return transport_socket_->protocol(); }
void noDelay(bool enable) override;
void readDisable(bool disable) override;
Expand Down Expand Up @@ -132,7 +132,7 @@ class ConnectionImpl : public ConnectionImplBase, public TransportSocketCallback
bool consumerWantsToRead();

// Network::ConnectionImplBase
void closeConnectionImmediately() override;
void closeConnectionImmediately() final;

void closeSocket(ConnectionEvent close_type);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CertificateValidationContextConfigImpl : public CertificateValidationConte
const std::string& certificateRevocationList() const override {
return certificate_revocation_list_;
}
const std::string& certificateRevocationListPath() const override {
const std::string& certificateRevocationListPath() const final {
return certificate_revocation_list_path_;
}
const std::vector<std::string>& verifySubjectAltNameList() const override {
Expand Down
2 changes: 1 addition & 1 deletion source/common/stats/allocator_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ template <class BaseClass> class StatsSharedImpl : public MetricImpl<BaseClass>
}

// Metric
SymbolTable& symbolTable() override { return alloc_.symbolTable(); }
SymbolTable& symbolTable() final { return alloc_.symbolTable(); }
bool used() const override { return flags_ & Metric::Flags::Used; }

// RefcountInterface
Expand Down
2 changes: 1 addition & 1 deletion source/common/stats/histogram_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class HistogramImpl : public HistogramImplHelper {
void recordValue(uint64_t value) override { parent_.deliverHistogramToSinks(*this, value); }

bool used() const override { return true; }
SymbolTable& symbolTable() override { return parent_.symbolTable(); }
SymbolTable& symbolTable() final { return parent_.symbolTable(); }

private:
Unit unit_;
Expand Down
4 changes: 2 additions & 2 deletions source/common/stats/scope_prefixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class ScopePrefixer : public Scope {
HistogramOptConstRef findHistogram(StatName name) const override;
TextReadoutOptConstRef findTextReadout(StatName name) const override;

const SymbolTable& constSymbolTable() const override { return scope_.constSymbolTable(); }
SymbolTable& symbolTable() override { return scope_.symbolTable(); }
const SymbolTable& constSymbolTable() const final { return scope_.constSymbolTable(); }
SymbolTable& symbolTable() final { return scope_.symbolTable(); }

NullGaugeImpl& nullGauge(const std::string& str) override { return scope_.nullGauge(str); }

Expand Down
7 changes: 4 additions & 3 deletions source/common/stats/thread_local_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ThreadLocalHistogramImpl : public HistogramImplHelper {
void recordValue(uint64_t value) override;

// Stats::Metric
SymbolTable& symbolTable() override { return symbol_table_; }
SymbolTable& symbolTable() final { return symbol_table_; }
bool used() const override { return used_; }

private:
Expand Down Expand Up @@ -334,13 +334,14 @@ class ThreadLocalStoreImpl : Logger::Loggable<Logger::Id::stats>, public StoreRo
ScopePtr createScope(const std::string& name) override {
return parent_.createScope(symbolTable().toString(prefix_.statName()) + "." + name);
}
const SymbolTable& constSymbolTable() const override { return parent_.constSymbolTable(); }
SymbolTable& symbolTable() override { return parent_.symbolTable(); }
const SymbolTable& constSymbolTable() const final { return parent_.constSymbolTable(); }
SymbolTable& symbolTable() final { return parent_.symbolTable(); }

Counter& counterFromString(const std::string& name) override {
StatNameManagedStorage storage(name, symbolTable());
return counterFromStatName(storage.statName());
}

Gauge& gaugeFromString(const std::string& name, Gauge::ImportMode import_mode) override {
StatNameManagedStorage storage(name, symbolTable());
return gaugeFromStatName(storage.statName(), import_mode);
Expand Down
2 changes: 1 addition & 1 deletion source/common/tcp_proxy/tcp_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ class Filter : public Network::ReadFilter,
bool on_high_watermark_called_{false};
};

virtual StreamInfo::StreamInfo& getStreamInfo();
StreamInfo::StreamInfo& getStreamInfo();

protected:
struct DownstreamCallbacks : public Network::ConnectionCallbacks {
Expand Down
2 changes: 1 addition & 1 deletion source/common/upstream/upstream_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class HostImpl : public HostDescriptionImpl,
}
void healthFlagClear(HealthFlag flag) override { health_flags_ &= ~enumToInt(flag); }
bool healthFlagGet(HealthFlag flag) const override { return health_flags_ & enumToInt(flag); }
void healthFlagSet(HealthFlag flag) override { health_flags_ |= enumToInt(flag); }
void healthFlagSet(HealthFlag flag) final { health_flags_ |= enumToInt(flag); }

ActiveHealthFailureType getActiveHealthFailureType() const override {
return active_health_failure_type_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class DnsCacheImpl : public DnsCache, Logger::Loggable<Logger::Id::forward_proxy
Network::Address::InstanceConstSharedPtr address() override { return address_; }
const std::string& resolvedHost() const override { return resolved_host_; }
bool isIpAddress() const override { return is_ip_address_; }
void touch() override { last_used_time_ = time_source_.monotonicTime().time_since_epoch(); }
void touch() final { last_used_time_ = time_source_.monotonicTime().time_since_epoch(); }

TimeSource& time_source_;
const std::string resolved_host_;
Expand Down
2 changes: 1 addition & 1 deletion source/extensions/filters/http/common/jwks_fetcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class JwksFetcherImpl : public JwksFetcher,

~JwksFetcherImpl() override { cancel(); }

void cancel() override {
void cancel() final {
if (request_ && !complete_) {
request_->cancel();
ENVOY_LOG(debug, "fetch pubkey [uri = {}]: canceled", uri_->uri());
Expand Down
2 changes: 1 addition & 1 deletion source/extensions/filters/http/jwt_authn/jwks_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class JwksCacheImpl : public JwksCache {
return it->second;
}

JwksData* findByProvider(const std::string& provider) override {
JwksData* findByProvider(const std::string& provider) final {
const auto it = jwks_data_map_.find(provider);
if (it == jwks_data_map_.end()) {
return nullptr;
Expand Down
2 changes: 1 addition & 1 deletion source/extensions/filters/udp/udp_proxy/udp_proxy_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class UdpProxyFilter : public Network::UdpListenerReadFilter,
}

// Upstream::ClusterUpdateCallbacks
void onClusterAddOrUpdate(Upstream::ThreadLocalCluster& cluster) override;
void onClusterAddOrUpdate(Upstream::ThreadLocalCluster& cluster) final;
void onClusterRemoval(const std::string& cluster_name) override;

const UdpProxyFilterConfigSharedPtr config_;
Expand Down

0 comments on commit 9ed8092

Please sign in to comment.