Finding a variable declaration in several files

Hello,

I’m trying to write a Clang Tidy check that will generate a warning if a certain variable is declared as “extern” in more than one file.

I was able to add find extern variable declarations using AST matchers, but so far I haven’t managed to determine in my check if a variable is declared in two different files.

Does the Clang Tidy API provide a way of remembering nodes that were matched in previous checks? Or should I implement it myself (for example using a list or writing to a file)?

Thanks!
Gilad Beer