diff options
author | Jordan Rupprecht <rupprecht@google.com> | 2019-01-18 19:46:00 +0000 |
---|---|---|
committer | Jordan Rupprecht <rupprecht@google.com> | 2019-01-18 19:46:00 +0000 |
commit | 5026a9a16d10a2edf09be54c7225f49b5789c69e (patch) | |
tree | 85c1e1c98d2a81ed687b44f5dd2c917176506ae8 /clangd/FS.cpp | |
parent | c0c923fb4d65ab16332fc84188b46508de0c35af (diff) | |
parent | 53b849a7ec90500d4c5970f3624c9a5321aacb16 (diff) |
Creating branches/google/stable and tags/google/stable/2019-01-18 from r351319
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/branches/google/stable@351578 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clangd/FS.cpp')
-rw-r--r-- | clangd/FS.cpp | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/clangd/FS.cpp b/clangd/FS.cpp index e588e00b..5d690c86 100644 --- a/clangd/FS.cpp +++ b/clangd/FS.cpp @@ -12,17 +12,17 @@ #include "llvm/ADT/None.h" #include "llvm/Support/Path.h" -using namespace llvm; namespace clang { namespace clangd { -PreambleFileStatusCache::PreambleFileStatusCache(StringRef MainFilePath) +PreambleFileStatusCache::PreambleFileStatusCache(llvm::StringRef MainFilePath) : MainFilePath(MainFilePath) { - assert(sys::path::is_absolute(MainFilePath)); + assert(llvm::sys::path::is_absolute(MainFilePath)); } -void PreambleFileStatusCache::update(const vfs::FileSystem &FS, vfs::Status S) { - SmallString<32> PathStore(S.getName()); +void PreambleFileStatusCache::update(const llvm::vfs::FileSystem &FS, + llvm::vfs::Status S) { + llvm::SmallString<32> PathStore(S.getName()); if (FS.makeAbsolute(PathStore)) return; // Do not cache status for the main file. @@ -32,25 +32,27 @@ void PreambleFileStatusCache::update(const vfs::FileSystem &FS, vfs::Status S) { StatCache.insert({PathStore, std::move(S)}); } -Optional<vfs::Status> PreambleFileStatusCache::lookup(StringRef File) const { +llvm::Optional<llvm::vfs::Status> +PreambleFileStatusCache::lookup(llvm::StringRef File) const { auto I = StatCache.find(File); if (I != StatCache.end()) return I->getValue(); return None; } -IntrusiveRefCntPtr<vfs::FileSystem> PreambleFileStatusCache::getProducingFS( - IntrusiveRefCntPtr<vfs::FileSystem> FS) { +llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> +PreambleFileStatusCache::getProducingFS( + llvm::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(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS, PreambleFileStatusCache &StatCache) : ProxyFileSystem(std::move(FS)), StatCache(StatCache) {} - ErrorOr<std::unique_ptr<vfs::File>> - openFileForRead(const Twine &Path) override { + llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>> + openFileForRead(const llvm::Twine &Path) override { auto File = getUnderlyingFS().openFileForRead(Path); if (!File || !*File) return File; @@ -64,7 +66,7 @@ IntrusiveRefCntPtr<vfs::FileSystem> PreambleFileStatusCache::getProducingFS( return File; } - ErrorOr<vfs::Status> status(const Twine &Path) override { + llvm::ErrorOr<llvm::vfs::Status> status(const llvm::Twine &Path) override { auto S = getUnderlyingFS().status(Path); if (S) StatCache.update(getUnderlyingFS(), *S); @@ -74,18 +76,20 @@ IntrusiveRefCntPtr<vfs::FileSystem> PreambleFileStatusCache::getProducingFS( private: PreambleFileStatusCache &StatCache; }; - return IntrusiveRefCntPtr<CollectFS>(new CollectFS(std::move(FS), *this)); + return llvm::IntrusiveRefCntPtr<CollectFS>( + new CollectFS(std::move(FS), *this)); } -IntrusiveRefCntPtr<vfs::FileSystem> PreambleFileStatusCache::getConsumingFS( - IntrusiveRefCntPtr<vfs::FileSystem> FS) const { - class CacheVFS : public vfs::ProxyFileSystem { +llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> +PreambleFileStatusCache::getConsumingFS( + llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS) const { + class CacheVFS : public llvm::vfs::ProxyFileSystem { public: - CacheVFS(IntrusiveRefCntPtr<vfs::FileSystem> FS, + CacheVFS(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS, const PreambleFileStatusCache &StatCache) : ProxyFileSystem(std::move(FS)), StatCache(StatCache) {} - ErrorOr<vfs::Status> status(const Twine &Path) override { + llvm::ErrorOr<llvm::vfs::Status> status(const llvm::Twine &Path) override { if (auto S = StatCache.lookup(Path.str())) return *S; return getUnderlyingFS().status(Path); @@ -94,7 +98,7 @@ IntrusiveRefCntPtr<vfs::FileSystem> PreambleFileStatusCache::getConsumingFS( private: const PreambleFileStatusCache &StatCache; }; - return IntrusiveRefCntPtr<CacheVFS>(new CacheVFS(std::move(FS), *this)); + return llvm::IntrusiveRefCntPtr<CacheVFS>(new CacheVFS(std::move(FS), *this)); } } // namespace clangd |