aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/FileManager.cpp
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2018-08-06 21:48:20 +0000
committerSimon Marchi <simon.marchi@ericsson.com>2018-08-06 21:48:20 +0000
commitddbabc6b7c3fc401d7b59f4c905c5964cb3c5643 (patch)
tree36e637942ed2dfdd485a9c35271eaf22aaf56df4 /clang/lib/Basic/FileManager.cpp
parent94b29601ef74d170a4b655839bfdba7c7183e708 (diff)
downloadllvm-ddbabc6b7c3fc401d7b59f4c905c5964cb3c5643.zip
llvm-ddbabc6b7c3fc401d7b59f4c905c5964cb3c5643.tar.gz
llvm-ddbabc6b7c3fc401d7b59f4c905c5964cb3c5643.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. An indirect impact of this change is that a -Wnonportable-include-path warning is now emitted in test PCH/case-insensitive-include.c. This is because the real path of the included file (with the wrong case) was not available previously, whereas it is now. Reviewers: malaperle, ilya-biryukov, bkramer Reviewed By: ilya-biryukov Subscribers: eric_niebler, malaperle, omtcyfz, hokein, bkramer, ilya-biryukov, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D48903 llvm-svn: 339063
Diffstat (limited to 'clang/lib/Basic/FileManager.cpp')
-rw-r--r--clang/lib/Basic/FileManager.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index d339b97..5f783a7 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;
}