diff options
author | Simon Marchi <simon.marchi@ericsson.com> | 2018-07-11 14:08:17 +0000 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2018-07-11 14:08:17 +0000 |
commit | a37ef291c84787329d1d77be66593042577b05ec (patch) | |
tree | 85f2ba8e0a3779690bf87098a443b841211afbe0 /clang/lib/Basic/FileManager.cpp | |
parent | 1edde95abdeab74cec1b83eaffce87f3afa8b1c4 (diff) | |
download | llvm-a37ef291c84787329d1d77be66593042577b05ec.zip llvm-a37ef291c84787329d1d77be66593042577b05ec.tar.gz llvm-a37ef291c84787329d1d77be66593042577b05ec.tar.bz2 |
[VirtualFileSystem] InMemoryFileSystem::status: Return a Status with the requested name
Summary:
InMemoryFileSystem::status behaves differently than
RealFileSystem::status. The Name contained in the Status returned by
RealFileSystem::status will be the path as requested by the caller,
whereas InMemoryFileSystem::status returns the normalized path.
For example, when requested the status for "../src/first.h",
RealFileSystem returns a Status with "../src/first.h" as the Name.
InMemoryFileSystem returns "/absolute/path/to/src/first.h".
The reason for this change is that I want to make a unit test in the
clangd testsuite (where we use an InMemoryFileSystem) to reproduce a
bug I get with the clangd program (where a RealFileSystem is used).
This difference in behavior "hides" the bug in the unit test version.
In general, I guess it's good if InMemoryFileSystem works as much as
possible like RealFileSystem.
Doing so made the FileEntry::RealPathName value (assigned in
FileManager::getFile) wrong when using the InMemoryFileSystem. That's
because it assumes that vfs::File::getName will always return the real
path. I changed to to use FileSystem::getRealPath instead.
Subscribers: ilya-biryukov, ioeric, cfe-commits
Differential Revision: https://reviews.llvm.org/D48903
llvm-svn: 336807
Diffstat (limited to 'clang/lib/Basic/FileManager.cpp')
-rw-r--r-- | clang/lib/Basic/FileManager.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index 7e2d01c..0a79800 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/lib/Basic/FileManager.cpp @@ -315,9 +315,11 @@ const FileEntry *FileManager::getFile(StringRef Filename, bool openFile, UFE.InPCH = Data.InPCH; UFE.File = std::move(F); UFE.IsValid = true; - if (UFE.File) - if (auto RealPathName = UFE.File->getName()) - UFE.RealPathName = *RealPathName; + + SmallString<128> RealPathName; + if (!FS->getRealPath(InterndFileName, RealPathName)) + UFE.RealPathName = RealPathName.str(); + return &UFE; } |