Thanks to visit codestin.com
Credit goes to clang.llvm.org

clang 22.0.0git
DependencyScannerImpl.h
Go to the documentation of this file.
1//===- DependencyScanner.h - Performs module dependency scanning *- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_TOOLING_DEPENDENCYSCANNING_DEPENDENCYSCANNER_H
10#define LLVM_CLANG_TOOLING_DEPENDENCYSCANNING_DEPENDENCYSCANNER_H
11
17
18namespace clang {
20
21namespace tooling {
22namespace dependencies {
27
29public:
31 DependencyScanningService &Service, StringRef WorkingDirectory,
34 std::optional<StringRef> ModuleName = std::nullopt)
35 : Service(Service), WorkingDirectory(WorkingDirectory),
36 Consumer(Consumer), Controller(Controller), DepFS(std::move(DepFS)),
37 ModuleName(ModuleName) {}
38 bool runInvocation(std::shared_ptr<CompilerInvocation> Invocation,
40 std::shared_ptr<PCHContainerOperations> PCHContainerOps,
41 DiagnosticConsumer *DiagConsumer);
42
43 bool hasScanned() const { return Scanned; }
44 bool hasDiagConsumerFinished() const { return DiagConsumerFinished; }
45
46 /// Take the cc1 arguments corresponding to the most recent invocation used
47 /// with this action. Any modifications implied by the discovered dependencies
48 /// will have already been applied.
49 std::vector<std::string> takeLastCC1Arguments() {
50 std::vector<std::string> Result;
51 std::swap(Result, LastCC1Arguments); // Reset LastCC1Arguments to empty.
52 return Result;
53 }
54
55private:
56 void setLastCC1Arguments(CompilerInvocation &&CI) {
57 if (MDC)
58 MDC->applyDiscoveredDependencies(CI);
59 LastCC1Arguments = CI.getCC1CommandLine();
60 }
61
62 DependencyScanningService &Service;
63 StringRef WorkingDirectory;
64 DependencyConsumer &Consumer;
65 DependencyActionController &Controller;
67 std::optional<StringRef> ModuleName;
68 std::optional<CompilerInstance> ScanInstanceStorage;
69 std::shared_ptr<ModuleDepCollector> MDC;
70 std::vector<std::string> LastCC1Arguments;
71 bool Scanned = false;
72 bool DiagConsumerFinished = false;
73};
74
75// Helper functions
77
78} // namespace dependencies
79} // namespace tooling
80} // namespace clang
81
82#endif
Helper class for holding the data necessary to invoke the compiler.
Abstract interface, implemented by clients of the front-end, which formats and prints fully processed...
Options for controlling the compiler diagnostics engine.
Dependency scanner callbacks that are used during scanning to influence the behaviour of the scan - f...
std::vector< std::string > takeLastCC1Arguments()
Take the cc1 arguments corresponding to the most recent invocation used with this action.
bool runInvocation(std::shared_ptr< CompilerInvocation > Invocation, IntrusiveRefCntPtr< llvm::vfs::FileSystem > FS, std::shared_ptr< PCHContainerOperations > PCHContainerOps, DiagnosticConsumer *DiagConsumer)
DependencyScanningAction(DependencyScanningService &Service, StringRef WorkingDirectory, DependencyConsumer &Consumer, DependencyActionController &Controller, llvm::IntrusiveRefCntPtr< DependencyScanningWorkerFilesystem > DepFS, std::optional< StringRef > ModuleName=std::nullopt)
The dependency scanning service contains shared configuration and state that is used by the individua...
A virtual file system optimized for the dependency discovery.
void sanitizeDiagOpts(DiagnosticOptions &DiagOpts)
Sanitize diagnostic options for dependency scan.
The JSON file list parser is used to communicate input to InstallAPI.
@ Result
The result type of a method or function.
Definition TypeBase.h:905