From 05d56ef2c5241802b9a371fcce19759fd6ee789b Mon Sep 17 00:00:00 2001 From: Ben Langmuir Date: Wed, 19 Feb 2014 16:36:49 +0000 Subject: [PATCH] Reduce verbosity in the virtual file system using LLVM.h No functional change git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201696 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/FileManager.h | 2 +- include/clang/Basic/VirtualFileSystem.h | 53 ++++++++++++------------- lib/Basic/VirtualFileSystem.cpp | 14 +++---- 3 files changed, 33 insertions(+), 36 deletions(-) diff --git a/include/clang/Basic/FileManager.h b/include/clang/Basic/FileManager.h index a4af280379..c2d78eed52 100644 --- a/include/clang/Basic/FileManager.h +++ b/include/clang/Basic/FileManager.h @@ -183,7 +183,7 @@ class FileManager : public RefCountedBase { public: FileManager(const FileSystemOptions &FileSystemOpts, - llvm::IntrusiveRefCntPtr FS = 0); + IntrusiveRefCntPtr FS = 0); ~FileManager(); /// \brief Installs the provided FileSystemStatCache object within diff --git a/include/clang/Basic/VirtualFileSystem.h b/include/clang/Basic/VirtualFileSystem.h index 6dd9bf73b3..694c6ddec8 100644 --- a/include/clang/Basic/VirtualFileSystem.h +++ b/include/clang/Basic/VirtualFileSystem.h @@ -13,12 +13,12 @@ #ifndef LLVM_CLANG_BASIC_VIRTUAL_FILE_SYSTEM_H #define LLVM_CLANG_BASIC_VIRTUAL_FILE_SYSTEM_H +#include "clang/Basic/LLVM.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/ErrorOr.h" namespace llvm { -template class OwningPtr; class MemoryBuffer; } @@ -40,21 +40,21 @@ class Status { public: Status() : Type(llvm::sys::fs::file_type::status_error) {} Status(const llvm::sys::fs::file_status &Status); - Status(llvm::StringRef Name, llvm::StringRef RealName, - llvm::sys::fs::UniqueID UID, llvm::sys::TimeValue MTime, - uint32_t User, uint32_t Group, uint64_t Size, - llvm::sys::fs::file_type Type, llvm::sys::fs::perms Perms); + Status(StringRef Name, StringRef RealName, llvm::sys::fs::UniqueID UID, + llvm::sys::TimeValue MTime, uint32_t User, uint32_t Group, + uint64_t Size, llvm::sys::fs::file_type Type, + llvm::sys::fs::perms Perms); /// \brief Returns the name this status was looked up by. - llvm::StringRef getName() const { return Name; } + StringRef getName() const { return Name; } /// \brief Returns the name to use outside the compiler. /// /// For example, in diagnostics or debug info we should use this name. - llvm::StringRef getExternalName() const { return ExternalName; } + StringRef getExternalName() const { return ExternalName; } - void setName(llvm::StringRef N) { Name = N; } - void setExternalName(llvm::StringRef N) { ExternalName = N; } + void setName(StringRef N) { Name = N; } + void setExternalName(StringRef N) { ExternalName = N; } /// @name Status interface from llvm::sys::fs /// @{ @@ -91,36 +91,36 @@ public: /// \brief Get the status of the file. virtual llvm::ErrorOr status() = 0; /// \brief Get the contents of the file as a \p MemoryBuffer. - virtual llvm::error_code - getBuffer(const llvm::Twine &Name, - llvm::OwningPtr &Result, int64_t FileSize = -1, - bool RequiresNullTerminator = true) = 0; + virtual llvm::error_code getBuffer(const Twine &Name, + OwningPtr &Result, + int64_t FileSize = -1, + bool RequiresNullTerminator = true) = 0; /// \brief Closes the file. virtual llvm::error_code close() = 0; }; /// \brief The virtual file system interface. -class FileSystem : public llvm::RefCountedBase { +class FileSystem : public RefCountedBase { public: virtual ~FileSystem(); /// \brief Get the status of the entry at \p Path, if one exists. - virtual llvm::ErrorOr status(const llvm::Twine &Path) = 0; + virtual llvm::ErrorOr status(const Twine &Path) = 0; /// \brief Get a \p File object for the file at \p Path, if one exists. - virtual llvm::error_code openFileForRead(const llvm::Twine &Path, - llvm::OwningPtr &Result) = 0; + virtual llvm::error_code openFileForRead(const Twine &Path, + OwningPtr &Result) = 0; /// This is a convenience method that opens a file, gets its content and then /// closes the file. - llvm::error_code getBufferForFile(const llvm::Twine &Name, - llvm::OwningPtr &Result, + llvm::error_code getBufferForFile(const Twine &Name, + OwningPtr &Result, int64_t FileSize = -1, bool RequiresNullTerminator = true); }; /// \brief Gets an \p vfs::FileSystem for the 'real' file system, as seen by /// the operating system. -llvm::IntrusiveRefCntPtr getRealFileSystem(); +IntrusiveRefCntPtr getRealFileSystem(); /// \brief A file system that allows overlaying one \p AbstractFileSystem on top /// of another. @@ -133,8 +133,7 @@ llvm::IntrusiveRefCntPtr getRealFileSystem(); /// that exists in more than one file system, the file in the top-most file /// system overrides the other(s). class OverlayFileSystem : public FileSystem { - typedef llvm::SmallVector, 1> - FileSystemList; + typedef SmallVector, 1> FileSystemList; typedef FileSystemList::reverse_iterator iterator; /// \brief The stack of file systems, implemented as a list in order of @@ -149,13 +148,13 @@ class OverlayFileSystem : public FileSystem { iterator overlays_end() { return FSList.rend(); } public: - OverlayFileSystem(llvm::IntrusiveRefCntPtr Base); + OverlayFileSystem(IntrusiveRefCntPtr Base); /// \brief Pushes a file system on top of the stack. - void pushOverlay(llvm::IntrusiveRefCntPtr FS); + void pushOverlay(IntrusiveRefCntPtr FS); - llvm::ErrorOr status(const llvm::Twine &Path) LLVM_OVERRIDE; - llvm::error_code openFileForRead(const llvm::Twine &Path, - llvm::OwningPtr &Result) LLVM_OVERRIDE; + llvm::ErrorOr status(const Twine &Path) LLVM_OVERRIDE; + llvm::error_code openFileForRead(const Twine &Path, + OwningPtr &Result) LLVM_OVERRIDE; }; } // end namespace vfs diff --git a/lib/Basic/VirtualFileSystem.cpp b/lib/Basic/VirtualFileSystem.cpp index 6379cd5ef2..3fedf27f97 100644 --- a/lib/Basic/VirtualFileSystem.cpp +++ b/lib/Basic/VirtualFileSystem.cpp @@ -28,10 +28,9 @@ Status::Status(const file_status &Status) User(Status.getUser()), Group(Status.getGroup()), Size(Status.getSize()), Type(Status.type()), Perms(Status.permissions()) {} -Status::Status(StringRef Name, StringRef ExternalName, - UniqueID UID, sys::TimeValue MTime, - uint32_t User, uint32_t Group, uint64_t Size, - file_type Type, perms Perms) +Status::Status(StringRef Name, StringRef ExternalName, UniqueID UID, + sys::TimeValue MTime, uint32_t User, uint32_t Group, + uint64_t Size, file_type Type, perms Perms) : Name(Name), ExternalName(ExternalName), UID(UID), MTime(MTime), User(User), Group(Group), Size(Size), Type(Type), Perms(Perms) {} @@ -133,8 +132,8 @@ error_code RealFile::close() { class RealFileSystem : public FileSystem { public: ErrorOr status(const Twine &Path) LLVM_OVERRIDE; - error_code openFileForRead(const Twine &Path, OwningPtr &Result) - LLVM_OVERRIDE; + error_code openFileForRead(const Twine &Path, + OwningPtr &Result) LLVM_OVERRIDE; }; ErrorOr RealFileSystem::status(const Twine &Path) { @@ -164,8 +163,7 @@ IntrusiveRefCntPtr vfs::getRealFileSystem() { //===-----------------------------------------------------------------------===/ // OverlayFileSystem implementation //===-----------------------------------------------------------------------===/ -OverlayFileSystem::OverlayFileSystem( - IntrusiveRefCntPtr BaseFS) { +OverlayFileSystem::OverlayFileSystem(IntrusiveRefCntPtr BaseFS) { pushOverlay(BaseFS); } -- 2.40.0