[PATCH] D48903: [VirtualFileSystem] InMemoryFileSystem::status: Return a Status with the requested name
Simon Marchi via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 6 15:03:24 PDT 2018
simark added a comment.
I found something fishy. There is this code in FileManager.cpp:
if (UFE.File)
if (auto RealPathName = UFE.File->getName())
UFE.RealPathName = *RealPathName;
The real path is obtained from `UFE.File->getName()`. In the `RealFile` implementation, it returns the `RealName` field, which is fine. For other implementations, it uses `File::getName`, which is:
/// Get the name of the file
virtual llvm::ErrorOr<std::string> getName() {
if (auto Status = status())
return Status->getName().str();
else
return Status.getError();
}
With the `InMemoryFileSystem`, this now returns a non-real path. The result is that we fill `RealPathName` with that non-real path. I see two options here:
1. Either the FileManager is wrong to assume that `File::getName` returns a real path, and should call `FS->getRealPath` to do the job.
2. If the contract is that the ` File::getName` interface should return a real path, then we should fix the `File::getName` implementation to do that somehow.
I would opt for 1. This way, we could compute the `RealPathName` field even if we don't open the file (unlike currently).
Repository:
rC Clang
https://reviews.llvm.org/D48903
More information about the cfe-commits
mailing list