@@ -35,8 +35,8 @@ class FrontendInputsAndOutputs {
35
35
friend class ArgsToFrontendInputsConverter ;
36
36
37
37
std::vector<InputFile> AllInputs;
38
-
39
- llvm::StringMap <unsigned > PrimaryInputs ;
38
+ llvm::StringMap< unsigned > PrimaryInputsByName;
39
+ std::vector <unsigned > PrimaryInputsInOrder ;
40
40
41
41
// / In Single-threaded WMO mode, all inputs are used
42
42
// / both for importing and compiling.
@@ -45,25 +45,10 @@ class FrontendInputsAndOutputs {
45
45
// / Punt where needed to enable batch mode experiments.
46
46
bool AreBatchModeChecksBypassed = false ;
47
47
48
- SupplementaryOutputPaths SupplementaryOutputs;
49
-
50
48
public:
51
49
bool areBatchModeChecksBypassed () const { return AreBatchModeChecksBypassed; }
52
50
void setBypassBatchModeChecks (bool bbc) { AreBatchModeChecksBypassed = bbc; }
53
51
54
- const SupplementaryOutputPaths &supplementaryOutputs () const {
55
- return SupplementaryOutputs;
56
- }
57
- SupplementaryOutputPaths &supplementaryOutputs () {
58
- return SupplementaryOutputs;
59
- }
60
-
61
- // / When performing a compilation for zero or one primary input file,
62
- // / this will hold the PrimarySpecificPaths.
63
- // / In a future PR, each InputFile will hold its own PrimarySpecificPaths and
64
- // / this will go away.
65
- PrimarySpecificPaths PrimarySpecificPathsForAtMostOnePrimary;
66
-
67
52
FrontendInputsAndOutputs () = default ;
68
53
FrontendInputsAndOutputs (const FrontendInputsAndOutputs &other);
69
54
FrontendInputsAndOutputs &operator =(const FrontendInputsAndOutputs &other);
@@ -88,6 +73,9 @@ class FrontendInputsAndOutputs {
88
73
89
74
std::vector<std::string> getInputFilenames () const ;
90
75
76
+ // / \return nullptr if not a primary input file.
77
+ const InputFile *primaryInputNamed (StringRef name) const ;
78
+
91
79
unsigned inputCount () const { return AllInputs.size (); }
92
80
93
81
bool hasInputs () const { return !AllInputs.empty (); }
@@ -99,21 +87,23 @@ class FrontendInputsAndOutputs {
99
87
100
88
const InputFile &lastInput () const { return AllInputs.back (); }
101
89
102
- StringRef getFilenameOfFirstInput () const ;
90
+ const std::string & getFilenameOfFirstInput () const ;
103
91
104
92
bool isReadingFromStdin () const ;
105
93
106
- void forEachInput (llvm::function_ref<void (const InputFile &)> fn) const ;
94
+ // / If \p fn returns true, exits early and returns true.
95
+ bool forEachInput (llvm::function_ref<bool (const InputFile &)> fn) const ;
107
96
108
97
// Primaries:
109
98
110
99
const InputFile &firstPrimaryInput () const ;
111
100
const InputFile &lastPrimaryInput () const ;
112
101
113
- void
114
- forEachPrimaryInput (llvm::function_ref<void (const InputFile &)> fn) const ;
102
+ // / If \p fn returns true, exit early and return true.
103
+ bool
104
+ forEachPrimaryInput (llvm::function_ref<bool (const InputFile &)> fn) const ;
115
105
116
- unsigned primaryInputCount () const { return PrimaryInputs .size (); }
106
+ unsigned primaryInputCount () const { return PrimaryInputsInOrder .size (); }
117
107
118
108
// Primary count readers:
119
109
@@ -143,11 +133,8 @@ class FrontendInputsAndOutputs {
143
133
144
134
const InputFile &getRequiredUniquePrimaryInput () const ;
145
135
146
- // / \return the name of the unique primary input, or an empty StrinRef if
147
- // / there isn't one.
148
- StringRef getNameOfUniquePrimaryInputFile () const ;
149
-
150
- // / Combines all primaries for stats reporter
136
+ // / FIXME: Should combine all primaries for the result
137
+ // / instead of just answering "batch" if there is more than one primary.
151
138
std::string getStatsFileMangledInputName () const ;
152
139
153
140
bool isInputPrimary (StringRef file) const ;
@@ -181,9 +168,9 @@ class FrontendInputsAndOutputs {
181
168
private:
182
169
friend class ArgsToFrontendOptionsConverter ;
183
170
184
- void
185
- setMainAndSupplementaryOutputs ( ArrayRef<std::string> outputFiles,
186
- SupplementaryOutputPaths supplementaryOutputs);
171
+ void setMainAndSupplementaryOutputs (
172
+ ArrayRef<std::string> outputFiles,
173
+ ArrayRef< SupplementaryOutputPaths> supplementaryOutputs);
187
174
188
175
public:
189
176
unsigned countOfInputsProducingMainOutputs () const ;
@@ -198,17 +185,18 @@ class FrontendInputsAndOutputs {
198
185
// / Under single-threaded WMO, we pretend that the first input
199
186
// / generates the main output, even though it will include code
200
187
// / generated from all of them.
201
- void forEachInputProducingAMainOutputFile (
202
- llvm::function_ref<void (const InputFile &)> fn) const ;
188
+ // /
189
+ // / If \p fn returns true, return early and return true.
190
+ bool forEachInputProducingAMainOutputFile (
191
+ llvm::function_ref<bool (const InputFile &)> fn) const ;
203
192
204
193
std::vector<std::string> copyOutputFilenames () const ;
205
194
206
- void
207
- forEachOutputFilename (llvm::function_ref<void (const std::string &)> fn) const ;
195
+ void forEachOutputFilename (llvm::function_ref<void (StringRef)> fn) const ;
208
196
209
197
// / Gets the name of the specified output filename.
210
198
// / If multiple files are specified, the last one is returned.
211
- StringRef getSingleOutputFilename () const ;
199
+ std::string getSingleOutputFilename () const ;
212
200
213
201
bool isOutputFilenameStdout () const ;
214
202
bool isOutputFileDirectory () const ;
@@ -218,17 +206,22 @@ class FrontendInputsAndOutputs {
218
206
219
207
unsigned countOfFilesProducingSupplementaryOutput () const ;
220
208
221
- void forEachInputProducingSupplementaryOutput (
222
- llvm::function_ref<void (const InputFile &)> fn) const ;
209
+ // / If \p fn returns true, exit early and return true.
210
+ bool forEachInputProducingSupplementaryOutput (
211
+ llvm::function_ref<bool (const InputFile &)> fn) const ;
223
212
224
213
// / Assumes there is not more than one primary input file, if any.
225
214
// / Otherwise, you would need to call getPrimarySpecificPathsForPrimary
226
215
// / to tell it which primary input you wanted the outputs for.
216
+ const PrimarySpecificPaths &
217
+ getPrimarySpecificPathsForAtMostOnePrimary () const ;
227
218
228
- PrimarySpecificPaths getPrimarySpecificPathsForAtMostOnePrimary () const ;
219
+ const PrimarySpecificPaths &
220
+ getPrimarySpecificPathsForPrimary (StringRef) const ;
229
221
230
- PrimarySpecificPaths
231
- getPrimarySpecificPathsForPrimary (StringRef filename) const ;
222
+ bool hasSupplementaryOutputPath (
223
+ llvm::function_ref<const std::string &(const SupplementaryOutputPaths &)>
224
+ extractorFn) const ;
232
225
233
226
bool hasDependenciesPath () const ;
234
227
bool hasReferenceDependenciesPath () const ;
0 commit comments