Skip to content

Commit 1af9741

Browse files
committed
format
1 parent cb3af7c commit 1af9741

File tree

3 files changed

+44
-41
lines changed

3 files changed

+44
-41
lines changed

include/swift/AST/DiagnosticConsumer.h

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -137,42 +137,46 @@ class NullDiagnosticConsumer : public DiagnosticConsumer {
137137
class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
138138
public:
139139
class Subconsumer;
140-
141-
/// Given a vector of subconsumers, return the most specific DiagnosticConsumer for that vector.
142-
/// That will be a FileSpecificDiagnosticConsumer if the vector has > 1 subconsumer,
143-
/// the subconsumer itself if the vector has just one, or a null pointer if there are no subconsumers.
144-
/// Takes ownership of the DiagnosticConsumers specified in \p subconsumers.
145-
static std::unique_ptr<DiagnosticConsumer> consolidateSubconsumers(SmallVectorImpl<Subconsumer> &subconsumers);
146-
140+
141+
/// Given a vector of subconsumers, return the most specific
142+
/// DiagnosticConsumer for that vector. That will be a
143+
/// FileSpecificDiagnosticConsumer if the vector has > 1 subconsumer, the
144+
/// subconsumer itself if the vector has just one, or a null pointer if there
145+
/// are no subconsumers. Takes ownership of the DiagnosticConsumers specified
146+
/// in \p subconsumers.
147+
static std::unique_ptr<DiagnosticConsumer>
148+
consolidateSubconsumers(SmallVectorImpl<Subconsumer> &subconsumers);
149+
147150
/// A diagnostic consumer, along with the name of the buffer that it should
148151
/// be associated with.
149152
class Subconsumer {
150-
friend std::unique_ptr<DiagnosticConsumer> FileSpecificDiagnosticConsumer::consolidateSubconsumers(SmallVectorImpl<Subconsumer> &subconsumers);
151-
153+
friend std::unique_ptr<DiagnosticConsumer>
154+
FileSpecificDiagnosticConsumer::consolidateSubconsumers(
155+
SmallVectorImpl<Subconsumer> &subconsumers);
156+
152157
/// The name of the input file that a consumer and diagnostics should
153158
/// be associated with. An empty string means that a consumer is not
154159
/// associated with any particular buffer, and should only receive
155160
/// diagnostics that are not in any of the other consumers' files.
156161
std::string inputFileName;
157-
162+
158163
/// The consumer (if any) for diagnostics associated with the inputFileName.
159164
/// A null pointer for the DiagnosticConsumer means that diagnostics for
160165
/// this file should not be emitted.
161166
std::unique_ptr<DiagnosticConsumer> consumer;
162-
167+
163168
// Has this subconsumer ever handled a diagnostic that is an error?
164169
bool hasAnErrorBeenConsumed = false;
165170

166-
167171
public:
168172
std::string getInputFileName() const { return inputFileName; }
169-
173+
170174
DiagnosticConsumer *getConsumer() const { return consumer.get(); }
171175

172176
Subconsumer(std::string inputFileName,
173177
std::unique_ptr<DiagnosticConsumer> consumer)
174178
: inputFileName(inputFileName), consumer(std::move(consumer)) {}
175-
179+
176180
void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
177181
DiagnosticKind Kind,
178182
StringRef FormatString,
@@ -181,7 +185,8 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
181185
if (!getConsumer())
182186
return; // Suppress non-primary diagnostic in batch mode.
183187
hasAnErrorBeenConsumed |= Kind == DiagnosticKind::Error;
184-
getConsumer()->handleDiagnostic(SM, Loc, Kind, FormatString, FormatArgs, Info);
188+
getConsumer()->handleDiagnostic(SM, Loc, Kind, FormatString, FormatArgs,
189+
Info);
185190
}
186191

187192
void informDriverOfIncompleteBatchModeCompilation() {
@@ -205,38 +210,36 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
205210

206211
/// Index into Subconsumers vector for this subconsumer.
207212
/*const*/ unsigned subconsumerIndex;
208-
213+
209214
public:
210215
ConsumerSpecificInformation(const CharSourceRange range,
211216
unsigned subconsumerIndex)
212-
: range(range), subconsumerIndex(subconsumerIndex) {}
217+
: range(range), subconsumerIndex(subconsumerIndex) {}
213218

214219
Subconsumer &subconsumer(FileSpecificDiagnosticConsumer &c) const {
215220
return c.Subconsumers[subconsumerIndex];
216221
}
217-
222+
218223
/// Compare according to range:
219-
bool operator < (const ConsumerSpecificInformation &right) const {
224+
bool operator<(const ConsumerSpecificInformation &right) const {
220225
auto compare = std::less<const char *>();
221-
return compare(getRawLoc( range.getEnd()).getPointer(),
226+
return compare(getRawLoc(range.getEnd()).getPointer(),
222227
getRawLoc(right.range.getEnd()).getPointer());
223228
}
224-
229+
225230
/// Overlaps by range:
226231
bool overlaps(const ConsumerSpecificInformation &other) const {
227232
return range.overlaps(other.range);
228233
}
229-
234+
230235
/// Does my range end after \p loc?
231236
bool endsAfter(const SourceLoc loc) const {
232237
auto compare = std::less<const char *>();
233238
return compare(getRawLoc(range.getEnd()).getPointer(),
234239
getRawLoc(loc).getPointer());
235240
}
236-
237-
bool contains(const SourceLoc loc) const {
238-
return range.contains(loc);
239-
}
241+
242+
bool contains(const SourceLoc loc) const { return range.contains(loc); }
240243
};
241244

242245
private:
@@ -262,19 +265,15 @@ class FileSpecificDiagnosticConsumer : public DiagnosticConsumer {
262265
ConsumerSpecificInfoForSubsequentNotes = None;
263266

264267
bool HasAnErrorBeenConsumed = false;
265-
266-
268+
267269
/// Takes ownership of the DiagnosticConsumers specified in \p consumers.
268270
///
269271
/// There must not be two consumers for the same file (i.e., having the same
270272
/// buffer name).
271273
explicit FileSpecificDiagnosticConsumer(
272-
SmallVectorImpl<Subconsumer> &consumers);
274+
SmallVectorImpl<Subconsumer> &consumers);
273275

274276
public:
275-
276-
277-
278277
void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
279278
DiagnosticKind Kind,
280279
StringRef FormatString,

lib/AST/DiagnosticConsumer.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,18 @@ static bool hasDuplicateFileNames(
5353
return false;
5454
}
5555

56-
std::unique_ptr<DiagnosticConsumer> FileSpecificDiagnosticConsumer::
57-
consolidateSubconsumers(SmallVectorImpl<Subconsumer> &subconsumers) {
56+
std::unique_ptr<DiagnosticConsumer>
57+
FileSpecificDiagnosticConsumer::consolidateSubconsumers(
58+
SmallVectorImpl<Subconsumer> &subconsumers) {
5859
if (subconsumers.empty())
5960
return nullptr;
6061
if (subconsumers.size() == 1)
6162
return std::move(subconsumers.front()).consumer;
62-
// Cannot use return llvm::make_unique<FileSpecificDiagnosticConsumer>(subconsumers);
63-
// because the constructor is private.
64-
return std::unique_ptr<DiagnosticConsumer>(new FileSpecificDiagnosticConsumer(subconsumers));
63+
// Cannot use return
64+
// llvm::make_unique<FileSpecificDiagnosticConsumer>(subconsumers); because
65+
// the constructor is private.
66+
return std::unique_ptr<DiagnosticConsumer>(
67+
new FileSpecificDiagnosticConsumer(subconsumers));
6568
}
6669

6770
FileSpecificDiagnosticConsumer::FileSpecificDiagnosticConsumer(
@@ -134,7 +137,8 @@ FileSpecificDiagnosticConsumer::consumerSpecificInformationForLocation(
134137
if (!SM.getIDForBufferIdentifier(Subconsumers.begin()->getInputFileName())
135138
.hasValue()) {
136139
assert(llvm::none_of(Subconsumers, [&](const Subconsumer &subconsumer) {
137-
return SM.getIDForBufferIdentifier(subconsumer.getInputFileName()).hasValue();
140+
return SM.getIDForBufferIdentifier(subconsumer.getInputFileName())
141+
.hasValue();
138142
}));
139143
return None;
140144
}
@@ -197,8 +201,8 @@ bool FileSpecificDiagnosticConsumer::finishProcessing() {
197201

198202
bool hadError = false;
199203
for (auto &subconsumer : Subconsumers)
200-
hadError |=
201-
subconsumer.getConsumer() && subconsumer.getConsumer()->finishProcessing();
204+
hadError |= subconsumer.getConsumer() &&
205+
subconsumer.getConsumer()->finishProcessing();
202206
return hadError;
203207
}
204208

lib/FrontendTool/FrontendTool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1618,7 +1618,7 @@ createDispatchingDiagnosticConsumerIfNeeded(
16181618
return false;
16191619
});
16201620
}
1621-
1621+
16221622
return FileSpecificDiagnosticConsumer::consolidateSubconsumers(subconsumers);
16231623
}
16241624

0 commit comments

Comments
 (0)