aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/clangd/FS.cpp
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2018-10-20 15:30:37 +0000
committerSam McCall <sam.mccall@gmail.com>2018-10-20 15:30:37 +0000
commitc008af646620f6718384c2cd95f58a7311fe10fb (patch)
tree4961c6079af876f19462df09f9a0d0fa1176a824 /clang-tools-extra/clangd/FS.cpp
parent0c35aa114d34c4f8add2a532de3a797ef0c1b667 (diff)
[clangd] Namespace style cleanup in cpp files. NFC.
Standardize on the most common namespace setup in our *.cpp files: using namespace llvm; namespace clang { namespace clangd { void foo(StringRef) { ... } And remove redundant llvm:: qualifiers. (Except for cases like make_unique where this causes problems with std:: and ADL). This choice is pretty arbitrary, but some broad consistency is nice. This is going to conflict with everything. Sorry :-/ Squash the other configurations: A) using namespace llvm; using namespace clang; using namespace clangd; void clangd::foo(StringRef); This is in some of the older files. (It prevents accidentally defining a new function instead of one in the header file, for what that's worth). B) namespace clang { namespace clangd { void foo(llvm::StringRef) { ... } This is fine, but in practice the using directive often gets added over time. C) namespace clang { namespace clangd { using namespace llvm; // inside the namespace This was pretty common, but is a bit misleading: name lookup preferrs clang::clangd::foo > clang::foo > llvm:: foo (no matter where the using directive is). llvm-svn: 344850
Diffstat (limited to 'clang-tools-extra/clangd/FS.cpp')
-rw-r--r--clang-tools-extra/clangd/FS.cpp37
1 files changed, 17 insertions, 20 deletions
diff --git a/clang-tools-extra/clangd/FS.cpp b/clang-tools-extra/clangd/FS.cpp
index 5f5dd5c64a5f..e588e00bb777 100644
--- a/clang-tools-extra/clangd/FS.cpp
+++ b/clang-tools-extra/clangd/FS.cpp
@@ -12,16 +12,16 @@
#include "llvm/ADT/None.h"
#include "llvm/Support/Path.h"
+using namespace llvm;
namespace clang {
namespace clangd {
-PreambleFileStatusCache::PreambleFileStatusCache(llvm::StringRef MainFilePath)
+PreambleFileStatusCache::PreambleFileStatusCache(StringRef MainFilePath)
: MainFilePath(MainFilePath) {
- assert(llvm::sys::path::is_absolute(MainFilePath));
+ assert(sys::path::is_absolute(MainFilePath));
}
-void PreambleFileStatusCache::update(const llvm::vfs::FileSystem &FS,
- llvm::vfs::Status S) {
+void PreambleFileStatusCache::update(const vfs::FileSystem &FS, vfs::Status S) {
SmallString<32> PathStore(S.getName());
if (FS.makeAbsolute(PathStore))
return;
@@ -32,26 +32,24 @@ void PreambleFileStatusCache::update(const llvm::vfs::FileSystem &FS,
StatCache.insert({PathStore, std::move(S)});
}
-llvm::Optional<llvm::vfs::Status>
-PreambleFileStatusCache::lookup(llvm::StringRef File) const {
+Optional<vfs::Status> PreambleFileStatusCache::lookup(StringRef File) const {
auto I = StatCache.find(File);
if (I != StatCache.end())
return I->getValue();
- return llvm::None;
+ return None;
}
-IntrusiveRefCntPtr<llvm::vfs::FileSystem>
-PreambleFileStatusCache::getProducingFS(
- IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS) {
+IntrusiveRefCntPtr<vfs::FileSystem> PreambleFileStatusCache::getProducingFS(
+ IntrusiveRefCntPtr<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 llvm::vfs::ProxyFileSystem {
+ class CollectFS : public vfs::ProxyFileSystem {
public:
- CollectFS(IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS,
+ CollectFS(IntrusiveRefCntPtr<vfs::FileSystem> FS,
PreambleFileStatusCache &StatCache)
: ProxyFileSystem(std::move(FS)), StatCache(StatCache) {}
- llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
+ ErrorOr<std::unique_ptr<vfs::File>>
openFileForRead(const Twine &Path) override {
auto File = getUnderlyingFS().openFileForRead(Path);
if (!File || !*File)
@@ -66,7 +64,7 @@ PreambleFileStatusCache::getProducingFS(
return File;
}
- llvm::ErrorOr<llvm::vfs::Status> status(const Twine &Path) override {
+ ErrorOr<vfs::Status> status(const Twine &Path) override {
auto S = getUnderlyingFS().status(Path);
if (S)
StatCache.update(getUnderlyingFS(), *S);
@@ -79,16 +77,15 @@ PreambleFileStatusCache::getProducingFS(
return IntrusiveRefCntPtr<CollectFS>(new CollectFS(std::move(FS), *this));
}
-IntrusiveRefCntPtr<llvm::vfs::FileSystem>
-PreambleFileStatusCache::getConsumingFS(
- IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS) const {
- class CacheVFS : public llvm::vfs::ProxyFileSystem {
+IntrusiveRefCntPtr<vfs::FileSystem> PreambleFileStatusCache::getConsumingFS(
+ IntrusiveRefCntPtr<vfs::FileSystem> FS) const {
+ class CacheVFS : public vfs::ProxyFileSystem {
public:
- CacheVFS(IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS,
+ CacheVFS(IntrusiveRefCntPtr<vfs::FileSystem> FS,
const PreambleFileStatusCache &StatCache)
: ProxyFileSystem(std::move(FS)), StatCache(StatCache) {}
- llvm::ErrorOr<llvm::vfs::Status> status(const Twine &Path) override {
+ ErrorOr<vfs::Status> status(const Twine &Path) override {
if (auto S = StatCache.lookup(Path.str()))
return *S;
return getUnderlyingFS().status(Path);