-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove redundant member field initialization #3070
Remove redundant member field initialization #3070
Conversation
…adability-redundant-member-init' -fix
7819abc
to
1d1429a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gave up on reviewing. 700 touched lines of code.
Edit: why not follow the usual strategy of splitting over modules?
@@ -64,7 +64,7 @@ namespace pcl | |||
int callback_counter; | |||
public: | |||
|
|||
Synchronizer () : mutex1_ (), mutex2_ (), publish_mutex_ (), queueT1 (), queueT2 (), cb_ (), callback_counter (0) { }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea why clang "ignored" the other 3 default initialized members?
@@ -45,7 +45,6 @@ | |||
template <typename PointT> | |||
pcl::PCLBase<PointT>::PCLBase () | |||
: input_ () | |||
, indices_ () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question here for input()
.
@@ -104,7 +104,6 @@ namespace pcl | |||
min_radius_(0.1), | |||
point_density_radius_(0.2), | |||
descriptor_length_ (), | |||
rng_ (), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
descriptor_length_()
@@ -74,7 +74,7 @@ namespace pcl | |||
typedef typename Feature<PointInT, PointOutT>::PointCloudOut PointCloudOut; | |||
|
|||
/** \brief Empty constructor. */ | |||
ESFEstimation () : lut_ (), local_cloud_ () | |||
ESFEstimation () : local_cloud_ () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here.
aabb_min_point_ (), | ||
aabb_max_point_ (), | ||
obb_min_point_ (), | ||
obb_max_point_ (), | ||
obb_position_ (0.0f, 0.0f, 0.0f), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here.
@@ -85,7 +85,7 @@ namespace pcl | |||
/** \brief Data leaf. */ | |||
struct Leaf | |||
{ | |||
Leaf () : data_indices (), pt_on_surface (), vect_at_grid_pt () {} | |||
Leaf () {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make it default.
cell_hash_map_ (), min_p_ (), max_p_ (), leaf_size_ (0.001), gaussian_scale_ (), | ||
data_size_ (0), max_binary_search_level_ (10), k_ (50), padding_size_ (3), data_ (), | ||
vector_at_data_point_ (), surface_ (), occupied_cell_list_ () | ||
cell_hash_map_ (), leaf_size_ (0.001), gaussian_scale_ (), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here.
data_size_ (0), max_binary_search_level_ (10), k_ (50), padding_size_ (3), data_ (), | ||
vector_at_data_point_ (), surface_ (), occupied_cell_list_ () | ||
cell_hash_map_ (), leaf_size_ (resolution), gaussian_scale_ (), | ||
data_size_ (0), max_binary_search_level_ (10), k_ (50), padding_size_ (3), data_ () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here.
@@ -838,7 +838,7 @@ template <typename PointInT, typename PointOutT> | |||
pcl::MovingLeastSquares<PointInT, PointOutT>::MLSVoxelGrid::MLSVoxelGrid (PointCloudInConstPtr& cloud, | |||
IndicesPtr &indices, | |||
float voxel_size) : | |||
voxel_grid_ (), bounding_min_ (), bounding_max_ (), data_size_ (), voxel_size_ (voxel_size) | |||
voxel_grid_ (), data_size_ (), voxel_size_ (voxel_size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here.
@@ -295,9 +295,7 @@ namespace pcl | |||
|
|||
/** \brief Empty constructor. */ | |||
MovingLeastSquares () : CloudSurfaceProcessing<PointInT, PointOutT> (), | |||
normals_ (), | |||
distinct_cloud_ (), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here.
👍 though I'd say there is no need for a separate PR for each and every module. This overloads our 10 free runners on CI. Last time it took over a day to run all the jobs through. We may group modules with few changes into a single PR. Edit: @SergioRAgostinho did you take a note of which modules' changes you reviewer? I propose to limit this PR to those modules and strip everything else. |
All files in alphabetical order up to the last comment. So it means I stopped halfway through surface. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to go through the rest, but realized to be consistent with your suggestions, it's better if we formulate a "meta-suggestion" (what we are looking to have in general) first. As far as I understand:
- Check remaining default-constructed members, eliminate those that are not needed;
- Eleminate (or
= default
) constructors that have not init-list and empty body.
Anything else I missed?
@@ -99,7 +99,7 @@ namespace pcl | |||
typedef PolygonMesh::ConstPtr PolygonMeshConstPtr; | |||
|
|||
/** \brief Constructor. */ | |||
MeshProcessing () : input_mesh_ () {} | |||
MeshProcessing () {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MeshProcessing () {} | |
MeshProcessing () = default; |
@@ -50,7 +50,7 @@ namespace pcl | |||
{ | |||
public: | |||
|
|||
TicToc () : tictic_ () {} | |||
TicToc () {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need in explicit constructor.
I knew I will open another can of worms with this. So I wanted to force you to only check automatic changes of clang-tidy. If we really want to clean constructors, this will be thousand of lines, because then we have to think about constructor inheritance, sense of some classes, like here: pcl/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/in_hand_scanner.h Lines 215 to 229 in 1d1429a
And of course we have to check a lot of documentary seen (e.g. clang-tidy didn't removed constructor of std::vector in case there is a custom allocator (Eigen)) In general I suggest to check here only clang-tidy fixes and make separate PR for manual search of unnecessary code. |
🤦♂
Any idea why that happens?
I see. In that case I say we simply merge as is. This was an automated change, it is compiling and passing all tests. |
My terminal is swamped with:
after merging this. Will send a fix reintroducing |
You are right, the ubuntu build is flooded by this (500 warnings of this type). As far as I can see both are right: clang-tidy & compiler. Example: Before: pcl/octree/include/pcl/octree/octree_container.h Lines 141 to 145 in 99362da
Now: pcl/octree/include/pcl/octree/octree_container.h Lines 140 to 143 in 6c3bbea
Correct:
clang-tidy removed it, because default base constructor will be always executed. Or just remove custom copy constructor implementation. I think this would be the best solution. |
Just mention: I currently going throw the warnings. Not sure if I get ready with my remaining time today. If not I send a PR with already fixed warnings, |
I've already submitted #3075. But I may have missed some, of course. |
I filtered output of Azure and yeah, you missed a lot ;). |
I vote to remove it.
Don´t forget to add a comment on the side so we don't feel tempted to accidentally remove it again. |
In the process we figured out (see comments in the linked PR) that it should be |
Changes are done by
run-clang-tidy -header-filter='.*' -checks='-*,readability-redundant-member-init' -fix
I sure there are more unnecessary explicit member init (and unnecessary empty constructors), but PR is already big enough with these automatic changes.