diff options
author | Ben Langmuir <blangmuir@apple.com> | 2014-02-27 19:14:03 +0000 |
---|---|---|
committer | Ben Langmuir <blangmuir@apple.com> | 2014-02-27 19:14:03 +0000 |
commit | 1f3d645a46e7c3f34769e6b882f3be52d6816d95 (patch) | |
tree | 3be29edb099c7491e861d87b916119235e104622 /include/clang/Basic/FileManager.h | |
parent | 8bb3054559fa34de5a8324b3d78431f9602e6797 (diff) | |
download | clang-1f3d645a46e7c3f34769e6b882f3be52d6816d95.tar.gz |
Remove constructors from FileEntry that prevent owning resources
This cleans up some constructors that would not be safe once FileEntry
owns the storage for its name. These were already suspect, since they
wouldn't work if the FileEntry had an open file descriptor. The only
user for these constructors was in UniqueFileContainer, which wasn't a
very useful abstraction anyway. So it and UniqueDirContainer have been
replaced with std::map<UniqueID, *>.
This change should not affect anything outside the FileManager.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202420 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/FileManager.h')
-rw-r--r-- | include/clang/Basic/FileManager.h | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/include/clang/Basic/FileManager.h b/include/clang/Basic/FileManager.h index bd85318e2f..616f9846a2 100644 --- a/include/clang/Basic/FileManager.h +++ b/include/clang/Basic/FileManager.h @@ -27,6 +27,7 @@ #include "llvm/Support/Allocator.h" // FIXME: Enhance libsystem to support inode and other fields in stat. #include <sys/types.h> +#include <map> #ifdef _MSC_VER typedef unsigned short mode_t; @@ -76,27 +77,15 @@ class FileEntry { File.reset(0); // rely on destructor to close File } + FileEntry(const FileEntry &) LLVM_DELETED_FUNCTION; + void operator=(const FileEntry &) LLVM_DELETED_FUNCTION; + public: - FileEntry(llvm::sys::fs::UniqueID UniqueID, bool IsNamedPipe, bool InPCH) - : Name(0), UniqueID(UniqueID), IsNamedPipe(IsNamedPipe), InPCH(InPCH), - IsValid(false) - {} - // Add a default constructor for use with llvm::StringMap FileEntry() : Name(0), UniqueID(0, 0), IsNamedPipe(false), InPCH(false), IsValid(false) {} - FileEntry(const FileEntry &FE) { - memcpy(this, &FE, sizeof(FE)); - assert(!File && "Cannot copy a file-owning FileEntry"); - } - - void operator=(const FileEntry &FE) { - memcpy(this, &FE, sizeof(FE)); - assert(!File && "Cannot assign a file-owning FileEntry"); - } - const char *getName() const { return Name; } bool isValid() const { return IsValid; } off_t getSize() const { return Size; } @@ -128,14 +117,11 @@ class FileManager : public RefCountedBase<FileManager> { IntrusiveRefCntPtr<vfs::FileSystem> FS; FileSystemOptions FileSystemOpts; - class UniqueDirContainer; - class UniqueFileContainer; - /// \brief Cache for existing real directories. - UniqueDirContainer &UniqueRealDirs; + std::map<llvm::sys::fs::UniqueID, DirectoryEntry> UniqueRealDirs; /// \brief Cache for existing real files. - UniqueFileContainer &UniqueRealFiles; + std::map<llvm::sys::fs::UniqueID, FileEntry> UniqueRealFiles; /// \brief The virtual directories that we have allocated. /// |