[index] Fix infinite loop while looking at superclasses
While checking for superclasses in isUnitTest, we need to handle
circular inheritance. For good measure, add tests for protocols as well.
The new API is designed to behave the same as walkInheritedProtocols
except that is walks over superclasses.
rdar://49434989