Skip to content

Commit 89feb8f

Browse files
committed
[Diags] Remove some now unnecessary calls to flush
1 parent 45065f3 commit 89feb8f

9 files changed

+9
-42
lines changed

lib/Sema/CSApply.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5092,9 +5092,6 @@ namespace {
50925092
// If the property is settable, we don't know whether the
50935093
// user wanted the getter or setter. Provide notes for each.
50945094
if (isSettable) {
5095-
// Flush the primary diagnostic. We have notes to add.
5096-
primaryDiag.flush();
5097-
50985095
// Add notes for the getter and setter, respectively.
50995096
de.diagnose(modifierLoc, diag::expr_selector_add_modifier, false,
51005097
var)

lib/Sema/CSDiagnostics.cpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,7 +1923,6 @@ bool MissingOptionalUnwrapFailure::diagnoseAsError() {
19231923
"#default value#"
19241924
"> }");
19251925
}
1926-
diag.flush();
19271926

19281927
offerDefaultValueUnwrapFixIt(varDecl->getDeclContext(), initializer);
19291928
offerForceUnwrapFixIt(initializer);
@@ -3150,7 +3149,7 @@ void ContextualFailure::tryFixIts(InFlightDiagnostic &diagnostic) const {
31503149
if (tryIntegerCastFixIts(diagnostic))
31513150
return;
31523151

3153-
if (tryProtocolConformanceFixIt(diagnostic))
3152+
if (tryProtocolConformanceFixIt())
31543153
return;
31553154

31563155
if (tryTypeCoercionFixIt(diagnostic))
@@ -3521,8 +3520,7 @@ bool ContextualFailure::tryTypeCoercionFixIt(
35213520
return false;
35223521
}
35233522

3524-
bool ContextualFailure::tryProtocolConformanceFixIt(
3525-
InFlightDiagnostic &diagnostic) const {
3523+
bool ContextualFailure::tryProtocolConformanceFixIt() const {
35263524
auto innermostTyCtx = getDC()->getInnermostTypeContext();
35273525
if (!innermostTyCtx)
35283526
return false;
@@ -3556,8 +3554,6 @@ bool ContextualFailure::tryProtocolConformanceFixIt(
35563554
if (!shouldOfferFixIt)
35573555
return false;
35583556

3559-
diagnostic.flush();
3560-
35613557
// Let's build a list of protocols that the context does not conform to.
35623558
SmallVector<std::string, 8> missingProtoTypeStrings;
35633559
SmallVector<ProtocolDecl *, 8> missingProtocols;
@@ -4090,7 +4086,6 @@ bool SubscriptMisuseFailure::diagnoseAsError() {
40904086
} else {
40914087
diag.fixItReplace(SourceRange(memberExpr->getDotLoc(), memberExpr->getLoc()), "[<#index#>]");
40924088
}
4093-
diag.flush();
40944089

40954090
if (auto overload = getOverloadChoiceIfAvailable(locator)) {
40964091
emitDiagnosticAt(overload->choice.getDecl(), diag::kind_declared_here,
@@ -5355,8 +5350,6 @@ bool MissingArgumentsFailure::diagnoseAsError() {
53555350
diag.fixItInsertAfter(getRawAnchor().getEndLoc(), fixIt.str());
53565351
}
53575352

5358-
diag.flush();
5359-
53605353
if (auto selectedOverload = getCalleeOverloadChoiceIfAvailable(locator)) {
53615354
if (auto *decl = selectedOverload->choice.getDeclOrNull()) {
53625355
emitDiagnosticAt(decl, diag::decl_declared_here, decl);
@@ -5724,8 +5717,6 @@ bool MissingArgumentsFailure::diagnoseInvalidTupleDestructuring() const {
57245717
diagnostic.fixItRemove(TE->getLParenLoc()).fixItRemove(TE->getRParenLoc());
57255718
}
57265719

5727-
diagnostic.flush();
5728-
57295720
// Add a note which points to the overload choice location.
57305721
emitDiagnosticAt(decl, diag::decl_declared_here, decl);
57315722
return true;
@@ -6126,8 +6117,6 @@ bool ExtraneousArgumentsFailure::diagnoseAsError() {
61266117
}
61276118
}
61286119

6129-
diag.flush();
6130-
61316120
// If all of the parameters are anonymous, let's point out references
61326121
// to make it explicit where parameters are used in complex closure body,
61336122
// which helps in situations where braces are missing for potential inner
@@ -8621,8 +8610,6 @@ void MissingRawRepresentableInitFailure::fixIt(
86218610
.fixItInsert(range.Start, rawReprObjType->getString() + "(rawValue: ")
86228611
.fixItInsertAfter(range.End, ")");
86238612
} else if (valueObjType) {
8624-
diagnostic.flush();
8625-
86268613
std::string fixItBefore = RawReprType->getString() + "(rawValue: ";
86278614
std::string fixItAfter;
86288615

lib/Sema/CSDiagnostics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ class ContextualFailure : public FailureDiagnostic {
726726

727727
/// Try to add a fix-it to conform the decl context (if it's a type) to the
728728
/// protocol
729-
bool tryProtocolConformanceFixIt(InFlightDiagnostic &diagnostic) const;
729+
bool tryProtocolConformanceFixIt() const;
730730

731731
private:
732732
Type resolve(Type rawType) const {

lib/Sema/ImportResolution.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,6 @@ CheckInconsistentAccessLevelOnImport::evaluate(
11591159
error.fixItInsert(implicitImport->getStartLoc(),
11601160
diag::inconsistent_implicit_access_level_on_import_fixit,
11611161
otherAccessLevel);
1162-
error.flush();
11631162
diags.diagnose(implicitImport,
11641163
diag::inconsistent_implicit_access_level_on_import_silence);
11651164
}
@@ -1352,7 +1351,6 @@ ScopedImportLookupRequest::evaluate(Evaluator &evaluator,
13521351

13531352
emittedDiag->fixItReplace(SourceRange(import->getKindLoc()),
13541353
getImportKindString(*actualKind));
1355-
emittedDiag->flush();
13561354

13571355
if (decls.size() == 1)
13581356
ctx.Diags.diagnose(decls.front(), diag::decl_declared_here,

lib/Sema/TypeCheckAccess.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,12 +363,10 @@ void AccessControlCheckerBase::checkTypeAccess(
363363
static void highlightOffendingType(InFlightDiagnostic &diag,
364364
const TypeRepr *complainRepr) {
365365
if (!complainRepr) {
366-
diag.flush();
367366
return;
368367
}
369368

370369
diag.highlight(complainRepr->getSourceRange());
371-
diag.flush();
372370

373371
if (auto *declRefTR = dyn_cast<DeclRefTypeRepr>(complainRepr)) {
374372
const ValueDecl *VD = declRefTR->getBoundDecl();
@@ -2480,7 +2478,7 @@ class DeclAvailabilityChecker : public DeclVisitor<DeclAvailabilityChecker> {
24802478
);
24812479
if (refRange.isValid())
24822480
diag.highlight(refRange);
2483-
diag.flush();
2481+
24842482
PGD->diagnose(diag::name_declared_here, PGD->getName());
24852483
}
24862484

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,7 +2036,6 @@ static void diagnoseChangesByAccessNote(
20362036
if (fixItLoc.isInvalid())
20372037
fixItLoc = attr->getRangeWithAt().Start;
20382038
}
2039-
diag.flush();
20402039

20412040
if (!fixItLoc)
20422041
fixItLoc = VD->getAttributeInsertionLoc(true);
@@ -4028,7 +4027,6 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
40284027
nominal->getDeclaredType());
40294028
diag.highlight(extTypeRepr->getSourceRange());
40304029
if (firstNominalIsNotMostSpecific) {
4031-
diag.flush();
40324030
Type mostSpecificProtocol = extTypeNominal->getDeclaredType();
40334031
ED->diagnose(diag::composition_in_extended_type_alternative,
40344032
mostSpecificProtocol)

lib/Sema/TypeCheckPattern.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,6 @@ void repairTupleOrAssociatedValuePatternIfApplicable(
10101010
auto trailingParen = SourceRange(enumElementInnerPat->getEndLoc());
10111011
diag.fixItRemove(leadingParen).fixItRemove(trailingParen);
10121012
}
1013-
diag.flush();
10141013
addDeclNote();
10151014
enumElementInnerPat = semantic;
10161015
} else {

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4049,16 +4049,14 @@ static void diagnoseProtocolStubFixit(
40494049

40504050
// Issue diagnostics for witness types.
40514051
if (auto MissingTypeWitness = dyn_cast<AssociatedTypeDecl>(VD)) {
4052-
std::optional<InFlightDiagnostic> diag;
40534052
if (isa<BuiltinTupleDecl>(DC->getSelfNominalTypeDecl())) {
40544053
auto expectedTy = getTupleConformanceTypeWitness(DC, MissingTypeWitness);
4055-
diag.emplace(Diags.diagnose(MissingTypeWitness, diag::no_witnesses_type_tuple,
4056-
MissingTypeWitness, expectedTy));
4054+
Diags.diagnose(MissingTypeWitness, diag::no_witnesses_type_tuple,
4055+
MissingTypeWitness, expectedTy);
40574056
} else {
4058-
diag.emplace(Diags.diagnose(MissingTypeWitness, diag::no_witnesses_type,
4059-
MissingTypeWitness));
4057+
Diags.diagnose(MissingTypeWitness, diag::no_witnesses_type,
4058+
MissingTypeWitness);
40604059
}
4061-
diag.value().flush();
40624060
continue;
40634061
}
40644062

@@ -4208,7 +4206,6 @@ void ConformanceChecker::checkNonFinalClassWitness(ValueDecl *requirement,
42084206
// If the main diagnostic is emitted on the conformance, we want to
42094207
// attach the fix-it to the note that shows where the initializer is
42104208
// defined.
4211-
fixItDiag.value().flush();
42124209
fixItDiag.emplace(diags.diagnose(ctor, diag::decl_declared_here,
42134210
ctor));
42144211
}
@@ -4387,7 +4384,6 @@ ConformanceChecker::resolveWitnessViaLookup(ValueDecl *requirement) {
43874384
if (diagLoc == witness->getLoc()) {
43884385
fixDeclarationName(diag, witness, requirement->getName());
43894386
} else {
4390-
diag.flush();
43914387
diags.diagnose(witness, diag::decl_declared_here, witness);
43924388
}
43934389
}
@@ -4568,7 +4564,6 @@ ConformanceChecker::resolveWitnessViaLookup(ValueDecl *requirement) {
45684564
if (diagLoc == witness->getLoc()) {
45694565
addOptionalityFixIts(adjustments, ctx, witness, diag);
45704566
} else {
4571-
diag.flush();
45724567
diags.diagnose(witness, diag::decl_declared_here, witness);
45734568
}
45744569
}
@@ -5661,7 +5656,6 @@ void ConformanceChecker::resolveValueWitnesses() {
56615656
// If the main diagnostic is emitted on the conformance, we want
56625657
// to attach the fix-it to the note that shows where the
56635658
// witness is defined.
5664-
fixItDiag.value().flush();
56655659
fixItDiag.emplace(
56665660
witness->diagnose(diag::make_decl_objc, witness));
56675661
}
@@ -5681,7 +5675,6 @@ void ConformanceChecker::resolveValueWitnesses() {
56815675
// If the main diagnostic is emitted on the conformance, we want
56825676
// to attach the fix-it to the note that shows where the
56835677
// witness is defined.
5684-
fixItDiag.value().flush();
56855678
fixItDiag.emplace(
56865679
witness->diagnose(diag::make_decl_objc, witness));
56875680
}
@@ -5701,7 +5694,6 @@ void ConformanceChecker::resolveValueWitnesses() {
57015694
// If the main diagnostic is emitted on the conformance, we want
57025695
// to attach the fix-it to the note that shows where the
57035696
// witness is defined.
5704-
fixItDiag.value().flush();
57055697
fixItDiag.emplace(
57065698
witness->diagnose(diag::make_decl_objc, witness));
57075699
}

lib/Serialization/Deserialization.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,7 @@ ModularizationError::diagnose(const ModuleFile *MF,
255255
llvm_unreachable("Unhandled ModularizationError::Kind in switch.");
256256
};
257257

258-
auto inFlight = diagnoseError(errorKind);
259-
inFlight.limitBehavior(limit);
260-
inFlight.flush();
258+
diagnoseError(errorKind).limitBehavior(limit);
261259

262260
// We could pass along the `path` information through notes.
263261
// However, for a top-level decl a path would just duplicate the

0 commit comments

Comments
 (0)