clang: include/clang/Serialization/ModuleManager.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_CLANG_SERIALIZATION_MODULEMANAGER_H

15#define LLVM_CLANG_SERIALIZATION_MODULEMANAGER_H

16

20#include "llvm/ADT/DenseMap.h"

21#include "llvm/ADT/IntrusiveRefCntPtr.h"

22#include "llvm/ADT/STLExtras.h"

23#include "llvm/ADT/SmallPtrSet.h"

24#include "llvm/ADT/SmallVector.h"

25#include "llvm/ADT/StringRef.h"

26#include "llvm/ADT/iterator.h"

27#include "llvm/ADT/iterator_range.h"

28#include

29#include

30#include

31#include

32#include

33

35

36class FileEntry;

37class FileManager;

38class GlobalModuleIndex;

40class InMemoryModuleCache;

41class PCHContainerReader;

42

43namespace serialization {

44

45

47

48

50

51

52

53

55

56

57

59

60

61 llvm::DenseMap<const FileEntry *, ModuleFile *> Modules;

62

63

64

66

67

69

70

72

73

75

76

77 llvm::DenseMap<const FileEntry *, std::unique_ptrllvm::MemoryBuffer>

78 InMemoryBuffers;

79

80

82

83

84

85

86

87

88

89

90

92

93

94

95

96

98

99

100

101 struct VisitState {

102 explicit VisitState(unsigned N) : VisitNumber(N, 0) {

103 Stack.reserve(N);

104 }

105

106

107

109

110

111

113

114

115 unsigned NextVisitNumber = 1;

116

117

118 std::unique_ptr NextState;

119 };

120

121

122 std::unique_ptr FirstVisitState;

123

124 std::unique_ptr allocateVisitState();

125 void returnVisitState(std::unique_ptr State);

126

127public:

135

139

140

142

143

145

146

148

149

151

152

154

155

157

158

159 llvm::iterator_range<SmallVectorImpl<ModuleFile *>::const_iterator>

161 return llvm::make_range(PCHChain.begin(), PCHChain.end());

162 }

163

164

165

167

168

169

171

172

174

175

177

178

180

181

183

184

185 std::unique_ptrllvm::MemoryBuffer lookupBuffer(StringRef Name);

186

187

188 unsigned size() const { return Chain.size(); }

189

190

192

194

195

197

198

200

201

204

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

243 ModuleFile *ImportedBy, unsigned Generation,

244 off_t ExpectedSize, time_t ExpectedModTime,

248 std::string &ErrorStr);

249

250

252

253

255 std::unique_ptrllvm::MemoryBuffer Buffer);

256

257

259

260

261

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283 void visit(llvm::function_ref<bool(ModuleFile &M)> Visitor,

284 llvm::SmallPtrSetImpl<ModuleFile *> *ModuleFilesHit = nullptr);

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

305

306

308

310};

311

312}

313

314}

315

316#endif

Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.

Defines the clang::SourceLocation class and associated facilities.

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

Implements support for file system lookup, file system caching, and directory search management.

A global index for a set of module files, providing information about the identifiers within those mo...

In-memory cache for modules.

Describes a module or submodule.

This abstract interface provides operations for unwrapping containers for serialized ASTs (precompile...

Encodes a location in the source.

The base class of the type hierarchy.

Information about a module that has been loaded by the ASTReader.

Manages the set of modules loaded by an AST reader.

bool lookupModuleFile(StringRef FileName, off_t ExpectedSize, time_t ExpectedModTime, OptionalFileEntryRef &File)

Attempt to resolve the given module file name to a file entry.

ModuleFile & getPrimaryModule()

Returns the primary module associated with the manager, that is, the first module loaded.

AddModuleResult

The result of attempting to add a new module.

@ Missing

The module file is missing.

@ OutOfDate

The module file is out-of-date.

@ NewlyLoaded

The module file was just loaded in response to this call.

@ AlreadyLoaded

The module file had already been loaded.

ModuleFile & getPrimaryModule() const

Returns the primary module associated with the manager, that is, the first module loaded.

llvm::iterator_range< SmallVectorImpl< ModuleFile * >::const_iterator > pch_modules() const

A range covering the PCH and preamble module files loaded.

void moduleFileAccepted(ModuleFile *MF)

Notification from the AST reader that the given module file has been "accepted", and will not (can no...

ModuleFile * lookup(const FileEntry *File) const

Returns the module associated with the given module file.

ModuleReverseIterator rbegin()

Reverse iterator to traverse all loaded modules.

std::pair< uint32_t, StringRef > ModuleOffset

void viewGraph()

View the graphviz representation of the module graph.

ModuleConstIterator begin() const

Const forward iterator to traverse all loaded modules.

ModuleFile & operator[](unsigned Index) const

Returns the module associated with the given index.

ModuleIterator begin()

Forward iterator to traverse all loaded modules.

void setGlobalIndex(GlobalModuleIndex *Index)

Set the global module index.

ModuleFile * lookupByFileName(StringRef FileName) const

Returns the module associated with the given file name.

void removeModules(ModuleIterator First)

Remove the modules starting from First (to the end).

llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::const_iterator > ModuleConstIterator

ModuleConstIterator end() const

Const forward iterator end-point to traverse all loaded modules.

ModuleIterator end()

Forward iterator end-point to traverse all loaded modules.

std::unique_ptr< llvm::MemoryBuffer > lookupBuffer(StringRef Name)

Returns the in-memory (virtual file) buffer with the given name.

void addInMemoryBuffer(StringRef FileName, std::unique_ptr< llvm::MemoryBuffer > Buffer)

Add an in-memory buffer the list of known buffers.

ModuleReverseIterator rend()

Reverse iterator end-point to traverse all loaded modules.

void visit(llvm::function_ref< bool(ModuleFile &M)> Visitor, llvm::SmallPtrSetImpl< ModuleFile * > *ModuleFilesHit=nullptr)

Visit each of the modules.

llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::reverse_iterator > ModuleReverseIterator

unsigned size() const

Number of modules loaded.

InMemoryModuleCache & getModuleCache() const

AddModuleResult addModule(StringRef FileName, ModuleKind Type, SourceLocation ImportLoc, ModuleFile *ImportedBy, unsigned Generation, off_t ExpectedSize, time_t ExpectedModTime, ASTFileSignature ExpectedSignature, ASTFileSignatureReader ReadSignature, ModuleFile *&Module, std::string &ErrorStr)

Attempts to create a new module and add it to the list of known modules.

ASTFileSignature(*)(StringRef) ASTFileSignatureReader

llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::iterator > ModuleIterator

ModuleFile * lookupByModuleName(StringRef ModName) const

Returns the module associated with the given module name.

ModuleKind

Specifies the kind of module that has been loaded.

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

The signature of a module, which is a hash of the AST content.