clang: lib/Tooling/DependencyScanning/DependencyScanningTool.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

11#include

12

13using namespace clang;

14using namespace tooling;

15using namespace dependencies;

16

20 : Worker(Service, std::move(FS)) {}

21

22namespace {

23

25public:

26 void handleBuildCommand(Command) override {}

27

28 void

30 this->Opts = std::make_unique(Opts);

31 }

32

33 void handleFileDependency(StringRef File) override {

34 Dependencies.push_back(std::string(File));

35 }

36

37

38

39

40 void handlePrebuiltModuleDependency(PrebuiltModuleDep PMD) override {}

41 void handleModuleDependency(ModuleDeps MD) override {}

42 void handleDirectModuleDependency(ModuleID ID) override {}

43 void handleContextHash(std::string Hash) override {}

44

45 void printDependencies(std::string &S) {

46 assert(Opts && "Handled dependency output options.");

47

49 public:

53 for (const auto &Dep : Dependencies)

54 addDependency(Dep);

55 }

56

57 void printDependencies(std::string &S) {

58 llvm::raw_string_ostream OS(S);

59 outputDependencyFile(OS);

60 }

61 };

62

63 DependencyPrinter Generator(*Opts, Dependencies);

65 }

66

67protected:

68 std::unique_ptr Opts;

69 std::vectorstd::string Dependencies;

70};

71}

72

74 const std::vectorstd::string &CommandLine, StringRef CWD) {

75 MakeDependencyPrinterConsumer Consumer;

80 return std::move(Result);

81 std::string Output;

82 Consumer.printDependencies(Output);

83 return Output;

84}

85

88 std::string &MakeformatOutputPath) {

89 class P1689ModuleDependencyPrinterConsumer

90 : public MakeDependencyPrinterConsumer {

91 public:

92 P1689ModuleDependencyPrinterConsumer(P1689Rule &Rule,

95 Rule.PrimaryOutput = Command.Output;

96 }

97

98 void handleProvidedAndRequiredStdCXXModules(

99 std::optional Provided,

100 std::vector Requires) override {

101 Rule.Provides = Provided;

102 if (Rule.Provides)

103 Rule.Provides->SourcePath = Filename.str();

104 Rule.Requires = Requires;

105 }

106

107 StringRef getMakeFormatDependencyOutputPath() {

108 if (Opts->OutputFormat != DependencyOutputFormat::Make)

109 return {};

110 return Opts->OutputFile;

111 }

112

113 private:

116 };

117

119 public:

120

121 std::string lookupModuleOutput(const ModuleID &,

123 return "";

124 }

125 };

126

128 P1689ModuleDependencyPrinterConsumer Consumer(Rule, Command);

129 P1689ActionController Controller;

131 Controller);

133 return std::move(Result);

134

135 MakeformatOutputPath = Consumer.getMakeFormatDependencyOutputPath();

136 if (!MakeformatOutputPath.empty())

137 Consumer.printDependencies(MakeformatOutput);

138 return Rule;

139}

140

143 const std::vectorstd::string &CommandLine, StringRef CWD,

144 const llvm::DenseSet &AlreadySeen,

151 return std::move(Result);

153}

154

156 StringRef ModuleName, const std::vectorstd::string &CommandLine,

157 StringRef CWD, const llvm::DenseSet &AlreadySeen,

162 Controller, ModuleName);

164 return std::move(Result);

166}

167

170

172 TU.FileDeps = std::move(Dependencies);

174 TU.Commands = std::move(Commands);

175

176 for (auto &&M : ClangModuleDeps) {

177 auto &MD = M.second;

178

179

180 if (AlreadySeen.count(M.first))

181 continue;

183 }

185

186 return TU;

187}

188

191

192 for (auto &&M : ClangModuleDeps) {

193 auto &MD = M.second;

194

195

196 if (AlreadySeen.count(M.first))

197 continue;

198 ModuleGraph.push_back(std::move(MD));

199 }

200

201 return ModuleGraph;

202}

203

enum clang::sema::@1725::IndirectLocalPathEntry::EntryKind Kind

Builds a dependency file when attached to a Preprocessor (for includes) and ASTReader (for module imp...

DependencyOutputOptions - Options for controlling the compiler dependency file generation.

std::shared_ptr< MatchComputation< T > > Generator

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

@ Worker

'worker' clause, allowed on 'loop', Combined, and 'routine' directives.

@ Result

The result type of a method or function.