6

Anyone know of any sources for a LLVMHeaderGuardCheck like clang-tidy check that formats the expected include guards based on configurable information like the include path(s) given on the command line?

More details...

The LLVMHeaderGuardCheck header guard check expects header file include guard macro names that are all uppercase letters of the path after include/ with the / replaced by _ and a suffix like .h or .hpp replaced with _H. That works as a fine header guard check so long as your header files are all under a common root that has include/ in its path.

What I'm looking instead for is a check which works based on the path given in a -I$path command line argument. So if given an include file path like -I/usr/local/xyz an include file named /usr/local/xyz/common/foo.h needs to have include guard of XYZ_COMMON_FOO_H.

I wrote some code to work for the meantime but my commit only uses the path as an option from the .clang-tidy configuration file. While this suffices, it's not as flexible as a solution that can also use the command line info.

So I'm wondering what else is out there as open source checks for clang-tidy for header file include guard naming checks as I haven't had any luck finding anything via the web searching I've done to-date.

Louis Langholtz
  • 2,913
  • 3
  • 17
  • 40

0 Answers0