Index: lib/Basic/VirtualFileSystem.cpp =================================================================== --- lib/Basic/VirtualFileSystem.cpp +++ lib/Basic/VirtualFileSystem.cpp @@ -508,10 +508,18 @@ class InMemoryFileAdaptor : public File { InMemoryFile &Node; + // The name to use when returning a Status for this file. + std::string RequestedName; + public: - explicit InMemoryFileAdaptor(InMemoryFile &Node) : Node(Node) {} + explicit InMemoryFileAdaptor(InMemoryFile &Node, std::string RequestedName) + : Node(Node), RequestedName (std::move (RequestedName)) + {} - llvm::ErrorOr status() override { return Node.getStatus(); } + llvm::ErrorOr status() override { + Status St = Node.getStatus(); + return Status::copyWithNewName(St, RequestedName); + } llvm::ErrorOr> getBuffer(const Twine &Name, int64_t FileSize, bool RequiresNullTerminator, @@ -711,7 +719,10 @@ llvm::ErrorOr InMemoryFileSystem::status(const Twine &Path) { auto Node = lookupInMemoryNode(*this, Root.get(), Path); if (Node) - return (*Node)->getStatus(); + { + Status St = (*Node)->getStatus(); + return Status::copyWithNewName(St, Path.str()); + } return Node.getError(); } @@ -724,7 +735,7 @@ // When we have a file provide a heap-allocated wrapper for the memory buffer // to match the ownership semantics for File. if (auto *F = dyn_cast(*Node)) - return std::unique_ptr(new detail::InMemoryFileAdaptor(*F)); + return std::unique_ptr(new detail::InMemoryFileAdaptor(*F, Path.str())); // FIXME: errc::not_a_file? return make_error_code(llvm::errc::invalid_argument);