When type names are too long to fit into a type record, the names need to be
truncated. The existing algorithm shrinks the name and unique name by
a proportionate amount until they fit into a type record. If the unique name
is significantly shorter then it can be reduced to a zero length string
resulting in the following crash:
Failure value returned from cantFail wrapped call Stream Error: The stream is too short to perform the requested operation. UNREACHABLE executed at llvm/include/llvm/Support/Error.h:718! PLEASE submit a bug report to https://bugs.llvm.org/ ...
Instead, reduce the size of the type record by:
- Replacing the entire linkage name with an MD5 hash.
- Truncate the source name and append an MD5 hash.
This matches the behavior of Visual Studio 2017.
Are these locals necessary? We should be able to map NameB and UniqueB directly.