#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 <typename T> class OwningPtr;
class MemoryBuffer;
}
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
/// @{
/// \brief Get the status of the file.
virtual llvm::ErrorOr<Status> status() = 0;
/// \brief Get the contents of the file as a \p MemoryBuffer.
- virtual llvm::error_code
- getBuffer(const llvm::Twine &Name,
- llvm::OwningPtr<llvm::MemoryBuffer> &Result, int64_t FileSize = -1,
- bool RequiresNullTerminator = true) = 0;
+ virtual llvm::error_code getBuffer(const Twine &Name,
+ OwningPtr<llvm::MemoryBuffer> &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<FileSystem> {
+class FileSystem : public RefCountedBase<FileSystem> {
public:
virtual ~FileSystem();
/// \brief Get the status of the entry at \p Path, if one exists.
- virtual llvm::ErrorOr<Status> status(const llvm::Twine &Path) = 0;
+ virtual llvm::ErrorOr<Status> 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<File> &Result) = 0;
+ virtual llvm::error_code openFileForRead(const Twine &Path,
+ OwningPtr<File> &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<llvm::MemoryBuffer> &Result,
+ llvm::error_code getBufferForFile(const Twine &Name,
+ OwningPtr<llvm::MemoryBuffer> &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<FileSystem> getRealFileSystem();
+IntrusiveRefCntPtr<FileSystem> getRealFileSystem();
/// \brief A file system that allows overlaying one \p AbstractFileSystem on top
/// of another.
/// 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<llvm::IntrusiveRefCntPtr<FileSystem>, 1>
- FileSystemList;
+ typedef SmallVector<IntrusiveRefCntPtr<FileSystem>, 1> FileSystemList;
typedef FileSystemList::reverse_iterator iterator;
/// \brief The stack of file systems, implemented as a list in order of
iterator overlays_end() { return FSList.rend(); }
public:
- OverlayFileSystem(llvm::IntrusiveRefCntPtr<FileSystem> Base);
+ OverlayFileSystem(IntrusiveRefCntPtr<FileSystem> Base);
/// \brief Pushes a file system on top of the stack.
- void pushOverlay(llvm::IntrusiveRefCntPtr<FileSystem> FS);
+ void pushOverlay(IntrusiveRefCntPtr<FileSystem> FS);
- llvm::ErrorOr<Status> status(const llvm::Twine &Path) LLVM_OVERRIDE;
- llvm::error_code openFileForRead(const llvm::Twine &Path,
- llvm::OwningPtr<File> &Result) LLVM_OVERRIDE;
+ llvm::ErrorOr<Status> status(const Twine &Path) LLVM_OVERRIDE;
+ llvm::error_code openFileForRead(const Twine &Path,
+ OwningPtr<File> &Result) LLVM_OVERRIDE;
};
} // end namespace vfs
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) {}
class RealFileSystem : public FileSystem {
public:
ErrorOr<Status> status(const Twine &Path) LLVM_OVERRIDE;
- error_code openFileForRead(const Twine &Path, OwningPtr<File> &Result)
- LLVM_OVERRIDE;
+ error_code openFileForRead(const Twine &Path,
+ OwningPtr<File> &Result) LLVM_OVERRIDE;
};
ErrorOr<Status> RealFileSystem::status(const Twine &Path) {
//===-----------------------------------------------------------------------===/
// OverlayFileSystem implementation
//===-----------------------------------------------------------------------===/
-OverlayFileSystem::OverlayFileSystem(
- IntrusiveRefCntPtr<FileSystem> BaseFS) {
+OverlayFileSystem::OverlayFileSystem(IntrusiveRefCntPtr<FileSystem> BaseFS) {
pushOverlay(BaseFS);
}