How to do clang-tidy checks that need global TU information?

I’m working on a check that replaces “function-like” macros with an inline function. Because macro arguments don’t have types, I have to use a template function with deduced argument types. However, it would be nice if I could identify that all calls to a macro consistently use a particular type for the arguments.

I can certainly detect this within a single translation unit, but how do I know if the macro (likely to be defined in a header and included in multiple translation units) is used consistently throughout all translation units to know it’s safe to replace the auto deduced parameter type with a specific type?

Currently clang-tidy invokes each check on each translation unit separately and I’m not aware of any mechanism that fires once all the requested translation units have been processed. Indeed, it could be the case that it takes multiple invocations of clang-tidy in order to process all the translation units mentioned in a compile command database.

Has anyone else given thought as to what such a mechanism might look like?


Random idea: check gathers relevant info into a JSON file per translation unit and an auxiliary program is invoked afterwards to process the JSON file and apply fixits based on global knowledge?