I debugged the problem from D84453 and D82188. The linker is not at fault - it's an ODR violation: there are two definitions for clang::tidy::test::TestCheck::registerMatchers. One test provides a non-trivial overload for registerMatchers, the other test doesn't overload this function (it only tests whether the check gets enabled when options are tweaked, so it doesn't register any matchers). When linker merges the two classes, the class without the overload may randomly win the race, and in this case the class that expects an overload appears to behave as if the function isn't called at all (because the definition in the superclass does nothing).
Put classes into anonymous namespaces to avoid the ODR violation.