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

30namespace FileMgr {

31

33

34}

35

36

37

44};

45

46

47

49public:

51

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

53

54

55

58 }

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

116namespace FileMgr {

117

118

119

121 using optional_none_tag = typename RefTy::optional_none_tag;

122 RefTy MaybeRef;

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

169

170public:

172

173 template <class... ArgTypes>

176

178 StorageImpl::operator=(Ref);

179 return *this;

180 }

181};

182

184 "OptionalDirectoryEntryRef must avoid size overhead");

185

186static_assert(std::is_trivially_copyable::value,

187 "OptionalDirectoryEntryRef should be trivially copyable");

188

189}

190}

191

192namespace llvm {

193

197 }

198

202 }

203

206};

207

208

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

212 clang::DirectoryEntryRef::dense_map_empty_tag());

213 }

214

217 clang::DirectoryEntryRef::dense_map_tombstone_tag());

218 }

219

222 }

223

226

228 return true;

229

230

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

232 return false;

233

234

235 return LHS == RHS;

236 }

237};

238

239}

240

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

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

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 &

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

OptionalStorage & operator=(clang::DirectoryEntryRef Ref)

OptionalStorage()=default

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

CustomizableOptional< DirectoryEntryRef > OptionalDirectoryEntryRef

Diagnostic wrappers for TextAPI types for error reporting.

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)