Skip to content

Commit 70f3290

Browse files
committed
[Diagnostic verify] Treat "{{none}}" as "no unexpected Fix-Its".
We were using "{{none}}" to mean "no Fix-Its" at all in the diagnostic verifier, which is useful but narrow. Tweak it's meaning to mean "no Fix-Its other than the ones we've explicitly checked for", which lets us verify the exact set of Fix-Its produced as part of a diagnostic rather than only matching a subset. I'll be landing some tests that rely on this shortly.
1 parent 4c87546 commit 70f3290

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/Frontend/DiagnosticVerifier.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ namespace {
4141
bool mayAppear = false;
4242

4343
// This is true if a '{{none}}' is present to mark that there should be no
44-
// fixits at all.
45-
bool noFixitsMayAppear = false;
44+
// extra fixits.
45+
bool noExtraFixitsMayAppear = false;
4646

4747
// This is the raw input buffer for the message text, the part in the
4848
// {{...}}
@@ -364,7 +364,7 @@ bool DiagnosticVerifier::verifyFile(unsigned BufferID,
364364

365365
// Special case for specifying no fixits should appear.
366366
if (FixItStr == "none") {
367-
Expected.noFixitsMayAppear = true;
367+
Expected.noExtraFixitsMayAppear = true;
368368
continue;
369369
}
370370

@@ -459,6 +459,9 @@ bool DiagnosticVerifier::verifyFile(unsigned BufferID,
459459
if (!checkForFixIt(fixit, FoundDiagnostic, InputFile))
460460
IncorrectFixit = fixit.StartLoc;
461461
}
462+
463+
bool matchedAllFixIts =
464+
expected.Fixits.size() == FoundDiagnostic.getFixIts().size();
462465

463466
// If we have any expected fixits that didn't get matched, then they are
464467
// wrong. Replace the failed fixit with what actually happened.
@@ -476,8 +479,8 @@ bool DiagnosticVerifier::verifyFile(unsigned BufferID,
476479
addError(IncorrectFixit,
477480
"expected fix-it not seen; actual fix-its: " + actual, fix);
478481
}
479-
} else if (expected.noFixitsMayAppear &&
480-
!FoundDiagnostic.getFixIts().empty() &&
482+
} else if (expected.noExtraFixitsMayAppear &&
483+
!matchedAllFixIts &&
481484
!expected.mayAppear) {
482485
// If there was no fixit specification, but some were produced, add a
483486
// fixit to add them in.

0 commit comments

Comments
 (0)