This allows clients to invoke clang without writing anything to disk.
I'm not sure if this is the right design, so I'm sending this patch to
start a discussion about the right way to do this. I'll be happy to make
changes and add tests after talking about the right way to do this!
At Google, we run some Swift source tooling on diskless servers. The
Swift source tooling calls Clang through the ClangImporter
Clang compiles module to an on-disk module cache, which does not work on
the diskless servers. This patch lets clients ask Clang to write the
module cache to memory.
- Adds class InMemoryOutputFileSystem : public llvm::vfs::FileSystem that supports write operations backed by memory. After a file is written, its contents are accessible through the llvm::vfs::FileSystem interface.
- Adds an InMemoryOutputFileSystem field to CompilerInstance. When this field is set, the CompilerInstance writes to the InMemoryOutputFileSystem instead of the real file system.