Skip to content
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

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

Conversation

gnawme
Copy link
Contributor

@gnawme gnawme commented Feb 19, 2024

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.

Copy link
Member

@mvieth mvieth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like there are also some parentheses needed in pcl_config.h (PCL_VERSION_CALC)

common/include/pcl/exceptions.h Outdated Show resolved Hide resolved
search/include/pcl/search/impl/organized.hpp Outdated Show resolved Hide resolved
@gnawme
Copy link
Contributor Author

gnawme commented Feb 26, 2024

@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
Copy link
Contributor

larshg commented Feb 26, 2024

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 😀

ml/src/svm.cpp Outdated Show resolved Hide resolved
@gnawme gnawme force-pushed the feature/add-bugprone-macro-parentheses-tidy branch from 8235366 to 0ba2888 Compare March 1, 2024 15:55
Copy link
Member

@mvieth mvieth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mvieth mvieth merged commit d39bfc3 into PointCloudLibrary:master Mar 5, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants