ClangTool using single FileManager might confuse two header files with the same relative path in different CWD(current working directory).
As the cache of previously opened FileEntry in FileManager is indexed by the file name, which is fine to be used in single compiler invocation, ClangTool, however, needs to parse more than one compile command, and the CWD is not assured to be consistent, thus the previous cached FileEntry which uses relative path as index would be invalid.
This patch tries to solve it by using a container named ToolFileManager called, which actually stores different FileManager for different CWD.
All file managers stored in ToolFileManager will be invalidated from where using FileManager::setVirtualFileSystem(), because of possibly unsound file status caches.
The unit test is written by Hao Zhang <zhanghao19@ios.ac.cn> in his original but unfinished commit.
Refer-to: https://github.com/llvm/llvm-project/issues/54410
Refer-to: https://reviews.llvm.org/D92160
This will *never* reuse the file manager, since it's *always* a new VFS.