Re-implement the RemappedFiles parameter to various ASTUnit entry points by storing buffers in an InMemoryFileSystem. This parameter is commonly used by indexing tools to pass in source files that haven't been saved to disk (yet). This is the same strategy ClangTool switched to in 2015.
The previous implementation added them to PreprocessorOptions::RemappedFileBuffers, which eventually triggers calls to FileManager::getVirtualFile and SourceManager::overrideFileContents. That's one of the blockers for sinking the content cache from SourceManager down to FileManager. The new strategy is also a bit cleaner (the old one predates llvm::vfs::FileSystem).
Follow-ups will handle the other two uses of RemappedFileBuffers in ASTUnit. One is for the preamble's serialized AST. The other is for overriding the main file buffer, which is a bit tricky since we need the ASTWriter to save the preamble-only version.
WIP: I'm not totally happy with this patch yet, but tests are finally passing so I'm posting this for early review. In the meantime I'll continue peeling off what I can for prep patches (or there may be changes I can just delete). Among other things, I want to add a test (in a prep patch) for the handling of a file showing up twice in the same RemappedFiles vector, since it was pretty tough to discover I needed special logic for that.
@kadircet, I'm curious if clang-tools-extra/clangd/Preamble.cpp's call to ASTUnit::CanReuse would benefit from this logic as well. I would guess clangd doesn't even try to reuse preambles when unsaved files have changed (since you might see the same crashes or wrong results I saw before adding this), but after this patch lands you might be able to do that safely.