23 PCHContainerOps = std::make_shared<PCHContainerOperations>();
25 PCHContainerOps->registerReader(
26 std::make_unique<ObjectFilePCHContainerReader>());
28 PCHContainerOps->registerWriter(std::make_unique<RawPCHContainerWriter>());
30 if (Service.shouldTraceVFS())
31 FS = llvm::makeIntrusiveRefCnt<llvm::vfs::TracingFileSystem>(std::move(FS));
33 switch (Service.getMode()) {
35 DepFS = llvm::makeIntrusiveRefCnt<DependencyScanningWorkerFilesystem>(
36 Service.getSharedCache(), FS);
50 StringRef WorkingDirectory,
const std::vector<std::string> &CommandLine,
52 std::optional<llvm::MemoryBufferRef> TUBuffer) {
59 return llvm::Error::success();
60 return llvm::make_error<llvm::StringError>(
61 DiagPrinterWithOS.
DiagnosticsOS.str(), llvm::inconvertibleErrorCode());
71 llvm::BumpPtrAllocator Alloc;
83 const std::vector<std::string> &CommandLine,
86 std::shared_ptr<clang::PCHContainerOperations> &PCHContainerOps,
92 if (!Action.
runInvocation(std::move(Invocation), std::move(FS),
101bool DependencyScanningWorker::scanDependencies(
102 StringRef WorkingDirectory,
const std::vector<std::string> &CommandLine,
104 DiagnosticConsumer &DC,
105 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS) {
106 DignosticsEngineWithDiagOpts DiagEngineWithCmdAndOpts(CommandLine, FS, DC);
107 DependencyScanningAction Action(Service, WorkingDirectory, Consumer,
111 if (CommandLine[1] ==
"-cc1") {
113 CommandLine, Action, FS, PCHContainerOps,
114 *DiagEngineWithCmdAndOpts.DiagEngine, Consumer);
117 CommandLine, *DiagEngineWithCmdAndOpts.DiagEngine, FS,
118 [&](
const driver::Command &Cmd) {
119 if (StringRef(Cmd.getCreator().getName()) !=
"clang") {
122 Consumer.handleBuildCommand(
123 {Cmd.getExecutable(),
124 {Cmd.getArguments().begin(), Cmd.getArguments().end()}});
129 std::vector<std::string> Argv;
138 std::move(Argv), Action, FS, PCHContainerOps,
139 *DiagEngineWithCmdAndOpts.DiagEngine, Consumer);
143 if (
Success && !Action.hasScanned())
144 DiagEngineWithCmdAndOpts.DiagEngine->Report(
145 diag::err_fe_expected_compiler_job)
146 << llvm::join(CommandLine,
" ");
149 if (!Action.hasDiagConsumerFinished())
152 return Success && Action.hasScanned();
156 StringRef WorkingDirectory,
const std::vector<std::string> &CommandLine,
161 BaseFS, CommandLine, WorkingDirectory, *TUBuffer);
162 return scanDependencies(WorkingDirectory, FinalCommandLine, Consumer,
163 Controller, DC, FinalFS);
165 BaseFS->setCurrentWorkingDirectory(WorkingDirectory);
166 return scanDependencies(WorkingDirectory, CommandLine, Consumer, Controller,
173 StringRef CWD,
const std::vector<std::string> &CommandLine) {
175 return CIWithContext->handleReturnStatus(
Success);
184 return CIWithContext->handleReturnStatus(
Success);
190 return CIWithContext->handleReturnStatus(
Success);
194 StringRef CWD,
const std::vector<std::string> &CommandLine,
197 std::make_unique<CompilerInstanceWithContext>(*
this, CWD, CommandLine);
198 return CIWithContext->initialize(DC);
204 assert(CIWithContext &&
"CompilerInstance with context required!");
205 return CIWithContext->computeDependencies(ModuleName, Consumer, Controller);
209 return CIWithContext->finalize();
static bool forEachDriverJob(ArrayRef< std::string > ArgStrs, DiagnosticsEngine &Diags, IntrusiveRefCntPtr< llvm::vfs::FileSystem > FS, llvm::function_ref< bool(const driver::Command &Cmd)> Callback)
static bool createAndRunToolInvocation(const std::vector< std::string > &CommandLine, DependencyScanningAction &Action, IntrusiveRefCntPtr< llvm::vfs::FileSystem > FS, std::shared_ptr< clang::PCHContainerOperations > &PCHContainerOps, DiagnosticsEngine &Diags, DependencyConsumer &Consumer)
Abstract interface, implemented by clients of the front-end, which formats and prints fully processed...
virtual void finish()
Callback to inform the diagnostic client that processing of all source files has ended.
Concrete class used by the front-end to report problems and issues.
DiagnosticConsumer * getClient()
Command - An executable path/name and argument vector to execute.
const llvm::opt::ArgStringList & getArguments() const
const char * getExecutable() const
The JSON file list parser is used to communicate input to InstallAPI.
@ Success
Annotation was successful.
TextDiagnosticPrinter DiagPrinter
llvm::raw_string_ostream DiagnosticsOS