[VirtualFileSystem] Support creating directories then adding files inside
authorBen Hamilton <benhamilton@google.com>
Thu, 16 Nov 2017 19:34:08 +0000 (19:34 +0000)
committerBen Hamilton <benhamilton@google.com>
Thu, 16 Nov 2017 19:34:08 +0000 (19:34 +0000)
commit78381016785a3fc4b6304c8040198c9cdd0564d9
tree1e94a84e62094fe1bdca9346b40abe1abd9a38f2
parent4ca69bdac60db56a79d2eeb3cc62ced23f3f1d64
[VirtualFileSystem] Support creating directories then adding files inside

Summary:
In https://reviews.llvm.org/D39572 , I added support for specifying
`Type` when invoking `InMemoryFileSystem::addFile()`.

However, I didn't account for the fact that when `Type` is
`directory_file`, we need to construct an `InMemoryDirectory`, not an
`InMemoryFile`, or else clients cannot create files inside that
directory.

This diff fixes the bug and adds a test.

Test Plan: New test added. Ran test with:

  % make -j12 check-clang-tools

Reviewers: bkramer, hokein

Reviewed By: bkramer

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D40140

llvm-svn: 318445
clang/include/clang/Basic/VirtualFileSystem.h
clang/lib/Basic/VirtualFileSystem.cpp
clang/unittests/Basic/VirtualFileSystemTest.cpp