swift
0d495293 - [ClangImporter] Make sure fake locations are always in /some/ buffer. (#8303)

Commit
8 years ago
[ClangImporter] Make sure fake locations are always in /some/ buffer. (#8303) We synthesize fake source locations for module imports that come from Swift code; these locations have to be both valid and distinct for Clang to use. We've mostly been getting away with simply making fake offsets from the main file, but after the offsets start exceeding the size of the buffer they start pointing into some /other/ file, and then if Clang's SourceManager tries to order those locations it gets /very/ confused. This commit fixes that by allocating a 256K buffer of zeros and using offsets into that instead. The hope is that a read-only mmap'd buffer of zeros that never gets read (except possibly to look for newlines) will be cheap to allocate. (Why not just make the main file buffer 256K? Because we actually try to parse that, and there's really no reason for the lexer to go crawl through that file eagerly.) This test case isn't the best because it doesn't actually fail in the old code, but if only the assertion was added we at least hit that. I did verify with the reproducing project I have that we no longer hit this issue. rdar://problem/30924269
Author
Committer
Parents
Loading