@@ -45,6 +45,33 @@ class DependencyConsumer {
45
45
public:
46
46
virtual ~DependencyConsumer () {}
47
47
48
+ virtual void handleBuildCommand (Command Cmd) {}
49
+
50
+ virtual void
51
+ handleDependencyOutputOpts (const DependencyOutputOptions &Opts) = 0 ;
52
+
53
+ virtual void handleFileDependency (StringRef Filename) = 0;
54
+
55
+ virtual void handlePrebuiltModuleDependency (PrebuiltModuleDep PMD) = 0;
56
+
57
+ virtual void handleModuleDependency (ModuleDeps MD) = 0;
58
+
59
+ virtual void handleContextHash (std::string Hash) = 0;
60
+
61
+ virtual void handleCASFileSystemRootID (std::string ID) {}
62
+
63
+ virtual void handleIncludeTreeID (std::string ID) {}
64
+ };
65
+
66
+ // / Dependency scanner callbacks that are used during scanning to influence the
67
+ // / behaviour of the scan - for example, to customize the scanned invocations.
68
+ class DependencyActionController {
69
+ public:
70
+ virtual ~DependencyActionController ();
71
+
72
+ virtual std::string lookupModuleOutput (const ModuleID &ID,
73
+ ModuleOutputKind Kind) = 0;
74
+
48
75
virtual llvm::Error initialize (CompilerInstance &ScanInstance,
49
76
CompilerInvocation &NewInvocation) {
50
77
return llvm::Error::success ();
@@ -70,65 +97,18 @@ class DependencyConsumer {
70
97
return llvm::Error::success ();
71
98
}
72
99
73
- virtual void handleBuildCommand (Command Cmd) = 0;
74
-
75
- virtual void
76
- handleDependencyOutputOpts (const DependencyOutputOptions &Opts) = 0 ;
77
-
78
- virtual void handleFileDependency (StringRef Filename) = 0;
79
-
80
- virtual void handlePrebuiltModuleDependency (PrebuiltModuleDep PMD) = 0;
81
-
82
- virtual void handleModuleDependency (ModuleDeps MD) = 0;
83
-
84
- virtual void handleContextHash (std::string Hash) = 0;
85
-
86
- virtual void handleCASFileSystemRootID (cas::CASID ID) = 0;
87
-
88
- virtual std::string lookupModuleOutput (const ModuleID &ID,
89
- ModuleOutputKind Kind) = 0;
90
- };
91
-
92
- // FIXME: This may need to merge with \p DependencyConsumer in order to support
93
- // clang modules for the include-tree.
94
- class PPIncludeActionsConsumer : public DependencyConsumer {
95
- public:
96
- virtual void enteredInclude (Preprocessor &PP, FileID FID) = 0;
100
+ virtual void enteredInclude (Preprocessor &PP, FileID FID) {}
97
101
98
102
virtual void exitedInclude (Preprocessor &PP, FileID IncludedBy,
99
- FileID Include, SourceLocation ExitLoc) = 0;
103
+ FileID Include, SourceLocation ExitLoc) {}
100
104
101
- virtual void handleHasIncludeCheck (Preprocessor &PP, bool Result) = 0;
105
+ virtual void handleHasIncludeCheck (Preprocessor &PP, bool Result) {}
102
106
103
107
// / FIXME: This is temporary until we eliminate the split between consumers in
104
108
// / \p DependencyScanningTool and collectors in \p DependencyScanningWorker
105
109
// / and have them both in the same file. see FIXME in \p
106
110
// / DependencyScanningAction::runInvocation.
107
- virtual const DepscanPrefixMapping &getPrefixMapping () = 0;
108
-
109
- protected:
110
- void handleBuildCommand (Command) override {}
111
- void handleDependencyOutputOpts (const DependencyOutputOptions &Opts) override {
112
- llvm::report_fatal_error (" unexpected callback for include-tree" );
113
- }
114
- void handleFileDependency (StringRef Filename) override {
115
- llvm::report_fatal_error (" unexpected callback for include-tree" );
116
- }
117
- void handlePrebuiltModuleDependency (PrebuiltModuleDep PMD) override {
118
- llvm::report_fatal_error (" unexpected callback for include-tree" );
119
- }
120
- void handleModuleDependency (ModuleDeps MD) override {
121
- llvm::report_fatal_error (" unexpected callback for include-tree" );
122
- }
123
- void handleContextHash (std::string Hash) override {
124
- llvm::report_fatal_error (" unexpected callback for include-tree" );
125
- }
126
- void handleCASFileSystemRootID (cas::CASID ID) override {
127
- llvm::report_fatal_error (" unexpected callback for include-tree" );
128
- }
129
- std::string lookupModuleOutput (const ModuleID &, ModuleOutputKind) override {
130
- llvm::report_fatal_error (" unexpected callback for include-tree" );
131
- }
111
+ virtual const DepscanPrefixMapping *getPrefixMapping () { return nullptr ; }
132
112
};
133
113
134
114
// / An individual dependency scanning worker that is able to run on its own
@@ -152,16 +132,15 @@ class DependencyScanningWorker {
152
132
bool computeDependencies (StringRef WorkingDirectory,
153
133
const std::vector<std::string> &CommandLine,
154
134
DependencyConsumer &DepConsumer,
135
+ DependencyActionController &Controller,
155
136
DiagnosticConsumer &DiagConsumer,
156
137
llvm::Optional<StringRef> ModuleName = None);
157
138
// / \returns A \c StringError with the diagnostic output if clang errors
158
139
// / occurred, success otherwise.
159
- llvm::Error computeDependencies (StringRef WorkingDirectory,
160
- const std::vector<std::string> &CommandLine,
161
- DependencyConsumer &Consumer,
162
- llvm::Optional<StringRef> ModuleName = None);
163
-
164
- ScanningOutputFormat getFormat () const { return Format; }
140
+ llvm::Error computeDependencies (
141
+ StringRef WorkingDirectory, const std::vector<std::string> &CommandLine,
142
+ DependencyConsumer &Consumer, DependencyActionController &Controller,
143
+ llvm::Optional<StringRef> ModuleName = None);
165
144
166
145
// / Scan from a compiler invocation.
167
146
// / If \p DiagGenerationAsCompilation is true it will generate error
@@ -171,15 +150,14 @@ class DependencyScanningWorker {
171
150
void computeDependenciesFromCompilerInvocation (
172
151
std::shared_ptr<CompilerInvocation> Invocation,
173
152
StringRef WorkingDirectory, DependencyConsumer &Consumer,
174
- DiagnosticConsumer &DiagsConsumer, raw_ostream *VerboseOS ,
175
- bool DiagGenerationAsCompilation);
153
+ DependencyActionController &Controller, DiagnosticConsumer &DiagsConsumer ,
154
+ raw_ostream *VerboseOS, bool DiagGenerationAsCompilation);
176
155
177
156
ScanningOutputFormat getScanningFormat () const { return Format; }
178
157
179
- llvm::vfs::FileSystem &getRealFS () { return *BaseFS; }
180
158
CachingOnDiskFileSystemPtr getCASFS () { return CacheFS; }
181
- bool useCAS () const { return UseCAS; }
182
159
const CASOptions &getCASOpts () const { return CASOpts; }
160
+ std::shared_ptr<cas::ObjectStore> getCAS () const { return CAS; }
183
161
184
162
// / If \p DependencyScanningService enabled sharing of \p FileManager this
185
163
// / will return the same instance, otherwise it will create a new one for
@@ -201,16 +179,15 @@ class DependencyScanningWorker {
201
179
ScanningOutputFormat Format;
202
180
// / Whether to optimize the modules' command-line arguments.
203
181
bool OptimizeArgs;
182
+ // / Whether to set up command-lines to load PCM files eagerly.
183
+ bool EagerLoadModules;
204
184
205
185
// / The caching file system.
206
186
CachingOnDiskFileSystemPtr CacheFS;
207
187
// / The CAS Dependency Filesytem. This is not set at the sametime as DepFS;
208
188
llvm::IntrusiveRefCntPtr<DependencyScanningCASFilesystem> DepCASFS;
209
189
CASOptions CASOpts;
210
- bool UseCAS;
211
-
212
- // / Whether to set up command-lines to load PCM files eagerly.
213
- bool EagerLoadModules;
190
+ std::shared_ptr<cas::ObjectStore> CAS;
214
191
};
215
192
216
193
} // end namespace dependencies
0 commit comments