14#ifndef LLVM_CLANG_BASIC_FILEENTRY_H
15#define LLVM_CLANG_BASIC_FILEENTRY_H
20#include "llvm/ADT/DenseMapInfo.h"
21#include "llvm/ADT/Hashing.h"
22#include "llvm/ADT/PointerUnion.h"
23#include "llvm/ADT/StringMap.h"
24#include "llvm/ADT/StringRef.h"
25#include "llvm/Support/ErrorOr.h"
26#include "llvm/Support/FileSystem/UniqueID.h"
76 inline void updateFileEntryBufferSize(
unsigned BufferSize);
80 inline off_t getSize()
const;
81 inline unsigned getUID()
const;
82 inline const llvm::sys::fs::UniqueID &getUniqueID()
const;
83 inline time_t getModificationTime()
const;
84 inline bool isNamedPipe()
const;
85 inline bool isDeviceFile()
const;
86 inline void closeFile()
const;
100 return !(LHS == RHS);
103 return !(LHS == RHS);
106 return !(LHS == RHS);
118 using MapEntry = llvm::StringMapEntry<llvm::ErrorOr<MapValue>>;
127 llvm::PointerUnion<FileEntry *, const MapEntry *>
V;
161 assert(ME.second &&
"Expected payload");
162 assert(ME.second->V &&
"Expected non-null");
179 struct optional_none_tag {};
182 FileEntryRef(optional_none_tag) : ME(
nullptr) {}
183 bool hasOptionalValue()
const {
return ME; }
190static_assert(
sizeof(FileEntryRef) ==
sizeof(
const FileEntry *),
191 "FileEntryRef must avoid size overhead");
193static_assert(std::is_trivially_copyable<FileEntryRef>::value,
194 "FileEntryRef must be trivially copyable");
209 using StorageImpl::StorageImpl;
218 "OptionalFileEntryRef must avoid size overhead");
220static_assert(std::is_trivially_copyable<OptionalFileEntryRef>::value,
221 "OptionalFileEntryRef should be trivially copyable");
229template <>
struct DenseMapInfo<
clang::FileEntryRef> {
262 return !(LHS == RHS);
265 return !(LHS == RHS);
277 FileEntry(
const FileEntry &) =
delete;
278 FileEntry &operator=(
const FileEntry &) =
delete;
280 std::string RealPathName;
284 llvm::sys::fs::UniqueID UniqueID;
286 bool IsNamedPipe =
false;
287 bool IsDeviceFile =
false;
290 mutable std::unique_ptr<llvm::vfs::File> File;
293 std::unique_ptr<llvm::MemoryBuffer> Content;
301 void setSize(off_t NewSize) { Size = NewSize; }
303 const llvm::sys::fs::UniqueID &
getUniqueID()
const {
return UniqueID; }
Defines interfaces for clang::DirectoryEntry and clang::DirectoryEntryRef.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
A reference to a DirectoryEntry that includes the name of the directory as it was accessed by the Fil...
Cached information about one directory (either on disk or in the virtual file system).
A reference to a FileEntry that includes the name of the file as it was accessed by the FileManager's...
friend bool operator==(const FileEntry *LHS, const FileEntryRef &RHS)
bool isDeviceFile() const
friend llvm::hash_code hash_value(FileEntryRef Ref)
Hash code is based on the FileEntry, not the specific named reference, just like operator==.
const MapEntry & getBaseMapEntry() const
Retrieve the base MapEntry after redirects.
const FileEntry & getFileEntry() const
bool isSameRef(const FileEntryRef &RHS) const
Check if RHS referenced the file in exactly the same way.
const clang::FileEntryRef::MapEntry & getMapEntry() const
Expose the underlying MapEntry to simplify packing in a PointerIntPair or PointerUnion and allow cons...
time_t getModificationTime() const
friend bool operator!=(const FileEntryRef &LHS, const FileEntryRef &RHS)
llvm::StringMapEntry< llvm::ErrorOr< MapValue > > MapEntry
Type used in the StringMap.
void updateFileEntryBufferSize(unsigned BufferSize)
FileEntryRef(const MapEntry &ME)
friend bool operator!=(const FileEntry *LHS, const FileEntryRef &RHS)
StringRef getName() const
The name of this FileEntry.
friend bool operator!=(const FileEntryRef &LHS, const FileEntry *RHS)
const llvm::sys::fs::UniqueID & getUniqueID() const
StringRef getNameAsRequested() const
The name of this FileEntry, as originally requested without applying any remappings for VFS 'use-exte...
DirectoryEntryRef getDir() const
friend bool operator==(const FileEntryRef &LHS, const FileEntryRef &RHS)
Check if the underlying FileEntry is the same, intentially ignoring whether the file was referenced w...
friend bool operator==(const FileEntryRef &LHS, const FileEntry *RHS)
Cached information about one file (either on disk or in the virtual file system).
bool isDeviceFile() const
const DirectoryEntry * getDir() const
Return the directory the file lives in.
StringRef tryGetRealPathName() const
friend class FileEntryTestHelper
void setSize(off_t NewSize)
time_t getModificationTime() const
bool isNamedPipe() const
Check whether the file is a named pipe (and thus can't be opened by the native FileManager methods).
const llvm::sys::fs::UniqueID & getUniqueID() const
Customized storage for refs derived from map entires in FileManager, using the private optional_none_...
MapEntryOptionalStorage & operator=(clang::FileEntryRef Ref)
OptionalStorage & operator=(clang::FileEntryRef Ref)
The JSON file list parser is used to communicate input to InstallAPI.
CustomizableOptional< FileEntryRef > OptionalFileEntryRef
bool operator==(const CallGraphNode::CallRecord &LHS, const CallGraphNode::CallRecord &RHS)
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
bool operator!=(CanQual< T > x, CanQual< U > y)
U cast(CodeGen::Address addr)
Diagnostic wrappers for TextAPI types for error reporting.
hash_code hash_value(const clang::dependencies::ModuleID &ID)
DirectoryEntryRef Dir
Directory the file was found in.
MapValue(FileEntry &FE, DirectoryEntryRef Dir)
MapValue(MapEntry &ME, DirectoryEntryRef Dir)
llvm::PointerUnion< FileEntry *, const MapEntry * > V
The pointer at another MapEntry is used when the FileManager should silently forward from one name to...
static unsigned getHashValue(const clang::FileEntry *Val)
Support for finding const FileEntry * in a DenseMap<FileEntryRef, T>.
static unsigned getHashValue(clang::FileEntryRef Val)
static bool isEqual(const clang::FileEntry *LHS, clang::FileEntryRef RHS)
static bool isEqual(clang::FileEntryRef LHS, clang::FileEntryRef RHS)