I'm trying to set up clang-tidy to check the right naming conventions for global variables. I'd like it to be able to distinguish between global static and global non-static variables.
int globalNonStatic = 1; /* Should be camelBack */
static int GlobalStatic = 0; /* Should be CamelCase */
However, I can't find find which readability-identifier-naming option to use to distinguish between the 2
I've tried to do something like:
Checks: '-*,readability-identifier-naming'
CheckOptions:
- { key: readability-identifier-naming.GlobalVariableCase, value: camelBack }
- { key: readability-identifier-naming.VariableCase, value: CamelCase }
A similar approach (GlobalFunctionCase/FunctionCase) seemed to work for distinguishing between static and non-static functions. I got the following warning when running:
warning: invalid case style for global variable 'GlobalStatic' [readability-identifier-naming]
static int GlobalStatic = 0; /* Should be CamelCase */
^~~~~~~~~~~~
globalStatic
I've also tried with the following options, but no luck:
- StaticVariableCase
- LocalVariableCase
Am I missing a specific (undocumented) option that can be used to achieve different style checks for static/non-static global variables?
Edit: Also found an issue reported on the subject in the LLVM issue tracker, but no replies yet (since 2019): https://bugs.llvm.org/show_bug.cgi?id=42634