diff options
| author | Taewook Oh <twoh@fb.com> | 2016-06-13 17:03:18 +0000 |
|---|---|---|
| committer | Taewook Oh <twoh@fb.com> | 2016-06-13 17:03:18 +0000 |
| commit | f0c013a48e3039cbb369e7dc8779b95455e3fb7c (patch) | |
| tree | 7472bae2ae8e1d1f605b5aa67d0019c7ff643929 /lib/Basic/VirtualFileSystem.cpp | |
| parent | aa6f4a7a3e3bbc248f86859a8d7f5af4bebef16b (diff) | |
Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.
Differential Revision: http://reviews.llvm.org/D19843
Corresponding LLVM change: http://reviews.llvm.org/D19842
Re-commit after addressing issues with of generating too many warnings for Windows and asan test failures.
Patch by Eric Niebler
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272562 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic/VirtualFileSystem.cpp')
| -rw-r--r-- | lib/Basic/VirtualFileSystem.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/Basic/VirtualFileSystem.cpp b/lib/Basic/VirtualFileSystem.cpp index 2eb7a84521..8ace2b3dc8 100644 --- a/lib/Basic/VirtualFileSystem.cpp +++ b/lib/Basic/VirtualFileSystem.cpp @@ -140,16 +140,19 @@ namespace { class RealFile : public File { int FD; Status S; + std::string RealName; friend class RealFileSystem; - RealFile(int FD, StringRef NewName) + RealFile(int FD, StringRef NewName, StringRef NewRealPathName) : FD(FD), S(NewName, {}, {}, {}, {}, {}, - llvm::sys::fs::file_type::status_error, {}) { + llvm::sys::fs::file_type::status_error, {}), + RealName(NewRealPathName.str()) { assert(FD >= 0 && "Invalid or inactive file descriptor"); } public: ~RealFile() override; ErrorOr<Status> status() override; + ErrorOr<std::string> getName() override; ErrorOr<std::unique_ptr<MemoryBuffer>> getBuffer(const Twine &Name, int64_t FileSize, bool RequiresNullTerminator, @@ -170,6 +173,10 @@ ErrorOr<Status> RealFile::status() { return S; } +ErrorOr<std::string> RealFile::getName() { + return RealName.empty() ? S.getName().str() : RealName; +} + ErrorOr<std::unique_ptr<MemoryBuffer>> RealFile::getBuffer(const Twine &Name, int64_t FileSize, bool RequiresNullTerminator, bool IsVolatile) { @@ -207,9 +214,10 @@ ErrorOr<Status> RealFileSystem::status(const Twine &Path) { ErrorOr<std::unique_ptr<File>> RealFileSystem::openFileForRead(const Twine &Name) { int FD; - if (std::error_code EC = sys::fs::openFileForRead(Name, FD)) + SmallString<256> RealName; + if (std::error_code EC = sys::fs::openFileForRead(Name, FD, &RealName)) return EC; - return std::unique_ptr<File>(new RealFile(FD, Name.str())); + return std::unique_ptr<File>(new RealFile(FD, Name.str(), RealName.str())); } llvm::ErrorOr<std::string> RealFileSystem::getCurrentWorkingDirectory() const { |
