14#ifndef LLVM_CLANG_BASIC_DIRECTORYENTRY_H
15#define LLVM_CLANG_BASIC_DIRECTORYENTRY_H
19#include "llvm/ADT/DenseMapInfo.h"
20#include "llvm/ADT/Hashing.h"
21#include "llvm/ADT/STLExtras.h"
22#include "llvm/ADT/StringMap.h"
23#include "llvm/ADT/StringRef.h"
24#include "llvm/Support/ErrorOr.h"
49 LLVM_DEPRECATED(
"Use DirectoryEntryRef::getName() instead.",
"")
50 StringRef
getName()
const {
return Name; }
59 StringRef
getName()
const {
return ME->getKey(); }
67 using MapEntry = llvm::StringMapEntry<llvm::ErrorOr<DirectoryEntry &>>;
98 struct optional_none_tag {};
102 bool hasOptionalValue()
const {
return ME; }
105 struct dense_map_empty_tag {};
106 struct dense_map_tombstone_tag {};
110 : ME(
llvm::DenseMapInfo<const
MapEntry *>::getEmptyKey()) {}
112 : ME(
llvm::DenseMapInfo<const
MapEntry *>::getTombstoneKey()) {}
113 bool isSpecialDenseMapKey()
const {
128 using optional_none_tag =
typename RefTy::optional_none_tag;
134 template <
class... ArgTypes>
136 : MaybeRef(
std::
forward<ArgTypes>(Args)...) {}
138 void reset() { MaybeRef = optional_none_tag(); }
140 bool has_value()
const {
return MaybeRef.hasOptionalValue(); }
152 return std::move(MaybeRef);
155 template <
class... Args>
void emplace(Args &&...args) {
156 MaybeRef = RefTy(std::forward<Args>(args)...);
167namespace optional_detail {
180 template <
class... ArgTypes>
185 StorageImpl::operator=(Ref);
191 "OptionalDirectoryEntryRef must avoid size overhead");
193static_assert(std::is_trivially_copyable<OptionalDirectoryEntryRef>::value,
194 "OptionalDirectoryEntryRef should be trivially copyable");
216template <>
struct DenseMapInfo<
clang::DirectoryEntryRef> {
219 clang::DirectoryEntryRef::dense_map_empty_tag());
224 clang::DirectoryEntryRef::dense_map_tombstone_tag());
238 if (LHS.isSpecialDenseMapKey() || RHS.isSpecialDenseMapKey())
311 return has_value() ? &(*this)->getDirEntry() :
nullptr;
315static_assert(std::is_trivially_copyable<
316 OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr>::value,
317 "OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr should be "
318 "trivially copyable");
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
constexpr bool has_value() const
CustomizableOptional & operator=(DirectoryEntryRef &&y)
A reference to a DirectoryEntry that includes the name of the directory as it was accessed by the Fil...
StringRef getName() const
DirectoryEntryRef(const MapEntry &ME)
llvm::StringMapEntry< llvm::ErrorOr< DirectoryEntry & > > MapEntry
DirectoryEntryRef()=delete
friend llvm::hash_code hash_value(DirectoryEntryRef Ref)
Hash code is based on the DirectoryEntry, not the specific named reference.
bool isSameRef(DirectoryEntryRef RHS) const
Check if RHS referenced the file in exactly the same way.
const MapEntry & getMapEntry() const
const DirectoryEntry & getDirEntry() const
Cached information about one directory (either on disk or in the virtual file system).
StringRef getName() const
friend class FileEntryTestHelper
Implements support for file system lookup, file system caching, and directory search management.
Customized storage for refs derived from map entires in FileManager, using the private optional_none_...
MapEntryOptionalStorage(std::in_place_t, ArgTypes &&...Args)
MapEntryOptionalStorage()
void emplace(Args &&...args)
MapEntryOptionalStorage & operator=(RefTy Ref)
RefTy const & value() const &
Wrapper around OptionalDirectoryEntryRef that degrades to 'const DirectoryEntry*',...
OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr(std::nullopt_t)
OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr & operator=(const OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr &)=default
OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr & operator=(std::nullopt_t)
OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr(DirectoryEntryRef Ref)
OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr()=default
OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr(OptionalDirectoryEntryRef MaybeRef)
OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr(OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr &&)=default
OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr & operator=(OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr &&)=default
OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr & operator=(OptionalDirectoryEntryRef MaybeRef)
OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr(const OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr &)=default
OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr & operator=(DirectoryEntryRef Ref)
OptionalStorage(std::in_place_t, ArgTypes &&...Args)
OptionalStorage & operator=(clang::DirectoryEntryRef Ref)
OptionalStorage()=default
CustomizableOptional< DirectoryEntryRef > OptionalDirectoryEntryRef
YAML serialization mapping.
hash_code hash_value(const clang::tooling::dependencies::ModuleID &ID)
static clang::DirectoryEntryRef getTombstoneKey()
static clang::DirectoryEntryRef getEmptyKey()
static unsigned getHashValue(clang::DirectoryEntryRef Val)
static bool isEqual(clang::DirectoryEntryRef LHS, clang::DirectoryEntryRef RHS)
static clang::DirectoryEntryRef getFromVoidPointer(void *Ptr)
static void * getAsVoidPointer(clang::DirectoryEntryRef Dir)