summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/FS.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2018-10-10 13:27:25 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2018-10-10 13:27:25 +0000
commitfc51490baf1d6ad5796d8cb8bb0792de13ce8fce (patch)
treebae0cfa9002258ffad07524d654245ed3b918cb1 /clang-tools-extra/clangd/FS.cpp
parentc616a7236c83994cacdbc13e37269bbc9598093d (diff)
downloadbcm5719-llvm-fc51490baf1d6ad5796d8cb8bb0792de13ce8fce.tar.gz
bcm5719-llvm-fc51490baf1d6ad5796d8cb8bb0792de13ce8fce.zip
Lift VFS from clang to llvm (NFC)
This patch moves the virtual file system form clang to llvm so it can be used by more projects. Concretely the patch: - Moves VirtualFileSystem.{h|cpp} from clang/Basic to llvm/Support. - Moves the corresponding unit test from clang to llvm. - Moves the vfs namespace from clang::vfs to llvm::vfs. - Formats the lines affected by this change, mostly this is the result of the added llvm namespace. RFC on the mailing list: http://lists.llvm.org/pipermail/llvm-dev/2018-October/126657.html Differential revision: https://reviews.llvm.org/D52783 llvm-svn: 344140
Diffstat (limited to 'clang-tools-extra/clangd/FS.cpp')
-rw-r--r--clang-tools-extra/clangd/FS.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/clang-tools-extra/clangd/FS.cpp b/clang-tools-extra/clangd/FS.cpp
index fa94b967214..5f5dd5c64a5 100644
--- a/clang-tools-extra/clangd/FS.cpp
+++ b/clang-tools-extra/clangd/FS.cpp
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
#include "FS.h"
-#include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Basic/LLVM.h"
#include "llvm/ADT/None.h"
#include "llvm/Support/Path.h"
@@ -20,7 +20,8 @@ PreambleFileStatusCache::PreambleFileStatusCache(llvm::StringRef MainFilePath)
assert(llvm::sys::path::is_absolute(MainFilePath));
}
-void PreambleFileStatusCache::update(const vfs::FileSystem &FS, vfs::Status S) {
+void PreambleFileStatusCache::update(const llvm::vfs::FileSystem &FS,
+ llvm::vfs::Status S) {
SmallString<32> PathStore(S.getName());
if (FS.makeAbsolute(PathStore))
return;
@@ -31,7 +32,7 @@ void PreambleFileStatusCache::update(const vfs::FileSystem &FS, vfs::Status S) {
StatCache.insert({PathStore, std::move(S)});
}
-llvm::Optional<vfs::Status>
+llvm::Optional<llvm::vfs::Status>
PreambleFileStatusCache::lookup(llvm::StringRef File) const {
auto I = StatCache.find(File);
if (I != StatCache.end())
@@ -39,17 +40,18 @@ PreambleFileStatusCache::lookup(llvm::StringRef File) const {
return llvm::None;
}
-IntrusiveRefCntPtr<vfs::FileSystem> PreambleFileStatusCache::getProducingFS(
- IntrusiveRefCntPtr<vfs::FileSystem> FS) {
+IntrusiveRefCntPtr<llvm::vfs::FileSystem>
+PreambleFileStatusCache::getProducingFS(
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS) {
// This invalidates old status in cache if files are re-`open()`ed or
// re-`stat()`ed in case file status has changed during preamble build.
- class CollectFS : public vfs::ProxyFileSystem {
+ class CollectFS : public llvm::vfs::ProxyFileSystem {
public:
- CollectFS(IntrusiveRefCntPtr<vfs::FileSystem> FS,
+ CollectFS(IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS,
PreambleFileStatusCache &StatCache)
: ProxyFileSystem(std::move(FS)), StatCache(StatCache) {}
- llvm::ErrorOr<std::unique_ptr<vfs::File>>
+ llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
openFileForRead(const Twine &Path) override {
auto File = getUnderlyingFS().openFileForRead(Path);
if (!File || !*File)
@@ -64,7 +66,7 @@ IntrusiveRefCntPtr<vfs::FileSystem> PreambleFileStatusCache::getProducingFS(
return File;
}
- llvm::ErrorOr<vfs::Status> status(const Twine &Path) override {
+ llvm::ErrorOr<llvm::vfs::Status> status(const Twine &Path) override {
auto S = getUnderlyingFS().status(Path);
if (S)
StatCache.update(getUnderlyingFS(), *S);
@@ -77,15 +79,16 @@ IntrusiveRefCntPtr<vfs::FileSystem> PreambleFileStatusCache::getProducingFS(
return IntrusiveRefCntPtr<CollectFS>(new CollectFS(std::move(FS), *this));
}
-IntrusiveRefCntPtr<vfs::FileSystem> PreambleFileStatusCache::getConsumingFS(
- IntrusiveRefCntPtr<vfs::FileSystem> FS) const {
- class CacheVFS : public vfs::ProxyFileSystem {
+IntrusiveRefCntPtr<llvm::vfs::FileSystem>
+PreambleFileStatusCache::getConsumingFS(
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS) const {
+ class CacheVFS : public llvm::vfs::ProxyFileSystem {
public:
- CacheVFS(IntrusiveRefCntPtr<vfs::FileSystem> FS,
+ CacheVFS(IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS,
const PreambleFileStatusCache &StatCache)
: ProxyFileSystem(std::move(FS)), StatCache(StatCache) {}
- llvm::ErrorOr<vfs::Status> status(const Twine &Path) override {
+ llvm::ErrorOr<llvm::vfs::Status> status(const Twine &Path) override {
if (auto S = StatCache.lookup(Path.str()))
return *S;
return getUnderlyingFS().status(Path);
OpenPOWER on IntegriCloud