This patch avoids unnecessarily copying contents of mmap-ed files into CachedFileSystemEntry by storing MemoryBuffer instead. The change leads to ~50% reduction of peak memory footprint when scanning LLVM+Clang via clang-scan-deps.
Depends on D115331.
In the implementation of this function we get std::unique_ptr<llvm::vfs::File> from the underlying filesystem. When that goes out of scope, the file descriptor will be closed immediately. How did copying contents into memory prevent running out of file descriptors? @arphaman