Compare top-level modules when deciding visibility for redeclarations
Compare top-level modules when deciding visibility for redeclarations

When importing C declarations, one can come across a redeclaration due
to two different clang modules textually including the same header.

Previously, to decide visibility of a declaration from a particular
module, the module in which it is redeclarated had to exactly match the
one we saw before, so a struct defined in A.B.C might cause it to be
hidden in A.X.Y, because we were already popping off submodule names on
the "left hand side", so the module comparison was A != A.X.Y. If
someone imports A.X.Y and expects that struct, they won't see it.

Now, strip off submodules of the "right hand side", correctly comparing
if the top-level modules match (A == A).

This may have the effect of allowing more declarations to be visible
than before but it prevents weird situations where struct typedefs can
be hidden in overly complicated nested header includes normally found in
OS system headers.

rdar://problem/23588593

jmgc/swift,jckarter/swift,milseman/swift,lorentey/swift,tkremenek/swift,MukeshKumarS/Swift,lorentey/swift,mightydeveloper/swift,tinysun212/swift-windows,Jnosh/swift,allevato/swift,tkremenek/swift,gribozavr/swift,swiftix/swift,arvedviehweger/swift,sschiau/swift,uasys/swift,kusl/swift,OscarSwanros/swift,gmilos/swift,apple/swift,alblue/swift,tjw/swift,kstaring/swift,khizkhiz/swift,calebd/swift,amraboelela/swift,tkremenek/swift,adrfer/swift,Ivacker/swift,allevato/swift,shahmishal/swift,hooman/swift,austinzheng/swift,LeoShimonaka/swift,sschiau/swift,Ivacker/swift,ben-ng/swift,tinysun212/swift-windows,mightydeveloper/swift,kstaring/swift,zisko/swift,ken0nek/swift,emilstahl/swift,calebd/swift,khizkhiz/swift,stephentyrone/swift,karwa/swift,jopamer/swift,sdulal/swift,kusl/swift,calebd/swift,rudkx/swift,therealbnut/swift,karwa/swift,tinysun212/swift-windows,jopamer/swift,parkera/swift,JGiola/swift,djwbrown/swift,sschiau/swift,benlangmuir/swift,roambotics/swift,stephentyrone/swift,xedin/swift,danielmartin/swift,djwbrown/swift,jtbandes/swift,jopamer/swift,devincoughlin/swift,swiftix/swift,JGiola/swift,shajrawi/swift,kstaring/swift,kstaring/swift,apple/swift,CodaFi/swift,MukeshKumarS/Swift,lorentey/swift,shahmishal/swift,MukeshKumarS/Swift,xedin/swift,jtbandes/swift,arvedviehweger/swift,arvedviehweger/swift,Jnosh/swift,frootloops/swift,xwu/swift,deyton/swift,KrishMunot/swift,tardieu/swift,sdulal/swift,kentya6/swift,zisko/swift,JaSpa/swift,huonw/swift,modocache/swift,KrishMunot/swift,ahoppen/swift,Ivacker/swift,jtbandes/swift,felix91gr/swift,modocache/swift,amraboelela/swift,aschwaighofer/swift,IngmarStein/swift,hooman/swift,codestergit/swift,zisko/swift,felix91gr/swift,CodaFi/swift,practicalswift/swift,gottesmm/swift,ahoppen/swift,jtbandes/swift,adrfer/swift,huonw/swift,gribozavr/swift,slavapestov/swift,deyton/swift,JGiola/swift,MukeshKumarS/Swift,tkremenek/swift,felix91gr/swift,kusl/swift,johnno1962d/swift,cbrentharris/swift,arvedviehweger/swift,gottesmm/swift,tkremenek/swift,devincoughlin/swift,russbishop/swift,airspeedswift/swift,karwa/swift,jtbandes/swift,kusl/swift,swiftix/swift,shajrawi/swift,natecook1000/swift,ben-ng/swift,jopamer/swift,harlanhaskins/swift,arvedviehweger/swift,lorentey/swift,IngmarStein/swift,deyton/swift,huonw/swift,kstaring/swift,huonw/swift,austinzheng/swift,danielmartin/swift,tjw/swift,JaSpa/swift,practicalswift/swift,xedin/swift,slavapestov/swift,modocache/swift,jtbandes/swift,LeoShimonaka/swift,natecook1000/swift,cbrentharris/swift,johnno1962d/swift,jckarter/swift,hughbe/swift,adrfer/swift,sschiau/swift,johnno1962d/swift,manavgabhawala/swift,lorentey/swift,lorentey/swift,Jnosh/swift,allevato/swift,milseman/swift,jopamer/swift,ahoppen/swift,dduan/swift,gregomni/swift,kperryua/swift,therealbnut/swift,swiftix/swift,deyton/swift,johnno1962d/swift,brentdax/swift,hooman/swift,return/swift,ahoppen/swift,khizkhiz/swift,bitjammer/swift,OscarSwanros/swift,OscarSwanros/swift,practicalswift/swift,danielmartin/swift,russbishop/swift,parkera/swift,jmgc/swift,IngmarStein/swift,jmgc/swift,hooman/swift,deyton/swift,cbrentharris/swift,shahmishal/swift,austinzheng/swift,dduan/swift,kperryua/swift,sdulal/swift,jckarter/swift,ben-ng/swift,khizkhiz/swift,return/swift,arvedviehweger/swift,slavapestov/swift,gregomni/swift,emilstahl/swift,brentdax/swift,jtbandes/swift,xwu/swift,ken0nek/swift,SwiftAndroid/swift,brentdax/swift,gregomni/swift,kusl/swift,shahmishal/swift,glessard/swift,milseman/swift,IngmarStein/swift,allevato/swift,devincoughlin/swift,kentya6/swift,danielmartin/swift,therealbnut/swift,austinzheng/swift,CodaFi/swift,johnno1962d/swift,return/swift,uasys/swift,karwa/swift,glessard/swift,JaSpa/swift,xedin/swift,mightydeveloper/swift,therealbnut/swift,Jnosh/swift,therealbnut/swift,dduan/swift,frootloops/swift,IngmarStein/swift,slavapestov/swift,Jnosh/swift,natecook1000/swift,johnno1962d/swift,atrick/swift,kperryua/swift,shajrawi/swift,nathawes/swift,tinysun212/swift-windows,danielmartin/swift,brentdax/swift,return/swift,calebd/swift,bitjammer/swift,ben-ng/swift,kstaring/swift,parkera/swift,huonw/swift,modocache/swift,devincoughlin/swift,airspeedswift/swift,harlanhaskins/swift,shahmishal/swift,gottesmm/swift,frootloops/swift,aschwaighofer/swift,SwiftAndroid/swift,airspeedswift/swift,JaSpa/swift,alblue/swift,rudkx/swift,dreamsxin/swift,tardieu/swift,aschwaighofer/swift,uasys/swift,emilstahl/swift,apple/swift,harlanhaskins/swift,tardieu/swift,allevato/swift,jmgc/swift,glessard/swift,codestergit/swift,nathawes/swift,harlanhaskins/swift,ahoppen/swift,atrick/swift,Ivacker/swift,return/swift,tjw/swift,brentdax/swift,codestergit/swift,natecook1000/swift,OscarSwanros/swift,natecook1000/swift,karwa/swift,gregomni/swift,swiftix/swift,kperryua/swift,modocache/swift,roambotics/swift,uasys/swift,apple/swift,ahoppen/swift,harlanhaskins/swift,milseman/swift,kperryua/swift,aschwaighofer/swift,ken0nek/swift,ken0nek/swift,ken0nek/swift,brentdax/swift,kusl/swift,devincoughlin/swift,manavgabhawala/swift,adrfer/swift,emilstahl/swift,frootloops/swift,parkera/swift,ben-ng/swift,allevato/swift,adrfer/swift,stephentyrone/swift,benlangmuir/swift,zisko/swift,MukeshKumarS/Swift,kusl/swift,karwa/swift,parkera/swift,slavapestov/swift,shahmishal/swift,LeoShimonaka/swift,gottesmm/swift,tinysun212/swift-windows,SwiftAndroid/swift,gregomni/swift,sschiau/swift,hughbe/swift,airspeedswift/swift,gribozavr/swift,sdulal/swift,mightydeveloper/swift,rudkx/swift,sschiau/swift,danielmartin/swift,gmilos/swift,SwiftAndroid/swift,bitjammer/swift,shajrawi/swift,nathawes/swift,xedin/swift,uasys/swift,russbishop/swift,airspeedswift/swift,nathawes/swift,bitjammer/swift,MukeshKumarS/Swift,CodaFi/swift,emilstahl/swift,Jnosh/swift,djwbrown/swift,johnno1962d/swift,shajrawi/swift,deyton/swift,tardieu/swift,tardieu/swift,rudkx/swift,tkremenek/swift,brentdax/swift,stephentyrone/swift,gregomni/swift,ben-ng/swift,kentya6/swift,glessard/swift,parkera/swift,alblue/swift,Ivacker/swift,gmilos/swift,sdulal/swift,tjw/swift,JGiola/swift,mightydeveloper/swift,airspeedswift/swift,atrick/swift,ken0nek/swift,airspeedswift/swift,khizkhiz/swift,emilstahl/swift,rudkx/swift,manavgabhawala/swift,JaSpa/swift,uasys/swift,practicalswift/swift,tjw/swift,frootloops/swift,practicalswift/swift,milseman/swift,LeoShimonaka/swift,karwa/swift,CodaFi/swift,xwu/swift,khizkhiz/swift,practicalswift/swift,alblue/swift,manavgabhawala/swift,manavgabhawala/swift,felix91gr/swift,harlanhaskins/swift,roambotics/swift,Ivacker/swift,xedin/swift,milseman/swift,JGiola/swift,gmilos/swift,codestergit/swift,nathawes/swift,deyton/swift,bitjammer/swift,apple/swift,parkera/swift,swiftix/swift,hooman/swift,milseman/swift,ben-ng/swift,kentya6/swift,jmgc/swift,jmgc/swift,SwiftAndroid/swift,mightydeveloper/swift,apple/swift,LeoShimonaka/swift,emilstahl/swift,nathawes/swift,zisko/swift,hooman/swift,djwbrown/swift,hughbe/swift,mightydeveloper/swift,frootloops/swift,russbishop/swift,benlangmuir/swift,KrishMunot/swift,nathawes/swift,jckarter/swift,emilstahl/swift,tardieu/swift,gmilos/swift,djwbrown/swift,huonw/swift,gribozavr/swift,shajrawi/swift,allevato/swift,austinzheng/swift,sschiau/swift,IngmarStein/swift,Ivacker/swift,harlanhaskins/swift,KrishMunot/swift,cbrentharris/swift,amraboelela/swift,gribozavr/swift,felix91gr/swift,amraboelela/swift,KrishMunot/swift,JaSpa/swift,russbishop/swift,glessard/swift,hughbe/swift,MukeshKumarS/Swift,jckarter/swift,felix91gr/swift,hughbe/swift,hughbe/swift,gribozavr/swift,xedin/swift,arvedviehweger/swift,xwu/swift,LeoShimonaka/swift,xedin/swift,therealbnut/swift,austinzheng/swift,gottesmm/swift,JGiola/swift,gribozavr/swift,dduan/swift,amraboelela/swift,IngmarStein/swift,adrfer/swift,austinzheng/swift,alblue/swift,khizkhiz/swift,danielmartin/swift,devincoughlin/swift,JaSpa/swift,modocache/swift,sdulal/swift,aschwaighofer/swift,SwiftAndroid/swift,zisko/swift,tjw/swift,shahmishal/swift,modocache/swift,CodaFi/swift,amraboelela/swift,cbrentharris/swift,tkremenek/swift,adrfer/swift,atrick/swift,benlangmuir/swift,calebd/swift,djwbrown/swift,xwu/swift,roambotics/swift,KrishMunot/swift,frootloops/swift,stephentyrone/swift,CodaFi/swift,hughbe/swift,SwiftAndroid/swift,rudkx/swift,benlangmuir/swift,uasys/swift,dduan/swift,OscarSwanros/swift,sdulal/swift,tinysun212/swift-windows,lorentey/swift,return/swift,tardieu/swift,zisko/swift,hooman/swift,shajrawi/swift,dduan/swift,kperryua/swift,atrick/swift,tjw/swift,devincoughlin/swift,aschwaighofer/swift,cbrentharris/swift,kperryua/swift,bitjammer/swift,ken0nek/swift,tinysun212/swift-windows,lorentey/swift,codestergit/swift,mightydeveloper/swift,slavapestov/swift,atrick/swift,russbishop/swift,Ivacker/swift,manavgabhawala/swift,return/swift,dreamsxin/swift,OscarSwanros/swift,devincoughlin/swift,jckarter/swift,benlangmuir/swift,LeoShimonaka/swift,swiftix/swift,gottesmm/swift,gribozavr/swift,felix91gr/swift,jopamer/swift,cbrentharris/swift,stephentyrone/swift,karwa/swift,slavapestov/swift,parkera/swift,stephentyrone/swift,kstaring/swift,practicalswift/swift,alblue/swift,alblue/swift,huonw/swift,OscarSwanros/swift,Jnosh/swift,sdulal/swift,calebd/swift,kentya6/swift,KrishMunot/swift,glessard/swift,roambotics/swift,xwu/swift,shahmishal/swift,aschwaighofer/swift,natecook1000/swift,kentya6/swift,natecook1000/swift,calebd/swift,codestergit/swift,cbrentharris/swift,gmilos/swift,amraboelela/swift,jckarter/swift,dduan/swift,gmilos/swift,kentya6/swift,shajrawi/swift,codestergit/swift,LeoShimonaka/swift,gottesmm/swift,jmgc/swift,xwu/swift,russbishop/swift,djwbrown/swift,jopamer/swift,sschiau/swift,kusl/swift,therealbnut/swift,practicalswift/swift,kentya6/swift,manavgabhawala/swift,bitjammer/swift,roambotics/swift