Skip to content

Commit

Permalink
clang-tidy: modernize-use-equals-default (envoyproxy#7638)
Browse files Browse the repository at this point in the history
Mass translation to = default; done using clang-tidy's -fix flag and enable as a clang-tidy error. https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-equals-default.html

Risk Level: low
Testing: existing

Signed-off-by: Derek Argueta <dereka@pinterest.com>
  • Loading branch information
derekargueta authored and htuch committed Jul 19, 2019
1 parent 14c5371 commit 1278529
Show file tree
Hide file tree
Showing 85 changed files with 264 additions and 265 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ WarningsAsErrors: 'abseil-duration-*,
modernize-make-shared,
modernize-make-unique,
modernize-return-braced-init-list,
modernize-use-equals-default,
modernize-use-using,
performance-faster-string-find,
performance-for-range-copy,
Expand Down
2 changes: 1 addition & 1 deletion source/common/access_log/access_log_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class OrFilter : public OperatorFilter {
*/
class NotHealthCheckFilter : public Filter {
public:
NotHealthCheckFilter() {}
NotHealthCheckFilter() = default;

// AccessLog::Filter
bool evaluate(const StreamInfo::StreamInfo& info, const Http::HeaderMap& request_headers,
Expand Down
2 changes: 1 addition & 1 deletion source/common/config/delta_subscription_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class DeltaSubscriptionState : public Logger::Loggable<Logger::Id::config> {
public:
explicit ResourceVersion(absl::string_view version) : version_(version) {}
// Builds a ResourceVersion in the waitingForServer state.
ResourceVersion() {}
ResourceVersion() = default;

// If true, we currently have no version of this resource - we are waiting for the server to
// provide us with one.
Expand Down
2 changes: 1 addition & 1 deletion source/common/grpc/codec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Envoy {
namespace Grpc {

Encoder::Encoder() {}
Encoder::Encoder() = default;

void Encoder::newFrame(uint8_t flags, uint64_t length, std::array<uint8_t, 5>& output) {
output[0] = flags;
Expand Down
4 changes: 2 additions & 2 deletions source/common/grpc/typed_async_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ AsyncRequest* sendUntyped(RawAsyncClient* client, const Protobuf::MethodDescript
*/
template <typename Request> class AsyncStream /* : public RawAsyncStream */ {
public:
AsyncStream() {}
AsyncStream() = default;
AsyncStream(RawAsyncStream* stream) : stream_(stream) {}
AsyncStream(const AsyncStream& other) = default;
void sendMessage(const Request& request, bool end_stream) {
Expand Down Expand Up @@ -93,7 +93,7 @@ template <typename Response> class AsyncStreamCallbacks : public RawAsyncStreamC

template <typename Request, typename Response> class AsyncClient /* : public RawAsyncClient )*/ {
public:
AsyncClient() {}
AsyncClient() = default;
AsyncClient(RawAsyncClientPtr&& client) : client_(std::move(client)) {}
virtual ~AsyncClient() = default;

Expand Down
8 changes: 2 additions & 6 deletions source/common/network/cidr_range.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,9 @@ CidrRange::CidrRange(InstanceConstSharedPtr address, int length)
}
}

CidrRange::CidrRange(const CidrRange& other) : address_(other.address_), length_(other.length_) {}
CidrRange::CidrRange(const CidrRange& other) = default;

CidrRange& CidrRange::operator=(const CidrRange& other) {
address_ = other.address_;
length_ = other.length_;
return *this;
}
CidrRange& CidrRange::operator=(const CidrRange& other) = default;

bool CidrRange::operator==(const CidrRange& other) const {
// Lengths must be the same, and must be valid (i.e. not -1).
Expand Down
2 changes: 1 addition & 1 deletion source/common/network/io_socket_error_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class IoSocketError : public Api::IoError {
public:
explicit IoSocketError(int sys_errno) : errno_(sys_errno) {}

~IoSocketError() override {}
~IoSocketError() override = default;

Api::IoError::IoErrorCode getErrorCode() const override;
std::string getErrorDetails() const override;
Expand Down
2 changes: 1 addition & 1 deletion source/common/protobuf/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ class ValueUtil {
class HashedValue {
public:
HashedValue(const ProtobufWkt::Value& value) : value_(value), hash_(ValueUtil::hash(value)){};
HashedValue(const HashedValue& v) : value_(v.value_), hash_(v.hash_){};
HashedValue(const HashedValue& v) = default;

const ProtobufWkt::Value& value() const { return value_; }
std::size_t hash() const { return hash_; }
Expand Down
2 changes: 1 addition & 1 deletion source/common/router/config_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class RetryPolicyImpl : public RetryPolicy {
public:
RetryPolicyImpl(const envoy::api::v2::route::RetryPolicy& retry_policy,
ProtobufMessage::ValidationVisitor& validation_visitor);
RetryPolicyImpl() {}
RetryPolicyImpl() = default;

// Router::RetryPolicy
std::chrono::milliseconds perTryTimeout() const override { return per_try_timeout_; }
Expand Down
2 changes: 1 addition & 1 deletion source/common/router/header_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class HeaderParser {
void evaluateHeaders(Http::HeaderMap& headers, const StreamInfo::StreamInfo& stream_info) const;

protected:
HeaderParser() {}
HeaderParser() = default;

private:
std::vector<std::pair<Http::LowerCaseString, HeaderFormatterPtr>> headers_to_add_;
Expand Down
2 changes: 1 addition & 1 deletion source/common/stats/tag_producer_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Stats {
class TagProducerImpl : public TagProducer {
public:
TagProducerImpl(const envoy::config::metrics::v2::StatsConfig& config);
TagProducerImpl() {}
TagProducerImpl() = default;

/**
* Take a metric name and a vector then add proper tags into the vector and
Expand Down
2 changes: 1 addition & 1 deletion source/common/upstream/load_balancer_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class ZoneAwareLoadBalancerBase : public LoadBalancerBase {
LocalityDegradedHosts,
};

HostsSource() {}
HostsSource() = default;

HostsSource(uint32_t priority, SourceType source_type)
: priority_(priority), source_type_(source_type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class OriginalSrcSocketOption : public Network::Socket::Option {
* Constructs a socket option which will set the socket to use source @c src_address
*/
OriginalSrcSocketOption(Network::Address::InstanceConstSharedPtr src_address);
~OriginalSrcSocketOption() {}
~OriginalSrcSocketOption() = default;

/**
* Updates the source address of the socket to match `src_address_`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class RequestParser {
// http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.Errors.html
static const std::vector<std::string> SUPPORTED_ERROR_TYPES;

RequestParser() {}
RequestParser() = default;
};

} // namespace Dynamo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace IpTagging {

IpTaggingFilter::IpTaggingFilter(IpTaggingFilterConfigSharedPtr config) : config_(config) {}

IpTaggingFilter::~IpTaggingFilter() {}
IpTaggingFilter::~IpTaggingFilter() = default;

void IpTaggingFilter::onDestroy() {}

Expand Down
2 changes: 1 addition & 1 deletion source/extensions/filters/http/squash/squash_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ SquashFilter::SquashFilter(SquashFilterConfigSharedPtr config, Upstream::Cluster
std::bind(&SquashFilter::onGetAttachmentFailure, this, _1)),
cm_(cm), decoder_callbacks_(nullptr) {}

SquashFilter::~SquashFilter() {}
SquashFilter::~SquashFilter() = default;

void SquashFilter::onDestroy() { cleanup(); }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class EncoderFilterCallbacks : public virtual FilterCallbacksBase {
*/
class FilterBase {
public:
virtual ~FilterBase() {}
virtual ~FilterBase() = default;

/**
* This routine is called prior to a filter being destroyed. This may happen after normal stream
Expand Down
4 changes: 2 additions & 2 deletions source/extensions/filters/network/dubbo_proxy/message_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace DubboProxy {
class ContextBase : public Context {
public:
ContextBase() = default;
~ContextBase() override {}
~ContextBase() override = default;

// Override from Context
size_t body_size() const override { return body_size_; }
Expand All @@ -27,7 +27,7 @@ class ContextBase : public Context {
class ContextImpl : public ContextBase {
public:
ContextImpl() = default;
~ContextImpl() override {}
~ContextImpl() override = default;

bool is_heartbeat() const { return is_heartbeat_; }
void set_heartbeat(bool is_heartbeat) { is_heartbeat_ = is_heartbeat; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ ParameterRouteEntryImpl::ParameterRouteEntryImpl(
}
}

ParameterRouteEntryImpl::~ParameterRouteEntryImpl() {}
ParameterRouteEntryImpl::~ParameterRouteEntryImpl() = default;

bool ParameterRouteEntryImpl::matchParameter(absl::string_view request_data,
const ParameterData& config_data) const {
Expand Down Expand Up @@ -138,7 +138,7 @@ MethodRouteEntryImpl::MethodRouteEntryImpl(
}
}

MethodRouteEntryImpl::~MethodRouteEntryImpl() {}
MethodRouteEntryImpl::~MethodRouteEntryImpl() = default;

RouteConstSharedPtr MethodRouteEntryImpl::matches(const MessageMetadata& metadata,
uint64_t random_value) const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ Router::UpstreamRequest::UpstreamRequest(Router& parent, Tcp::ConnectionPool::In
request_complete_(false), response_started_(false), response_complete_(false),
stream_reset_(false) {}

Router::UpstreamRequest::~UpstreamRequest() {}
Router::UpstreamRequest::~UpstreamRequest() = default;

FilterStatus Router::UpstreamRequest::start() {
Tcp::ConnectionPool::Cancellable* handle = conn_pool_.newConnection(*this);
Expand Down
2 changes: 1 addition & 1 deletion source/extensions/filters/network/ext_authz/ext_authz.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class Filter : public Network::ReadFilter,
public:
Filter(ConfigSharedPtr config, Filters::Common::ExtAuthz::ClientPtr&& client)
: config_(config), client_(std::move(client)) {}
~Filter() {}
~Filter() = default;

// Network::ReadFilter
Network::FilterStatus onData(Buffer::Instance& data, bool end_stream) override;
Expand Down
2 changes: 1 addition & 1 deletion source/extensions/filters/network/kafka/serialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class Int64Deserializer : public IntDeserializer<int64_t> {
*/
class BooleanDeserializer : public Deserializer<bool> {
public:
BooleanDeserializer(){};
BooleanDeserializer() = default;

uint32_t feed(absl::string_view& data) override { return buffer_.feed(data); }

Expand Down
2 changes: 1 addition & 1 deletion source/extensions/filters/network/mongo_proxy/bson_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ class DocumentImpl : public Document,
const std::list<FieldPtr>& values() const override { return fields_; }

private:
DocumentImpl() {}
DocumentImpl() = default;

void fromBuffer(Buffer::Instance& data);

Expand Down
2 changes: 1 addition & 1 deletion source/extensions/filters/network/rbac/rbac_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class RoleBasedAccessControlFilter : public Network::ReadFilter,
public:
RoleBasedAccessControlFilter(RoleBasedAccessControlFilterConfigSharedPtr config)
: config_(config) {}
~RoleBasedAccessControlFilter() {}
~RoleBasedAccessControlFilter() = default;

// Network::ReadFilter
Network::FilterStatus onData(Buffer::Instance& data, bool end_stream) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace ThriftProxy {
*/
class CompactProtocolImpl : public Protocol {
public:
CompactProtocolImpl() {}
CompactProtocolImpl() = default;

// Protocol
const std::string& name() const override { return ProtocolNames::get().COMPACT; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ConnectionManager::ConnectionManager(Config& config, Runtime::RandomGenerator& r
decoder_(std::make_unique<Decoder>(*transport_, *protocol_, *this)),
random_generator_(random_generator), time_source_(time_source) {}

ConnectionManager::~ConnectionManager() {}
ConnectionManager::~ConnectionManager() = default;

Network::FilterStatus ConnectionManager::onData(Buffer::Instance& data, bool end_stream) {
request_buffer_.move(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace ThriftProxy {
*/
class FramedTransportImpl : public Transport {
public:
FramedTransportImpl() {}
FramedTransportImpl() = default;

// Transport
const std::string& name() const override { return TransportNames::get().FRAMED; }
Expand Down
2 changes: 1 addition & 1 deletion source/extensions/filters/network/thrift_proxy/metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace ThriftProxy {
*/
class MessageMetadata {
public:
MessageMetadata() {}
MessageMetadata() = default;

bool hasFrameSize() const { return frame_size_.has_value(); }
uint32_t frameSize() const { return frame_size_.value(); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ Router::UpstreamRequest::UpstreamRequest(Router& parent, Tcp::ConnectionPool::In
protocol_(NamedProtocolConfigFactory::getFactory(protocol_type).createProtocol()),
request_complete_(false), response_started_(false), response_complete_(false) {}

Router::UpstreamRequest::~UpstreamRequest() {}
Router::UpstreamRequest::~UpstreamRequest() = default;

FilterStatus Router::UpstreamRequest::start() {
Tcp::ConnectionPool::Cancellable* handle = conn_pool_.newConnection(*this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace ThriftProxy {
class ThriftBase : public DecoderEventHandler {
public:
ThriftBase(ThriftBase* parent);
~ThriftBase() {}
~ThriftBase() = default;

// DecoderEventHandler
FilterStatus transportBegin(MessageMetadataSharedPtr) override { return FilterStatus::Continue; }
Expand Down Expand Up @@ -61,7 +61,7 @@ class ThriftValueBase : public ThriftValue, public ThriftBase {
public:
ThriftValueBase(ThriftBase* parent, FieldType value_type)
: ThriftBase(parent), value_type_(value_type) {}
~ThriftValueBase() {}
~ThriftValueBase() = default;

// ThriftValue
FieldType type() const override { return value_type_; }
Expand Down
8 changes: 4 additions & 4 deletions source/extensions/filters/network/thrift_proxy/tracing.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Endpoint {
public:
Endpoint(int32_t ipv4, int16_t port, const std::string& service_name)
: ipv4_(ipv4), port_(port), service_name_(service_name) {}
Endpoint() {}
Endpoint() = default;

int32_t ipv4_{0};
int16_t port_{0};
Expand All @@ -31,7 +31,7 @@ class Annotation {
public:
Annotation(int64_t timestamp, const std::string& value, absl::optional<Endpoint> host)
: timestamp_(timestamp), value_(value), host_(host) {}
Annotation() {}
Annotation() = default;

int64_t timestamp_{0};
std::string value_;
Expand Down Expand Up @@ -60,7 +60,7 @@ class BinaryAnnotation {
BinaryAnnotation(const std::string& key, const std::string& value, AnnotationType annotation_type,
absl::optional<Endpoint> host)
: key_(key), value_(value), annotation_type_(annotation_type), host_(host) {}
BinaryAnnotation() {}
BinaryAnnotation() = default;

std::string key_;
std::string value_;
Expand All @@ -80,7 +80,7 @@ class Span {
: trace_id_(trace_id), name_(name), span_id_(span_id), parent_span_id_(parent_span_id),
annotations_(std::move(annotations)), binary_annotations_(std::move(binary_annotations)),
debug_(debug) {}
Span() {}
Span() = default;

int64_t trace_id_{0};
std::string name_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class ClientId {
*/
class UpgradeReply : public DirectResponse, public ThriftObject {
public:
UpgradeReply() {}
UpgradeReply() = default;
UpgradeReply(Transport& transport)
: thrift_obj_(std::make_unique<ThriftObjectImpl>(transport, protocol_)) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace ThriftProxy {
*/
class UnframedTransportImpl : public Transport {
public:
UnframedTransportImpl() {}
UnframedTransportImpl() = default;

// Transport
const std::string& name() const override { return TransportNames::get().UNFRAMED; }
Expand Down
2 changes: 1 addition & 1 deletion source/extensions/tracers/zipkin/span_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SpanBuffer {
* Constructor that creates an empty buffer. Space needs to be allocated by invoking
* the method allocateBuffer(size).
*/
SpanBuffer() {}
SpanBuffer() = default;

/**
* Constructor that initializes a buffer with the given size.
Expand Down
2 changes: 1 addition & 1 deletion source/extensions/tracers/zipkin/span_context_extractor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ bool getSamplingFlags(char c, const Tracing::Decision tracing_decision) {
SpanContextExtractor::SpanContextExtractor(Http::HeaderMap& request_headers)
: request_headers_(request_headers) {}

SpanContextExtractor::~SpanContextExtractor() {}
SpanContextExtractor::~SpanContextExtractor() = default;

bool SpanContextExtractor::extractSampled(const Tracing::Decision tracing_decision) {
bool sampled(false);
Expand Down
4 changes: 3 additions & 1 deletion source/server/http/admin.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,9 @@ class AdminImpl : public Admin,

class AdminFilterChain : public Network::FilterChain {
public:
AdminFilterChain() {}
// We can't use the default constructor because transport_socket_factory_ doesn't have a
// default constructor.
AdminFilterChain() {} // NOLINT(modernize-use-equals-default)

// Network::FilterChain
const Network::TransportSocketFactory& transportSocketFactory() const override {
Expand Down
Loading

0 comments on commit 1278529

Please sign in to comment.