Skip to content

Commit

Permalink
Cleanup: enable modernize-use-equals-default check
Browse files Browse the repository at this point in the history
This removes a lot of unnecessary code that is generated by
the compiler automatically.

In very few cases, a defaulted destructor in a .cc file is
still necessary, because of forward declarations in the header.

I removed some defaulted virtual destructors, because they are not
necessary, when the parent class has a virtual destructor already.

Defaulted constructors are only necessary when there is another
constructor, but the class should still be default constructible.

Differential Revision: https://developer.blender.org/D10911
  • Loading branch information
JacquesLucke committed Apr 8, 2021
1 parent 0ea6603 commit 19dfb6e
Show file tree
Hide file tree
Showing 64 changed files with 14 additions and 419 deletions.
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ Checks: >
-modernize-use-auto,
-modernize-use-trailing-return-type,
-modernize-avoid-c-arrays,
-modernize-use-equals-default,
-modernize-use-nodiscard,
-modernize-loop-convert,
-modernize-pass-by-value,
Expand Down
2 changes: 1 addition & 1 deletion source/blender/blenkernel/BKE_geometry_set.hh
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class GeometryComponent {

public:
GeometryComponent(GeometryComponentType type);
virtual ~GeometryComponent();
virtual ~GeometryComponent() = default;
static GeometryComponent *create(GeometryComponentType component_type);

/* The returned component should be of the same type as the type this is called on. */
Expand Down
6 changes: 1 addition & 5 deletions source/blender/blenkernel/intern/cryptomatte.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct CryptomatteSession {
/* Layer names in order of creation. */
blender::Vector<std::string> layer_names;

CryptomatteSession();
CryptomatteSession() = default;
CryptomatteSession(const Main *bmain);
CryptomatteSession(StampData *stamp_data);
CryptomatteSession(const Scene *scene);
Expand All @@ -67,10 +67,6 @@ struct CryptomatteSession {
#endif
};

CryptomatteSession::CryptomatteSession()
{
}

CryptomatteSession::CryptomatteSession(const Main *bmain)
{
if (!BLI_listbase_is_empty(&bmain->objects)) {
Expand Down
4 changes: 0 additions & 4 deletions source/blender/blenkernel/intern/geometry_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ GeometryComponent::GeometryComponent(GeometryComponentType type) : type_(type)
{
}

GeometryComponent ::~GeometryComponent()
{
}

GeometryComponent *GeometryComponent::create(GeometryComponentType component_type)
{
switch (component_type) {
Expand Down
4 changes: 0 additions & 4 deletions source/blender/blenkernel/intern/volume.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,6 @@ static struct VolumeFileCache {
};

/* Cache */
VolumeFileCache()
{
}

~VolumeFileCache()
{
BLI_assert(cache.empty());
Expand Down
3 changes: 0 additions & 3 deletions source/blender/blenlib/intern/delaunay_2d.cc
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,6 @@ template<typename T> class CDT_state {
T epsilon;

explicit CDT_state(int num_input_verts, int num_input_edges, int num_input_faces, T epsilon);
~CDT_state()
{
}
};

template<typename T> CDTArrangement<T>::~CDTArrangement()
Expand Down
79 changes: 1 addition & 78 deletions source/blender/blenlib/intern/mesh_intersect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,7 @@ IMeshArena::IMeshArena()
pimpl_ = std::make_unique<IMeshArenaImpl>();
}

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

void IMeshArena::reserve(int vert_num_hint, int face_num_hint)
{
Expand Down Expand Up @@ -753,27 +751,6 @@ struct BoundingBox {
BoundingBox(const float3 &min, const float3 &max) : min(min), max(max)
{
}
BoundingBox(const BoundingBox &other) : min(other.min), max(other.max)
{
}
BoundingBox(BoundingBox &&other) noexcept : min(std::move(other.min)), max(std::move(other.max))
{
}
~BoundingBox() = default;
BoundingBox operator=(const BoundingBox &other)
{
if (this != &other) {
min = other.min;
max = other.max;
}
return *this;
}
BoundingBox operator=(BoundingBox &&other) noexcept
{
min = std::move(other.min);
max = std::move(other.max);
return *this;
}

void combine(const float3 &p)
{
Expand Down Expand Up @@ -936,28 +913,6 @@ class CoplanarCluster {
{
this->add_tri(t, bb);
}
CoplanarCluster(const CoplanarCluster &other) : tris_(other.tris_), bb_(other.bb_)
{
}
CoplanarCluster(CoplanarCluster &&other) noexcept
: tris_(std::move(other.tris_)), bb_(std::move(other.bb_))
{
}
~CoplanarCluster() = default;
CoplanarCluster &operator=(const CoplanarCluster &other)
{
if (this != &other) {
tris_ = other.tris_;
bb_ = other.bb_;
}
return *this;
}
CoplanarCluster &operator=(CoplanarCluster &&other) noexcept
{
tris_ = std::move(other.tris_);
bb_ = std::move(other.bb_);
return *this;
}

/* Assume that caller knows this will not be a duplicate. */
void add_tri(int t, const BoundingBox &bb)
Expand Down Expand Up @@ -1073,38 +1028,6 @@ struct ITT_value {
ITT_value(ITT_value_kind k, const mpq3 &p1, const mpq3 &p2) : p1(p1), p2(p2), kind(k)
{
}
ITT_value(const ITT_value &other)
: p1(other.p1), p2(other.p2), t_source(other.t_source), kind(other.kind)
{
}
ITT_value(ITT_value &&other) noexcept
: p1(std::move(other.p1)),
p2(std::move(other.p2)),
t_source(other.t_source),
kind(other.kind)
{
}
~ITT_value()
{
}
ITT_value &operator=(const ITT_value &other)
{
if (this != &other) {
kind = other.kind;
p1 = other.p1;
p2 = other.p2;
t_source = other.t_source;
}
return *this;
}
ITT_value &operator=(ITT_value &&other) noexcept
{
kind = other.kind;
p1 = std::move(other.p1);
p2 = std::move(other.p2);
t_source = other.t_source;
return *this;
}
};

static std::ostream &operator<<(std::ostream &os, const ITT_value &itt);
Expand Down
4 changes: 0 additions & 4 deletions source/blender/blenlib/intern/task_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,6 @@ class TBBTaskGroup : public tbb::task_group {
}
# endif
}

~TBBTaskGroup()
{
}
};
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@

#include "CLG_log.h"

BlendfileLoadingBaseTest::~BlendfileLoadingBaseTest()
{
}

void BlendfileLoadingBaseTest::SetUpTestCase()
{
testing::Test::SetUpTestCase();
Expand Down
2 changes: 0 additions & 2 deletions source/blender/blenloader/tests/blendfile_loading_base_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ class BlendfileLoadingBaseTest : public testing::Test {
struct Depsgraph *depsgraph = nullptr;

public:
virtual ~BlendfileLoadingBaseTest();

/* Sets up Blender just enough to not crash on loading
* a blendfile and constructing a depsgraph. */
static void SetUpTestCase();
Expand Down
4 changes: 0 additions & 4 deletions source/blender/compositor/intern/COM_NodeGraph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ namespace blender::compositor {
**** NodeGraph ****
*******************/

NodeGraph::NodeGraph()
{
}

NodeGraph::~NodeGraph()
{
while (m_nodes.size()) {
Expand Down
1 change: 0 additions & 1 deletion source/blender/compositor/intern/COM_NodeGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class NodeGraph {
Vector<Link> m_links;

public:
NodeGraph();
~NodeGraph();

const Vector<Node *> &nodes() const
Expand Down
4 changes: 0 additions & 4 deletions source/blender/compositor/intern/COM_NodeOperationBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ NodeOperationBuilder::NodeOperationBuilder(const CompositorContext *context, bNo
m_graph.from_bNodeTree(*context, b_nodetree);
}

NodeOperationBuilder::~NodeOperationBuilder()
{
}

void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
{
/* interface handle for nodes */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ class NodeOperationBuilder {

public:
NodeOperationBuilder(const CompositorContext *context, bNodeTree *b_nodetree);
~NodeOperationBuilder();

const CompositorContext &context() const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@

namespace blender::compositor {

AlphaOverKeyOperation::AlphaOverKeyOperation()
{
/* pass */
}

void AlphaOverKeyOperation::executePixelSampled(float output[4],
float x,
float y,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ namespace blender::compositor {
*/
class AlphaOverKeyOperation : public MixBaseOperation {
public:
/**
* Default constructor
*/
AlphaOverKeyOperation();

/**
* The inner loop of this operation.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@

namespace blender::compositor {

AlphaOverPremultiplyOperation::AlphaOverPremultiplyOperation()
{
/* pass */
}

void AlphaOverPremultiplyOperation::executePixelSampled(float output[4],
float x,
float y,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ namespace blender::compositor {
*/
class AlphaOverPremultiplyOperation : public MixBaseOperation {
public:
/**
* Default constructor
*/
AlphaOverPremultiplyOperation();

/**
* The inner loop of this operation.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@

namespace blender::compositor {

CalculateStandardDeviationOperation::CalculateStandardDeviationOperation()
{
/* pass */
}

void CalculateStandardDeviationOperation::executePixel(float output[4],
int /*x*/,
int /*y*/,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ class CalculateStandardDeviationOperation : public CalculateMeanOperation {
float m_standardDeviation;

public:
CalculateStandardDeviationOperation();

/**
* The inner loop of this operation.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@

namespace blender::compositor {

ConvolutionEdgeFilterOperation::ConvolutionEdgeFilterOperation()
{
/* pass */
}

void ConvolutionEdgeFilterOperation::executePixel(float output[4], int x, int y, void * /*data*/)
{
float in1[4], in2[4], res1[4] = {0.0}, res2[4] = {0.0};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ namespace blender::compositor {

class ConvolutionEdgeFilterOperation : public ConvolutionFilterOperation {
public:
ConvolutionEdgeFilterOperation();
void executePixel(float output[4], int x, int y, void *data) override;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@

namespace blender::compositor {

DistanceYCCMatteOperation::DistanceYCCMatteOperation()
{
/* pass */
}

float DistanceYCCMatteOperation::calculateDistance(float key[4], float image[4])
{
/* only measure the second 2 values */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ namespace blender::compositor {
class DistanceYCCMatteOperation : public DistanceRGBMatteOperation {
protected:
float calculateDistance(float key[4], float image[4]) override;

public:
/**
* Default constructor
*/
DistanceYCCMatteOperation();
};

} // namespace blender::compositor
Loading

0 comments on commit 19dfb6e

Please sign in to comment.