11
11
// ===----------------------------------------------------------------------===//
12
12
13
13
#include " swift/AST/DiagnosticConsumer.h"
14
+ #include " swift/Basic/Located.h"
14
15
#include " swift/Basic/SourceManager.h"
15
16
#include " gtest/gtest.h"
16
17
@@ -37,7 +38,7 @@ namespace {
37
38
void handleDiagnostic (SourceManager &SM,
38
39
const DiagnosticInfo &Info) override {
39
40
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 ());
41
42
expected.erase (expected.begin ());
42
43
}
43
44
@@ -83,7 +84,7 @@ TEST(FileSpecificDiagnosticConsumer, InvalidLocDiagsGoToEveryConsumer) {
83
84
(void )sourceMgr.addMemBufferCopy (" abcde" , " A" );
84
85
(void )sourceMgr.addMemBufferCopy (" vwxyz" , " B" );
85
86
86
- ExpectedDiagnostic expected[] = { { SourceLoc (), " dummy" } };
87
+ ExpectedDiagnostic expected[] = { Located<StringRef>( " dummy" , SourceLoc ()) };
87
88
auto consumerA = llvm::make_unique<ExpectationDiagnosticConsumer>(
88
89
nullptr , expected);
89
90
auto consumerUnaffiliated = llvm::make_unique<ExpectationDiagnosticConsumer>(
@@ -116,14 +117,14 @@ TEST(FileSpecificDiagnosticConsumer, ErrorsWithLocationsGoToExpectedConsumers) {
116
117
SourceLoc backOfB = sourceMgr.getLocForOffset (bufferB, 4 );
117
118
118
119
ExpectedDiagnostic expectedA[] = {
119
- {frontOfA, " front" },
120
- {middleOfA, " middle" },
121
- {backOfA, " back" },
120
+ {" front" , frontOfA },
121
+ {" middle" , middleOfA },
122
+ {" back" , backOfA },
122
123
};
123
124
ExpectedDiagnostic expectedB[] = {
124
- {frontOfB, " front" },
125
- {middleOfB, " middle" },
126
- {backOfB, " back" }
125
+ {" front" , frontOfB },
126
+ {" middle" , middleOfB },
127
+ {" back" , backOfB }
127
128
};
128
129
129
130
auto consumerA = llvm::make_unique<ExpectationDiagnosticConsumer>(
@@ -170,17 +171,17 @@ TEST(FileSpecificDiagnosticConsumer,
170
171
SourceLoc backOfB = sourceMgr.getLocForOffset (bufferB, 4 );
171
172
172
173
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 }
179
180
};
180
181
ExpectedDiagnostic expectedUnaffiliated[] = {
181
- {frontOfB, " front" },
182
- {middleOfB, " middle" },
183
- {backOfB, " back" }
182
+ {" front" , frontOfB },
183
+ {" middle" , middleOfB },
184
+ {" back" , backOfB }
184
185
};
185
186
186
187
auto consumerA = llvm::make_unique<ExpectationDiagnosticConsumer>(
@@ -221,14 +222,14 @@ TEST(FileSpecificDiagnosticConsumer, WarningsAndRemarksAreTreatedLikeErrors) {
221
222
SourceLoc frontOfB = sourceMgr.getLocForBufferStart (bufferB);
222
223
223
224
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 },
228
229
};
229
230
ExpectedDiagnostic expectedUnaffiliated[] = {
230
- {frontOfB, " warning" },
231
- {frontOfB, " remark" },
231
+ {" warning" , frontOfB },
232
+ {" remark" , frontOfB },
232
233
};
233
234
234
235
auto consumerA = llvm::make_unique<ExpectationDiagnosticConsumer>(
@@ -272,20 +273,20 @@ TEST(FileSpecificDiagnosticConsumer, NotesAreAttachedToErrors) {
272
273
SourceLoc backOfB = sourceMgr.getLocForOffset (bufferB, 4 );
273
274
274
275
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 },
284
285
};
285
286
ExpectedDiagnostic expectedUnaffiliated[] = {
286
- {frontOfB, " error" },
287
- {middleOfB, " note" },
288
- {backOfB, " note" },
287
+ {" error" , frontOfB },
288
+ {" note" , middleOfB },
289
+ {" note" , backOfB },
289
290
};
290
291
291
292
auto consumerA = llvm::make_unique<ExpectationDiagnosticConsumer>(
@@ -335,20 +336,20 @@ TEST(FileSpecificDiagnosticConsumer, NotesAreAttachedToWarningsAndRemarks) {
335
336
SourceLoc backOfB = sourceMgr.getLocForOffset (bufferB, 4 );
336
337
337
338
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 },
347
348
};
348
349
ExpectedDiagnostic expectedUnaffiliated[] = {
349
- {frontOfB, " warning" },
350
- {middleOfB, " note" },
351
- {backOfB, " note" },
350
+ {" warning" , frontOfB },
351
+ {" note" , middleOfB },
352
+ {" note" , backOfB },
352
353
};
353
354
354
355
auto consumerA = llvm::make_unique<ExpectationDiagnosticConsumer>(
@@ -401,17 +402,17 @@ TEST(FileSpecificDiagnosticConsumer, NotesAreAttachedToErrorsEvenAcrossFiles) {
401
402
SourceLoc backOfB = sourceMgr.getLocForOffset (bufferB, 4 );
402
403
403
404
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 },
410
411
};
411
412
ExpectedDiagnostic expectedB[] = {
412
- {frontOfB, " error" },
413
- {middleOfA, " note" },
414
- {backOfB, " note" },
413
+ {" error" , frontOfB },
414
+ {" note" , middleOfA },
415
+ {" note" , backOfB },
415
416
};
416
417
417
418
auto consumerA = llvm::make_unique<ExpectationDiagnosticConsumer>(
@@ -462,20 +463,20 @@ TEST(FileSpecificDiagnosticConsumer,
462
463
SourceLoc backOfB = sourceMgr.getLocForOffset (bufferB, 4 );
463
464
464
465
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 },
474
475
};
475
476
ExpectedDiagnostic expectedUnaffiliated[] = {
476
- {frontOfB, " error" },
477
- {middleOfA, " note" },
478
- {backOfB, " note" },
477
+ {" error" , frontOfB },
478
+ {" note" , middleOfA },
479
+ {" note" , backOfB },
479
480
};
480
481
481
482
auto consumerA = llvm::make_unique<ExpectationDiagnosticConsumer>(
@@ -522,16 +523,16 @@ TEST(FileSpecificDiagnosticConsumer,
522
523
SourceLoc frontOfB = sourceMgr.getLocForBufferStart (bufferB);
523
524
524
525
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 () },
531
532
};
532
533
ExpectedDiagnostic expectedUnaffiliated[] = {
533
- {frontOfB, " error" },
534
- {SourceLoc (), " note" },
534
+ {" error" , frontOfB },
535
+ {" note" , SourceLoc () },
535
536
};
536
537
537
538
auto consumerA = llvm::make_unique<ExpectationDiagnosticConsumer>(
0 commit comments