Skip to content

Commit 76373b6

Browse files
committed
SR-11889: Fixed code review issues
1 parent 646e9ac commit 76373b6

File tree

1 file changed

+77
-76
lines changed

1 file changed

+77
-76
lines changed

unittests/AST/DiagnosticConsumerTests.cpp

Lines changed: 77 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "swift/AST/DiagnosticConsumer.h"
14+
#include "swift/Basic/Located.h"
1415
#include "swift/Basic/SourceManager.h"
1516
#include "gtest/gtest.h"
1617

@@ -37,7 +38,7 @@ namespace {
3738
void handleDiagnostic(SourceManager &SM,
3839
const DiagnosticInfo &Info) override {
3940
ASSERT_FALSE(expected.empty());
40-
EXPECT_EQ(std::make_pair(Info.Loc, Info.FormatString), expected.front());
41+
EXPECT_EQ(Located<StringRef>(Info.FormatString, Info.Loc), expected.front());
4142
expected.erase(expected.begin());
4243
}
4344

@@ -83,7 +84,7 @@ TEST(FileSpecificDiagnosticConsumer, InvalidLocDiagsGoToEveryConsumer) {
8384
(void)sourceMgr.addMemBufferCopy("abcde", "A");
8485
(void)sourceMgr.addMemBufferCopy("vwxyz", "B");
8586

86-
ExpectedDiagnostic expected[] = { {SourceLoc(), "dummy"} };
87+
ExpectedDiagnostic expected[] = { Located<StringRef>("dummy", SourceLoc()) };
8788
auto consumerA = llvm::make_unique<ExpectationDiagnosticConsumer>(
8889
nullptr, expected);
8990
auto consumerUnaffiliated = llvm::make_unique<ExpectationDiagnosticConsumer>(
@@ -116,14 +117,14 @@ TEST(FileSpecificDiagnosticConsumer, ErrorsWithLocationsGoToExpectedConsumers) {
116117
SourceLoc backOfB = sourceMgr.getLocForOffset(bufferB, 4);
117118

118119
ExpectedDiagnostic expectedA[] = {
119-
{frontOfA, "front"},
120-
{middleOfA, "middle"},
121-
{backOfA, "back"},
120+
{"front", frontOfA},
121+
{"middle", middleOfA},
122+
{"back", backOfA},
122123
};
123124
ExpectedDiagnostic expectedB[] = {
124-
{frontOfB, "front"},
125-
{middleOfB, "middle"},
126-
{backOfB, "back"}
125+
{"front", frontOfB},
126+
{"middle", middleOfB},
127+
{"back", backOfB}
127128
};
128129

129130
auto consumerA = llvm::make_unique<ExpectationDiagnosticConsumer>(
@@ -170,17 +171,17 @@ TEST(FileSpecificDiagnosticConsumer,
170171
SourceLoc backOfB = sourceMgr.getLocForOffset(bufferB, 4);
171172

172173
ExpectedDiagnostic expectedA[] = {
173-
{frontOfA, "front"},
174-
{frontOfB, "front"},
175-
{middleOfA, "middle"},
176-
{middleOfB, "middle"},
177-
{backOfA, "back"},
178-
{backOfB, "back"}
174+
{"front", frontOfA},
175+
{"front", frontOfB},
176+
{"middle", middleOfA},
177+
{"middle", middleOfB},
178+
{"back", backOfA},
179+
{"back", backOfB}
179180
};
180181
ExpectedDiagnostic expectedUnaffiliated[] = {
181-
{frontOfB, "front"},
182-
{middleOfB, "middle"},
183-
{backOfB, "back"}
182+
{"front", frontOfB},
183+
{"middle", middleOfB},
184+
{"back", backOfB}
184185
};
185186

186187
auto consumerA = llvm::make_unique<ExpectationDiagnosticConsumer>(
@@ -221,14 +222,14 @@ TEST(FileSpecificDiagnosticConsumer, WarningsAndRemarksAreTreatedLikeErrors) {
221222
SourceLoc frontOfB = sourceMgr.getLocForBufferStart(bufferB);
222223

223224
ExpectedDiagnostic expectedA[] = {
224-
{frontOfA, "warning"},
225-
{frontOfB, "warning"},
226-
{frontOfA, "remark"},
227-
{frontOfB, "remark"},
225+
{"warning", frontOfA},
226+
{"warning", frontOfB},
227+
{"remark", frontOfA},
228+
{"remark", frontOfB},
228229
};
229230
ExpectedDiagnostic expectedUnaffiliated[] = {
230-
{frontOfB, "warning"},
231-
{frontOfB, "remark"},
231+
{"warning", frontOfB},
232+
{"remark", frontOfB},
232233
};
233234

234235
auto consumerA = llvm::make_unique<ExpectationDiagnosticConsumer>(
@@ -272,20 +273,20 @@ TEST(FileSpecificDiagnosticConsumer, NotesAreAttachedToErrors) {
272273
SourceLoc backOfB = sourceMgr.getLocForOffset(bufferB, 4);
273274

274275
ExpectedDiagnostic expectedA[] = {
275-
{frontOfA, "error"},
276-
{middleOfA, "note"},
277-
{backOfA, "note"},
278-
{frontOfB, "error"},
279-
{middleOfB, "note"},
280-
{backOfB, "note"},
281-
{frontOfA, "error"},
282-
{middleOfA, "note"},
283-
{backOfA, "note"},
276+
{"error", frontOfA},
277+
{"note", middleOfA},
278+
{"note", backOfA},
279+
{"error", frontOfB},
280+
{"note", middleOfB},
281+
{"note", backOfB},
282+
{"error", frontOfA},
283+
{"note", middleOfA},
284+
{"note", backOfA},
284285
};
285286
ExpectedDiagnostic expectedUnaffiliated[] = {
286-
{frontOfB, "error"},
287-
{middleOfB, "note"},
288-
{backOfB, "note"},
287+
{"error", frontOfB},
288+
{"note", middleOfB},
289+
{"note", backOfB},
289290
};
290291

291292
auto consumerA = llvm::make_unique<ExpectationDiagnosticConsumer>(
@@ -335,20 +336,20 @@ TEST(FileSpecificDiagnosticConsumer, NotesAreAttachedToWarningsAndRemarks) {
335336
SourceLoc backOfB = sourceMgr.getLocForOffset(bufferB, 4);
336337

337338
ExpectedDiagnostic expectedA[] = {
338-
{frontOfA, "warning"},
339-
{middleOfA, "note"},
340-
{backOfA, "note"},
341-
{frontOfB, "warning"},
342-
{middleOfB, "note"},
343-
{backOfB, "note"},
344-
{frontOfA, "remark"},
345-
{middleOfA, "note"},
346-
{backOfA, "note"},
339+
{"warning", frontOfA},
340+
{"note", middleOfA},
341+
{"note", backOfA},
342+
{"warning", frontOfB},
343+
{"note", middleOfB},
344+
{"note", backOfB},
345+
{"remark", frontOfA},
346+
{"note", middleOfA},
347+
{"note", backOfA},
347348
};
348349
ExpectedDiagnostic expectedUnaffiliated[] = {
349-
{frontOfB, "warning"},
350-
{middleOfB, "note"},
351-
{backOfB, "note"},
350+
{"warning", frontOfB},
351+
{"note", middleOfB},
352+
{"note", backOfB},
352353
};
353354

354355
auto consumerA = llvm::make_unique<ExpectationDiagnosticConsumer>(
@@ -401,17 +402,17 @@ TEST(FileSpecificDiagnosticConsumer, NotesAreAttachedToErrorsEvenAcrossFiles) {
401402
SourceLoc backOfB = sourceMgr.getLocForOffset(bufferB, 4);
402403

403404
ExpectedDiagnostic expectedA[] = {
404-
{frontOfA, "error"},
405-
{middleOfB, "note"},
406-
{backOfA, "note"},
407-
{frontOfA, "error"},
408-
{middleOfB, "note"},
409-
{backOfA, "note"},
405+
{"error", frontOfA},
406+
{"note", middleOfB},
407+
{"note", backOfA},
408+
{"error", frontOfA},
409+
{"note", middleOfB},
410+
{"note", backOfA},
410411
};
411412
ExpectedDiagnostic expectedB[] = {
412-
{frontOfB, "error"},
413-
{middleOfA, "note"},
414-
{backOfB, "note"},
413+
{"error", frontOfB},
414+
{"note", middleOfA},
415+
{"note", backOfB},
415416
};
416417

417418
auto consumerA = llvm::make_unique<ExpectationDiagnosticConsumer>(
@@ -462,20 +463,20 @@ TEST(FileSpecificDiagnosticConsumer,
462463
SourceLoc backOfB = sourceMgr.getLocForOffset(bufferB, 4);
463464

464465
ExpectedDiagnostic expectedA[] = {
465-
{frontOfA, "error"},
466-
{middleOfB, "note"},
467-
{backOfA, "note"},
468-
{frontOfB, "error"},
469-
{middleOfA, "note"},
470-
{backOfB, "note"},
471-
{frontOfA, "error"},
472-
{middleOfB, "note"},
473-
{backOfA, "note"},
466+
{"error", frontOfA},
467+
{"note", middleOfB},
468+
{"note", backOfA},
469+
{"error", frontOfB},
470+
{"note", middleOfA},
471+
{"note", backOfB},
472+
{"error", frontOfA},
473+
{"note", middleOfB},
474+
{"note", backOfA},
474475
};
475476
ExpectedDiagnostic expectedUnaffiliated[] = {
476-
{frontOfB, "error"},
477-
{middleOfA, "note"},
478-
{backOfB, "note"},
477+
{"error", frontOfB},
478+
{"note", middleOfA},
479+
{"note", backOfB},
479480
};
480481

481482
auto consumerA = llvm::make_unique<ExpectationDiagnosticConsumer>(
@@ -522,16 +523,16 @@ TEST(FileSpecificDiagnosticConsumer,
522523
SourceLoc frontOfB = sourceMgr.getLocForBufferStart(bufferB);
523524

524525
ExpectedDiagnostic expectedA[] = {
525-
{frontOfA, "error"},
526-
{SourceLoc(), "note"},
527-
{frontOfB, "error"},
528-
{SourceLoc(), "note"},
529-
{frontOfA, "error"},
530-
{SourceLoc(), "note"},
526+
{"error", frontOfA},
527+
{"note", SourceLoc()},
528+
{"error", frontOfB},
529+
{"note", SourceLoc()},
530+
{"error", frontOfA},
531+
{"note", SourceLoc()},
531532
};
532533
ExpectedDiagnostic expectedUnaffiliated[] = {
533-
{frontOfB, "error"},
534-
{SourceLoc(), "note"},
534+
{"error", frontOfB},
535+
{"note", SourceLoc()},
535536
};
536537

537538
auto consumerA = llvm::make_unique<ExpectationDiagnosticConsumer>(

0 commit comments

Comments
 (0)