clang: include/clang/Basic/DirectoryEntry.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_CLANG_BASIC_DIRECTORYENTRY_H

15#define LLVM_CLANG_BASIC_DIRECTORYENTRY_H

16

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"

25

26#include

27#include

28

35

36

37

38class DirectoryEntry {

39 DirectoryEntry() = default;

40 DirectoryEntry(const DirectoryEntry &) = delete;

41 DirectoryEntry &operator=(const DirectoryEntry &) = delete;

44};

45

46

47

49public:

51

52 StringRef getName() const { return ME->getKey(); }

53

54

55

59

60 using MapEntry = llvm::StringMapEntry<llvm::ErrorOr<DirectoryEntry &>>;

61

63

64

66

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

88

89private:

91 struct optional_none_tag {};

92

93

95 bool hasOptionalValue() const { return ME; }

96

98 struct dense_map_empty_tag {};

99 struct dense_map_tombstone_tag {};

100

101

103 : ME(llvm::DenseMapInfo<const MapEntry *>::getEmptyKey()) {}

105 : ME(llvm::DenseMapInfo<const MapEntry *>::getTombstoneKey()) {}

106 bool isSpecialDenseMapKey() const {

109 }

110

112};

113

115

117

118

119

121 using optional_none_tag = typename RefTy::optional_none_tag;

122 RefTy MaybeRef = optional_none_tag();

123

124public:

126

127 template <class... ArgTypes>

129 : MaybeRef(std::forward(Args)...) {}

130

131 void reset() { MaybeRef = optional_none_tag(); }

132

133 bool has_value() const { return MaybeRef.hasOptionalValue(); }

134

137 return MaybeRef;

138 }

139 RefTy const &value() const & {

141 return MaybeRef;

142 }

145 return std::move(MaybeRef);

146 }

147

148 template <class... Args> void emplace(Args &&...args) {

149 MaybeRef = RefTy(std::forward(args)...);

150 }

151

153 MaybeRef = Ref;

154 return *this;

155 }

156};

157

158}

159

160namespace optional_detail {

161

162

163

164template <>

167 using StorageImpl =

169

170public:

171 using StorageImpl::StorageImpl;

172

177};

178

180 "OptionalDirectoryEntryRef must avoid size overhead");

181

182static_assert(std::is_trivially_copyable::value,

183 "OptionalDirectoryEntryRef should be trivially copyable");

184

185}

186}

187

188namespace llvm {

189

203

204

205template <> struct DenseMapInfo<clang::DirectoryEntryRef> {

208 clang::DirectoryEntryRef::dense_map_empty_tag());

209 }

210

213 clang::DirectoryEntryRef::dense_map_tombstone_tag());

214 }

215

219

222

224 return true;

225

226

227 if (LHS.isSpecialDenseMapKey() || RHS.isSpecialDenseMapKey())

228 return false;

229

230

231 return LHS == RHS;

232 }

233};

234

235}

236

237#endif

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...

Definition DirectoryEntry.h:48

StringRef getName() const

Definition DirectoryEntry.h:52

DirectoryEntryRef(const MapEntry &ME)

Definition DirectoryEntry.h:68

DirectoryEntryRef()=delete

friend llvm::hash_code hash_value(DirectoryEntryRef Ref)

Hash code is based on the DirectoryEntry, not the specific named reference.

Definition DirectoryEntry.h:56

bool isSameRef(DirectoryEntryRef RHS) const

Check if RHS referenced the file in exactly the same way.

Definition DirectoryEntry.h:65

const MapEntry & getMapEntry() const

Definition DirectoryEntry.h:62

llvm::StringMapEntry< llvm::ErrorOr< DirectoryEntry & > > MapEntry

Definition DirectoryEntry.h:60

const DirectoryEntry & getDirEntry() const

Definition DirectoryEntry.h:50

Cached information about one directory (either on disk or in the virtual file system).

Definition DirectoryEntry.h:38

friend class FileEntryTestHelper

Definition DirectoryEntry.h:43

friend class FileManager

Definition DirectoryEntry.h:42

Customized storage for refs derived from map entires in FileManager, using the private optional_none_...

Definition DirectoryEntry.h:120

MapEntryOptionalStorage()=default

MapEntryOptionalStorage(std::in_place_t, ArgTypes &&...Args)

Definition DirectoryEntry.h:128

RefTy & value() &

Definition DirectoryEntry.h:135

bool has_value() const

Definition DirectoryEntry.h:133

void emplace(Args &&...args)

Definition DirectoryEntry.h:148

RefTy && value() &&

Definition DirectoryEntry.h:143

MapEntryOptionalStorage & operator=(RefTy Ref)

Definition DirectoryEntry.h:152

RefTy const & value() const &

Definition DirectoryEntry.h:139

void reset()

Definition DirectoryEntry.h:131

OptionalStorage & operator=(clang::DirectoryEntryRef Ref)

Definition DirectoryEntry.h:173

Definition DirectoryEntry.h:30

The JSON file list parser is used to communicate input to InstallAPI.

nullptr

This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...

CustomizableOptional< DirectoryEntryRef > OptionalDirectoryEntryRef

Definition DirectoryEntry.h:114

Diagnostic wrappers for TextAPI types for error reporting.

hash_code hash_value(const clang::dependencies::ModuleID &ID)

static clang::DirectoryEntryRef getTombstoneKey()

Definition DirectoryEntry.h:211

static clang::DirectoryEntryRef getEmptyKey()

Definition DirectoryEntry.h:206

static unsigned getHashValue(clang::DirectoryEntryRef Val)

Definition DirectoryEntry.h:216

static bool isEqual(clang::DirectoryEntryRef LHS, clang::DirectoryEntryRef RHS)

Definition DirectoryEntry.h:220

static constexpr int NumLowBitsAvailable

Definition DirectoryEntry.h:200

static clang::DirectoryEntryRef getFromVoidPointer(void *Ptr)

Definition DirectoryEntry.h:195

static void * getAsVoidPointer(clang::DirectoryEntryRef Dir)

Definition DirectoryEntry.h:191