Commit 783d00fd authored by Tom Hughes's avatar Tom Hughes Committed by Copybara-Service
Browse files

Use '=default' to define trivial constructor/destructors

https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-equals-default.html

PiperOrigin-RevId: 526079054
Change-Id: Ia4db21e3e5f58b90de05d52fd94b291ed06d785d
parent baf182e0
...@@ -435,7 +435,7 @@ GTEST_API_ TypeId GetTestTypeId(); ...@@ -435,7 +435,7 @@ GTEST_API_ TypeId GetTestTypeId();
// of a Test object. // of a Test object.
class TestFactoryBase { class TestFactoryBase {
public: public:
virtual ~TestFactoryBase() {} virtual ~TestFactoryBase() = default;
// Creates a test instance to run. The instance is both created and destroyed // Creates a test instance to run. The instance is both created and destroyed
// within TestInfoImpl::Run() // within TestInfoImpl::Run()
......
...@@ -97,7 +97,7 @@ class ParamGenerator; ...@@ -97,7 +97,7 @@ class ParamGenerator;
template <typename T> template <typename T>
class ParamIteratorInterface { class ParamIteratorInterface {
public: public:
virtual ~ParamIteratorInterface() {} virtual ~ParamIteratorInterface() = default;
// A pointer to the base generator instance. // A pointer to the base generator instance.
// Used only for the purposes of iterator comparison // Used only for the purposes of iterator comparison
// to make sure that two iterators belong to the same generator. // to make sure that two iterators belong to the same generator.
...@@ -171,7 +171,7 @@ class ParamGeneratorInterface { ...@@ -171,7 +171,7 @@ class ParamGeneratorInterface {
public: public:
typedef T ParamType; typedef T ParamType;
virtual ~ParamGeneratorInterface() {} virtual ~ParamGeneratorInterface() = default;
// Generator interface definition // Generator interface definition
virtual ParamIteratorInterface<T>* Begin() const = 0; virtual ParamIteratorInterface<T>* Begin() const = 0;
...@@ -215,7 +215,7 @@ class RangeGenerator : public ParamGeneratorInterface<T> { ...@@ -215,7 +215,7 @@ class RangeGenerator : public ParamGeneratorInterface<T> {
end_(end), end_(end),
step_(step), step_(step),
end_index_(CalculateEndIndex(begin, end, step)) {} end_index_(CalculateEndIndex(begin, end, step)) {}
~RangeGenerator() override {} ~RangeGenerator() override = default;
ParamIteratorInterface<T>* Begin() const override { ParamIteratorInterface<T>* Begin() const override {
return new Iterator(this, begin_, 0, step_); return new Iterator(this, begin_, 0, step_);
...@@ -230,7 +230,7 @@ class RangeGenerator : public ParamGeneratorInterface<T> { ...@@ -230,7 +230,7 @@ class RangeGenerator : public ParamGeneratorInterface<T> {
Iterator(const ParamGeneratorInterface<T>* base, T value, int index, Iterator(const ParamGeneratorInterface<T>* base, T value, int index,
IncrementT step) IncrementT step)
: base_(base), value_(value), index_(index), step_(step) {} : base_(base), value_(value), index_(index), step_(step) {}
~Iterator() override {} ~Iterator() override = default;
const ParamGeneratorInterface<T>* BaseGenerator() const override { const ParamGeneratorInterface<T>* BaseGenerator() const override {
return base_; return base_;
...@@ -299,7 +299,7 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> { ...@@ -299,7 +299,7 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
template <typename ForwardIterator> template <typename ForwardIterator>
ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end) ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end)
: container_(begin, end) {} : container_(begin, end) {}
~ValuesInIteratorRangeGenerator() override {} ~ValuesInIteratorRangeGenerator() override = default;
ParamIteratorInterface<T>* Begin() const override { ParamIteratorInterface<T>* Begin() const override {
return new Iterator(this, container_.begin()); return new Iterator(this, container_.begin());
...@@ -316,7 +316,7 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> { ...@@ -316,7 +316,7 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
Iterator(const ParamGeneratorInterface<T>* base, Iterator(const ParamGeneratorInterface<T>* base,
typename ContainerType::const_iterator iterator) typename ContainerType::const_iterator iterator)
: base_(base), iterator_(iterator) {} : base_(base), iterator_(iterator) {}
~Iterator() override {} ~Iterator() override = default;
const ParamGeneratorInterface<T>* BaseGenerator() const override { const ParamGeneratorInterface<T>* BaseGenerator() const override {
return base_; return base_;
...@@ -420,7 +420,7 @@ class ParameterizedTestFactory : public TestFactoryBase { ...@@ -420,7 +420,7 @@ class ParameterizedTestFactory : public TestFactoryBase {
template <class ParamType> template <class ParamType>
class TestMetaFactoryBase { class TestMetaFactoryBase {
public: public:
virtual ~TestMetaFactoryBase() {} virtual ~TestMetaFactoryBase() = default;
virtual TestFactoryBase* CreateTestFactory(ParamType parameter) = 0; virtual TestFactoryBase* CreateTestFactory(ParamType parameter) = 0;
}; };
...@@ -439,7 +439,7 @@ class TestMetaFactory ...@@ -439,7 +439,7 @@ class TestMetaFactory
public: public:
using ParamType = typename TestSuite::ParamType; using ParamType = typename TestSuite::ParamType;
TestMetaFactory() {} TestMetaFactory() = default;
TestFactoryBase* CreateTestFactory(ParamType parameter) override { TestFactoryBase* CreateTestFactory(ParamType parameter) override {
return new ParameterizedTestFactory<TestSuite>(parameter); return new ParameterizedTestFactory<TestSuite>(parameter);
...@@ -462,7 +462,7 @@ class TestMetaFactory ...@@ -462,7 +462,7 @@ class TestMetaFactory
// and calls RegisterTests() on each of them when asked. // and calls RegisterTests() on each of them when asked.
class ParameterizedTestSuiteInfoBase { class ParameterizedTestSuiteInfoBase {
public: public:
virtual ~ParameterizedTestSuiteInfoBase() {} virtual ~ParameterizedTestSuiteInfoBase() = default;
// Base part of test suite name for display purposes. // Base part of test suite name for display purposes.
virtual const std::string& GetTestSuiteName() const = 0; virtual const std::string& GetTestSuiteName() const = 0;
...@@ -691,7 +691,7 @@ using ParameterizedTestCaseInfo = ParameterizedTestSuiteInfo<TestCase>; ...@@ -691,7 +691,7 @@ using ParameterizedTestCaseInfo = ParameterizedTestSuiteInfo<TestCase>;
// ParameterizedTestSuiteInfo descriptors. // ParameterizedTestSuiteInfo descriptors.
class ParameterizedTestSuiteRegistry { class ParameterizedTestSuiteRegistry {
public: public:
ParameterizedTestSuiteRegistry() {} ParameterizedTestSuiteRegistry() = default;
~ParameterizedTestSuiteRegistry() { ~ParameterizedTestSuiteRegistry() {
for (auto& test_suite_info : test_suite_infos_) { for (auto& test_suite_info : test_suite_infos_) {
delete test_suite_info; delete test_suite_info;
...@@ -825,7 +825,7 @@ class CartesianProductGenerator ...@@ -825,7 +825,7 @@ class CartesianProductGenerator
CartesianProductGenerator(const std::tuple<ParamGenerator<T>...>& g) CartesianProductGenerator(const std::tuple<ParamGenerator<T>...>& g)
: generators_(g) {} : generators_(g) {}
~CartesianProductGenerator() override {} ~CartesianProductGenerator() override = default;
ParamIteratorInterface<ParamType>* Begin() const override { ParamIteratorInterface<ParamType>* Begin() const override {
return new Iterator(this, generators_, false); return new Iterator(this, generators_, false);
...@@ -850,7 +850,7 @@ class CartesianProductGenerator ...@@ -850,7 +850,7 @@ class CartesianProductGenerator
current_(is_end ? end_ : begin_) { current_(is_end ? end_ : begin_) {
ComputeCurrentValue(); ComputeCurrentValue();
} }
~IteratorImpl() override {} ~IteratorImpl() override = default;
const ParamGeneratorInterface<ParamType>* BaseGenerator() const override { const ParamGeneratorInterface<ParamType>* BaseGenerator() const override {
return base_; return base_;
...@@ -969,7 +969,7 @@ class ParamGeneratorConverter : public ParamGeneratorInterface<To> { ...@@ -969,7 +969,7 @@ class ParamGeneratorConverter : public ParamGeneratorInterface<To> {
: base_(base), it_(it), end_(end) { : base_(base), it_(it), end_(end) {
if (it_ != end_) value_ = std::make_shared<To>(static_cast<To>(*it_)); if (it_ != end_) value_ = std::make_shared<To>(static_cast<To>(*it_));
} }
~Iterator() override {} ~Iterator() override = default;
const ParamGeneratorInterface<To>* BaseGenerator() const override { const ParamGeneratorInterface<To>* BaseGenerator() const override {
return base_; return base_;
......
...@@ -1328,7 +1328,7 @@ GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 ...@@ -1328,7 +1328,7 @@ GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
// problem. // problem.
class ThreadWithParamBase { class ThreadWithParamBase {
public: public:
virtual ~ThreadWithParamBase() {} virtual ~ThreadWithParamBase() = default;
virtual void Run() = 0; virtual void Run() = 0;
}; };
...@@ -1790,7 +1790,7 @@ typedef GTestMutexLock MutexLock; ...@@ -1790,7 +1790,7 @@ typedef GTestMutexLock MutexLock;
// ThreadLocalValueHolderBase. // ThreadLocalValueHolderBase.
class GTEST_API_ ThreadLocalValueHolderBase { class GTEST_API_ ThreadLocalValueHolderBase {
public: public:
virtual ~ThreadLocalValueHolderBase() {} virtual ~ThreadLocalValueHolderBase() = default;
}; };
// Called by pthread to delete thread-local data stored by // Called by pthread to delete thread-local data stored by
...@@ -1862,8 +1862,8 @@ class GTEST_API_ ThreadLocal { ...@@ -1862,8 +1862,8 @@ class GTEST_API_ ThreadLocal {
class ValueHolderFactory { class ValueHolderFactory {
public: public:
ValueHolderFactory() {} ValueHolderFactory() = default;
virtual ~ValueHolderFactory() {} virtual ~ValueHolderFactory() = default;
virtual ValueHolder* MakeNewHolder() const = 0; virtual ValueHolder* MakeNewHolder() const = 0;
private: private:
...@@ -1873,7 +1873,7 @@ class GTEST_API_ ThreadLocal { ...@@ -1873,7 +1873,7 @@ class GTEST_API_ ThreadLocal {
class DefaultValueHolderFactory : public ValueHolderFactory { class DefaultValueHolderFactory : public ValueHolderFactory {
public: public:
DefaultValueHolderFactory() {} DefaultValueHolderFactory() = default;
ValueHolder* MakeNewHolder() const override { return new ValueHolder(); } ValueHolder* MakeNewHolder() const override { return new ValueHolder(); }
private: private:
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
// The prime table interface. // The prime table interface.
class PrimeTable { class PrimeTable {
public: public:
virtual ~PrimeTable() {} virtual ~PrimeTable() = default;
// Returns true if and only if n is a prime number. // Returns true if and only if n is a prime number.
virtual bool IsPrime(int n) const = 0; virtual bool IsPrime(int n) const = 0;
......
...@@ -407,8 +407,8 @@ GTEST_API_ FilePath GetCurrentExecutableName(); ...@@ -407,8 +407,8 @@ GTEST_API_ FilePath GetCurrentExecutableName();
// The role interface for getting the OS stack trace as a string. // The role interface for getting the OS stack trace as a string.
class OsStackTraceGetterInterface { class OsStackTraceGetterInterface {
public: public:
OsStackTraceGetterInterface() {} OsStackTraceGetterInterface() = default;
virtual ~OsStackTraceGetterInterface() {} virtual ~OsStackTraceGetterInterface() = default;
// Returns the current OS stack trace as an std::string. Parameters: // Returns the current OS stack trace as an std::string. Parameters:
// //
...@@ -436,7 +436,7 @@ class OsStackTraceGetterInterface { ...@@ -436,7 +436,7 @@ class OsStackTraceGetterInterface {
// A working implementation of the OsStackTraceGetterInterface interface. // A working implementation of the OsStackTraceGetterInterface interface.
class OsStackTraceGetter : public OsStackTraceGetterInterface { class OsStackTraceGetter : public OsStackTraceGetterInterface {
public: public:
OsStackTraceGetter() {} OsStackTraceGetter() = default;
std::string CurrentStackTrace(int max_depth, int skip_count) override; std::string CurrentStackTrace(int max_depth, int skip_count) override;
void UponLeavingGTest() override; void UponLeavingGTest() override;
...@@ -1064,7 +1064,7 @@ class StreamingListener : public EmptyTestEventListener { ...@@ -1064,7 +1064,7 @@ class StreamingListener : public EmptyTestEventListener {
// Abstract base class for writing strings to a socket. // Abstract base class for writing strings to a socket.
class AbstractSocketWriter { class AbstractSocketWriter {
public: public:
virtual ~AbstractSocketWriter() {} virtual ~AbstractSocketWriter() = default;
// Sends a string to the socket. // Sends a string to the socket.
virtual void Send(const std::string& message) = 0; virtual void Send(const std::string& message) = 0;
......
...@@ -2241,7 +2241,7 @@ TestResult::TestResult() ...@@ -2241,7 +2241,7 @@ TestResult::TestResult()
: death_test_count_(0), start_timestamp_(0), elapsed_time_(0) {} : death_test_count_(0), start_timestamp_(0), elapsed_time_(0) {}
// D'tor. // D'tor.
TestResult::~TestResult() {} TestResult::~TestResult() = default;
// Returns the i-th test part result among all the results. i can // Returns the i-th test part result among all the results. i can
// range from 0 to total_part_count() - 1. If i is not in that range, // range from 0 to total_part_count() - 1. If i is not in that range,
...@@ -2450,7 +2450,7 @@ Test::Test() : gtest_flag_saver_(new GTEST_FLAG_SAVER_) {} ...@@ -2450,7 +2450,7 @@ Test::Test() : gtest_flag_saver_(new GTEST_FLAG_SAVER_) {}
// The d'tor restores the states of all flags. The actual work is // The d'tor restores the states of all flags. The actual work is
// done by the d'tor of the gtest_flag_saver_ field, and thus not // done by the d'tor of the gtest_flag_saver_ field, and thus not
// visible here. // visible here.
Test::~Test() {} Test::~Test() = default;
// Sets up the test fixture. // Sets up the test fixture.
// //
...@@ -3362,7 +3362,7 @@ static void PrintFullTestCommentIfPresent(const TestInfo& test_info) { ...@@ -3362,7 +3362,7 @@ static void PrintFullTestCommentIfPresent(const TestInfo& test_info) {
// Class PrettyUnitTestResultPrinter is copyable. // Class PrettyUnitTestResultPrinter is copyable.
class PrettyUnitTestResultPrinter : public TestEventListener { class PrettyUnitTestResultPrinter : public TestEventListener {
public: public:
PrettyUnitTestResultPrinter() {} PrettyUnitTestResultPrinter() = default;
static void PrintTestName(const char* test_suite, const char* test) { static void PrintTestName(const char* test_suite, const char* test) {
printf("%s.%s", test_suite, test); printf("%s.%s", test_suite, test);
} }
...@@ -3670,7 +3670,7 @@ void PrettyUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test, ...@@ -3670,7 +3670,7 @@ void PrettyUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
// Class BriefUnitTestResultPrinter is copyable. // Class BriefUnitTestResultPrinter is copyable.
class BriefUnitTestResultPrinter : public TestEventListener { class BriefUnitTestResultPrinter : public TestEventListener {
public: public:
BriefUnitTestResultPrinter() {} BriefUnitTestResultPrinter() = default;
static void PrintTestName(const char* test_suite, const char* test) { static void PrintTestName(const char* test_suite, const char* test) {
printf("%s.%s", test_suite, test); printf("%s.%s", test_suite, test);
} }
......
...@@ -97,7 +97,7 @@ class Base { ...@@ -97,7 +97,7 @@ class Base {
explicit Base(int n) : member_(n) {} explicit Base(int n) : member_(n) {}
Base(const Base&) = default; Base(const Base&) = default;
Base& operator=(const Base&) = default; Base& operator=(const Base&) = default;
virtual ~Base() {} virtual ~Base() = default;
int member() { return member_; } int member() { return member_; }
private: private:
...@@ -982,7 +982,7 @@ TEST(ThreadLocalTest, SingleParamConstructorInitializesToParam) { ...@@ -982,7 +982,7 @@ TEST(ThreadLocalTest, SingleParamConstructorInitializesToParam) {
class NoDefaultConstructor { class NoDefaultConstructor {
public: public:
explicit NoDefaultConstructor(const char*) {} explicit NoDefaultConstructor(const char*) {}
NoDefaultConstructor(const NoDefaultConstructor&) {} NoDefaultConstructor(const NoDefaultConstructor&) = default;
}; };
TEST(ThreadLocalTest, ValueDefaultContructorIsNotRequiredForParamVersion) { TEST(ThreadLocalTest, ValueDefaultContructorIsNotRequiredForParamVersion) {
......
...@@ -108,7 +108,7 @@ class UnprintableTemplateInGlobal { ...@@ -108,7 +108,7 @@ class UnprintableTemplateInGlobal {
// A user-defined streamable type in the global namespace. // A user-defined streamable type in the global namespace.
class StreamableInGlobal { class StreamableInGlobal {
public: public:
virtual ~StreamableInGlobal() {} virtual ~StreamableInGlobal() = default;
}; };
inline void operator<<(::std::ostream& os, const StreamableInGlobal& /* x */) { inline void operator<<(::std::ostream& os, const StreamableInGlobal& /* x */) {
...@@ -216,7 +216,7 @@ class PathLike { ...@@ -216,7 +216,7 @@ class PathLike {
using value_type = char; using value_type = char;
using const_iterator = iterator; using const_iterator = iterator;
PathLike() {} PathLike() = default;
iterator begin() const { return iterator(); } iterator begin() const { return iterator(); }
iterator end() const { return iterator(); } iterator end() const { return iterator(); }
...@@ -749,7 +749,7 @@ AssertionResult HasPrefix(const StringType& str, const StringType& prefix) { ...@@ -749,7 +749,7 @@ AssertionResult HasPrefix(const StringType& str, const StringType& prefix) {
struct Foo { struct Foo {
public: public:
virtual ~Foo() {} virtual ~Foo() = default;
int MyMethod(char x) { return x + 1; } int MyMethod(char x) { return x + 1; }
virtual char MyVirtualMethod(int /* n */) { return 'a'; } virtual char MyVirtualMethod(int /* n */) { return 'a'; }
......
...@@ -61,7 +61,7 @@ int g_environment_tear_down_count = 0; ...@@ -61,7 +61,7 @@ int g_environment_tear_down_count = 0;
class MyEnvironment : public testing::Environment { class MyEnvironment : public testing::Environment {
public: public:
MyEnvironment() {} MyEnvironment() = default;
void SetUp() override { g_environment_set_up_count++; } void SetUp() override { g_environment_set_up_count++; }
void TearDown() override { g_environment_tear_down_count++; } void TearDown() override { g_environment_tear_down_count++; }
}; };
......
...@@ -4951,7 +4951,7 @@ TEST(ComparisonAssertionTest, AcceptsUnprintableArgs) { ...@@ -4951,7 +4951,7 @@ TEST(ComparisonAssertionTest, AcceptsUnprintableArgs) {
// both in a TEST and in a TEST_F. // both in a TEST and in a TEST_F.
class Foo { class Foo {
public: public:
Foo() {} Foo() = default;
private: private:
int Bar() const { return 1; } int Bar() const { return 1; }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment