[Remote] Cache built types when reading metadata (#2871)
If bad data is fed to the reader, it might be convinced it's looking at
a generic type. If the generic type parameter also happens to be the
same metadata pointer, an infinite recursion results. To prevent this,
insert an invalid type into the cache at the start of the read. If we
then ask for that same metadata pointer again, we'll return the
invalid/empty built type.
This also might improve performance a little by preventing rereading
and rebuilding types.
rdar://problem/26529650