If a semantic update finishes fast enough, the token snapshot may be
identical to the edit snapshot, but because of getBufferForSnapshot
consolidating edits into a new buffer, we were not detecting that case
properly, and it could cause an assertion failure (or potentially
incorrect range shifting in a release build). This would have reproduced
very rarely in practice, but I can reproduce it by putting `sleep(2)`
calls right before we read the semantic info in open and edit requests.
Incidentally, fix sourcekit-test and unit tests for the (rare) case
where an open or edit already has updated semantic info.
Otherwise, hits assertion, or crashes in no-assertion build.
Added 'EditableTextBuffer::getSize()' for getting size after previous updates
without actually applying them.
rdar://problem/34206143
After my PR 13591 to adjust for LLVM r321257, the Linux bots are failing with
errors about missing conversions. For some reason that I don't understand,
those errors do not reproduce when I build locally on macOS. I think this
change should fix them. I also cleaned up some const_casts that should now
be unnecessary when using WritableMemoryBuffer.
Found by TSan!
This was found while trying to reproduce a test failure on a linux bot
while running the test/Misc/stats.swift test. Hopefully this was the
underlying issue.
rdar://35537968
The code goes into its own sub-tree under 'tools' but tests go under 'test',
so that running 'check-swift' will also run all the SourceKit tests.
SourceKit is disabled on non-darwin platforms.