clang: include/clang/Tooling/DependencyScanning/ModuleDepCollector.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_CLANG_TOOLING_DEPENDENCYSCANNING_MODULEDEPCOLLECTOR_H

10#define LLVM_CLANG_TOOLING_DEPENDENCYSCANNING_MODULEDEPCOLLECTOR_H

11

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

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

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

24#include "llvm/Support/raw_ostream.h"

25#include

26#include

27#include <unordered_map>

28#include

29

31namespace tooling {

32namespace dependencies {

33

34class DependencyActionController;

35class DependencyConsumer;

36

37

42

44 : ModuleName(M->getTopLevelModuleName()),

47};

48

49

51

52

54

55

56

57

58

59

60

61

62

64

67 std::tie(Other.ModuleName, Other.ContextHash);

68 }

69

72 std::tie(Other.ModuleName, Other.ContextHash);

73 }

74};

75

76

77

79

81

82

84

85

87

90

91

92

93 };

95};

96

97

99

101

103

104

106

108};

109

111

113

114

116

117

118

119

120

122

123

124

126

127

128

130

131

132

133

134

135

137

138

139

141

142

143

144 void forEachFileDep(llvm::function_ref<void(StringRef)> Cb) const;

145

146

147

149

150private:

153

154

155 std::string FileDepsBaseDir;

156

157

158

159 std::vectorstd::string FileDeps;

160

161 std::variant<std::monostate, CowCompilerInvocation, std::vectorstd::string>

162 BuildInfo;

163};

164

166

168

169

170

171

172

174public:

176

181 StringRef FileName, bool IsAngled,

184 StringRef RelativePath, const Module *SuggestedModule,

185 bool ModuleImported,

188 const Module *Imported) override;

189

191

192private:

193

195

196 void handleImport(const Module *Imported);

197

198

199

200 void

202 llvm::DenseSet<const Module *> &SeenSubmodules);

204 llvm::DenseSet<const Module *> &SeenSubmodules);

205

206

207

208

209

210 std::optional handleTopLevelModule(const Module *M);

212 llvm::DenseSet<const Module *> &AddedModules);

214 llvm::DenseSet<const Module *> &AddedModules);

215

216

217

218 void addAllAffectingClangModules(const Module *M, ModuleDeps &MD,

219 llvm::DenseSet<const Module *> &AddedModules);

220 void addAffectingClangModule(const Module *M, ModuleDeps &MD,

221 llvm::DenseSet<const Module *> &AddedModules);

222};

223

224

225

227public:

234 bool IsStdModuleP1689Format);

235

238

239

240

242

243private:

245

246

248

250

252

254

255 std::string MainFile;

256

257 std::string ContextHash;

258

259

260 std::vectorstd::string FileDeps;

261

262 llvm::MapVector<const Module *, std::unique_ptr> ModularDeps;

263

264

265 llvm::DenseMap<ModuleID, ModuleDeps *> ModuleDepsByID;

266

267 llvm::MapVector<const Module *, PrebuiltModuleDep> DirectPrebuiltModularDeps;

268

269 llvm::SetVector<const Module *> DirectModularDeps;

270

271 std::unique_ptr Opts;

272

273

274

275

277

279

280 bool EagerLoadModules;

281

282

283 bool IsStdModuleP1689Format;

284

285 std::optional ProvidedStdCXXModule;

286 std::vector RequiredStdCXXModules;

287

288

289 bool isPrebuiltModule(const Module *M);

290

291

292 void addFileDep(StringRef Path);

293

295

296

297

301

302

303 llvm::DenseSet<const FileEntry *>

305

306

309

314

315

317

318

319

322};

323

324

328

329}

330}

331}

332

333namespace llvm {

335 return hash_combine(ID.ModuleName, ID.ContextHash);

336}

337

338template <> struct DenseMapInfo<clang::tooling::dependencies::ModuleID> {

342 return ModuleID{"~", "~"};

343 }

346 return LHS == RHS;

347 }

348};

349}

350

351#endif

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

llvm::MachO::FileType FileType

Defines the clang::Module class, which describes a module in the source code.

Defines the PPCallbacks interface.

static std::string getName(const CallEvent &Call)

Defines the SourceManager interface.

Reads an AST files chain containing the contents of a translation unit.

Represents a character-granular source range.

CodeGenOptions - Track various options which control how the code is optimized and passed to the back...

CompilerInstance - Helper class for managing a single instance of the Clang compiler.

Helper class for holding the data necessary to invoke the compiler.

Same as CompilerInvocation, but with copy-on-write optimization.

An interface for collecting the dependencies of a compilation.

An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...

Record the location of an inclusion directive, such as an #include or #import statement.

Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...

Describes a module or submodule.

This interface provides a way to observe the actions of the preprocessor as it does its thing.

Engages in a tight little dance with the lexer to efficiently preprocess tokens.

Encodes a location in the source.

Token - This structure provides full information about a lexed token.

The base class of the type hierarchy.

CharacteristicKind

Indicates whether a file or directory holds normal user code, system code, or system code which is im...

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

@ Other

Other implicit parameter.

Diagnostic wrappers for TextAPI types for error reporting.

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