@@ -45,6 +45,31 @@ 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
+
64
+ // / Dependency scanner callbacks that are used during scanning to influence the
65
+ // / behaviour of the scan - for example, to customize the scanned invocations.
66
+ class DependencyActionController {
67
+ public:
68
+ virtual ~DependencyActionController ();
69
+
70
+ virtual std::string lookupModuleOutput (const ModuleID &ID,
71
+ ModuleOutputKind Kind) = 0;
72
+
48
73
virtual llvm::Error initialize (CompilerInstance &ScanInstance,
49
74
CompilerInvocation &NewInvocation) {
50
75
return llvm::Error::success ();
@@ -70,72 +95,18 @@ class DependencyConsumer {
70
95
return llvm::Error::success ();
71
96
}
72
97
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
-
89
- // / Dependency scanner callbacks that are used during scanning to influence the
90
- // / behaviour of the scan - for example, to customize the scanned invocations.
91
- class DependencyActionController {
92
- public:
93
- virtual ~DependencyActionController ();
94
-
95
- virtual std::string lookupModuleOutput (const ModuleID &ID,
96
- ModuleOutputKind Kind) = 0;
97
- };
98
-
99
- // FIXME: This may need to merge with \p DependencyConsumer in order to support
100
- // clang modules for the include-tree.
101
- class PPIncludeActionsConsumer : public DependencyConsumer {
102
- public:
103
- virtual void enteredInclude (Preprocessor &PP, FileID FID) = 0;
98
+ virtual void enteredInclude (Preprocessor &PP, FileID FID) {}
104
99
105
100
virtual void exitedInclude (Preprocessor &PP, FileID IncludedBy,
106
- FileID Include, SourceLocation ExitLoc) = 0;
101
+ FileID Include, SourceLocation ExitLoc) {}
107
102
108
- virtual void handleHasIncludeCheck (Preprocessor &PP, bool Result) = 0;
103
+ virtual void handleHasIncludeCheck (Preprocessor &PP, bool Result) {}
109
104
110
105
// / FIXME: This is temporary until we eliminate the split between consumers in
111
106
// / \p DependencyScanningTool and collectors in \p DependencyScanningWorker
112
107
// / and have them both in the same file. see FIXME in \p
113
108
// / DependencyScanningAction::runInvocation.
114
- virtual const DepscanPrefixMapping &getPrefixMapping () = 0;
115
-
116
- protected:
117
- void handleBuildCommand (Command) override {}
118
- void handleDependencyOutputOpts (const DependencyOutputOptions &Opts) override {
119
- llvm::report_fatal_error (" unexpected callback for include-tree" );
120
- }
121
- void handleFileDependency (StringRef Filename) override {
122
- llvm::report_fatal_error (" unexpected callback for include-tree" );
123
- }
124
- void handlePrebuiltModuleDependency (PrebuiltModuleDep PMD) override {
125
- llvm::report_fatal_error (" unexpected callback for include-tree" );
126
- }
127
- void handleModuleDependency (ModuleDeps MD) override {
128
- llvm::report_fatal_error (" unexpected callback for include-tree" );
129
- }
130
- void handleContextHash (std::string Hash) override {
131
- llvm::report_fatal_error (" unexpected callback for include-tree" );
132
- }
133
- void handleCASFileSystemRootID (cas::CASID ID) override {
134
- llvm::report_fatal_error (" unexpected callback for include-tree" );
135
- }
136
- std::string lookupModuleOutput (const ModuleID &, ModuleOutputKind) override {
137
- llvm::report_fatal_error (" unexpected callback for include-tree" );
138
- }
109
+ virtual const DepscanPrefixMapping *getPrefixMapping () { return nullptr ; }
139
110
};
140
111
141
112
// / An individual dependency scanning worker that is able to run on its own
@@ -177,8 +148,8 @@ class DependencyScanningWorker {
177
148
void computeDependenciesFromCompilerInvocation (
178
149
std::shared_ptr<CompilerInvocation> Invocation,
179
150
StringRef WorkingDirectory, DependencyConsumer &Consumer,
180
- DiagnosticConsumer &DiagsConsumer, raw_ostream *VerboseOS ,
181
- bool DiagGenerationAsCompilation);
151
+ DependencyActionController &Controller, DiagnosticConsumer &DiagsConsumer ,
152
+ raw_ostream *VerboseOS, bool DiagGenerationAsCompilation);
182
153
183
154
ScanningOutputFormat getScanningFormat () const { return Format; }
184
155
0 commit comments