There is a bug in lld which on some occasions causes InputFile::ArchiveName to store incorrect value. This happens because library name allocated on stack then converted to StringRef and assigned to member variable.
I think a better approach would be to change the type of ArchiveName from StringRef to std::string. This patch may fix the issue, but I'm not 100% sure because it fixes only one path that can reach addFile function. There might be some other places at which we pass on-stack objects to the function.