Commits

Jordan Rose committed 3d3c6fa730e
[ClangImporter] Fix crash when a diagnostic is reported during module building. This rare crash happens when 1. A diagnostic is reported when building a Clang module. 2. The diagnostic is mapped to a Swift diagnostic by mirroring the Clang source buffer as a Swift source buffer (via non-owning reference). 3. The Clang CompilerInstance used specifically to build the module is destroyed. 4. Some /new/ buffer is allocated in the same memory spot as the old buffer. 5. Some new Clang diagnostic occurs in the new buffer. 6. The Swift source manager asserts when trying to set up a virtual name for the diagnostic in the second imported buffer, because there's already a name for that region. The fix, because we don't expect diagnostics from modules to appear very often, is to keep any clang::SourceManagers alive if diagnostics are emitted in their buffers. We can revisit this if/when Swift's source manager (currently built on llvm::SourceMgr) has the ability to remove buffers. Many thanks to Greg for noticing the problem, tracking it down, and providing a diff to make it fail reproducibly under GuardMalloc. I've tried to preserve the spirit of that diff in the new logic in ~SourceManager, which will also fail reliably with GuardMalloc (and probably ASan). rdar://problem/18285805 Swift SVN r21958