Swift validates the retain/release operations for foreign reference types to check for obvious errors, e.g. a wrong parameter type or return type.
That logic was only running for C++ foreign reference types. This patch enables it for C foreign reference types as well.
rdar://158609723
The code for handling Swift conforms_to attributes was specific to
C++ record types. Generalize it to work on typedefs imported as
nominal types, also in C.
Fixes rdar://156290361.
Some of the patterns in the new test header are special-cased by
ClangImporter (for example, the names of typedefs become names of
imported structs).
Nested structs have been historically imported in Swift according to C
rules, that is, structs lexically declared nested in other structs are
imported into the global namespace anyway. For the same reason, C
structs have been mangled in Swift names as if they are declared in the
global namespace. These rules are problematic when importing C++, see
https://bugs.swift.org/browse/SR-12803.