PointCloudLibrary / pcl

Point Cloud Library (PCL)
https://pointclouds.org/
Other
10.01k stars 4.62k forks source link

Add bugprone-macro-parentheses clang-tidy check #5967

Closed gnawme closed 8 months ago

gnawme commented 9 months ago

Adds the bugprone-macro-parentheses check to clang-tidy:

Finds macros that can have unexpected behavior due to missing parentheses.

There are macros that use std::stringstream to simulate variadic functions; these should probably be converted to use actual parameter packs.

gnawme commented 8 months ago

@mvieth what is with pcl_config.h? It's not showing up as tracked in my repo but I can see my fixes:

#define PCL_VERSION_CALC(MAJ, MIN, PATCH) ((MAJ)*100000+(MIN)*100+(PATCH))

However, CI is showing this:

/__w/pcl/pcl/include/pcl/pcl_config.h:17:44: error: macro argument should be enclosed in parentheses [bugprone-macro-parentheses,-warnings-as-errors]
#define PCL_VERSION_CALC(MAJ, MIN, PATCH) (MAJ*100000+MIN*100+PATCH)
                                           ^
                                           (  )
/__w/pcl/pcl/include/pcl/pcl_config.h:17:55: error: macro argument should be enclosed in parentheses [bugprone-macro-parentheses,-warnings-as-errors]
#define PCL_VERSION_CALC(MAJ, MIN, PATCH) (MAJ*100000+MIN*100+PATCH)
                                                      ^
                                                      (  )
/__w/pcl/pcl/include/pcl/pcl_config.h:17:63: error: macro argument should be enclosed in parentheses [bugprone-macro-parentheses,-warnings-as-errors]
#define PCL_VERSION_CALC(MAJ, MIN, PATCH) (MAJ*100000+MIN*100+PATCH)
                                                              ^
                                                              (    )
larshg commented 8 months ago

The pcl_config.h is generated from https://github.com/PointCloudLibrary/pcl/blob/master/pcl_config.h.in And you should remove the one from the build directory again 😀