@@ -155,6 +155,8 @@ bool CheckerLivenessInfo::compute() {
155155 }
156156 }
157157 }
158+ // FIXME: this ignores all other forms of Borrow ownership, such as
159+ // partial_apply [onstack] and mark_dependence [nonescaping].
158160 break ;
159161 }
160162 case OperandOwnership::GuaranteedForwarding:
@@ -250,8 +252,10 @@ void ConsumeOperatorCopyableValuesChecker::emitDiagnosticForMove(
250252 diagnose (astContext, getSourceLocFromValue (borrowedValue),
251253 diag::sil_movechecking_value_used_after_consume,
252254 borrowedValueName);
253- diagnose (astContext, mvi->getLoc ().getSourceLoc (),
254- diag::sil_movechecking_consuming_use_here);
255+ if (auto sourceLoc = mvi->getLoc ().getSourceLoc ()) {
256+ diagnose (astContext, sourceLoc,
257+ diag::sil_movechecking_consuming_use_here);
258+ }
255259
256260 // Then we do a bit of work to figure out where /all/ of the later uses than
257261 // mvi are so we can emit notes to the user telling them this is a problem
@@ -281,8 +285,10 @@ void ConsumeOperatorCopyableValuesChecker::emitDiagnosticForMove(
281285 case PrunedLiveness::NonLifetimeEndingUse:
282286 case PrunedLiveness::LifetimeEndingUse:
283287 LLVM_DEBUG (llvm::dbgs () << " Emitting note for in block use: " << inst);
284- diagnose (astContext, inst.getLoc ().getSourceLoc (),
285- diag::sil_movechecking_nonconsuming_use_here);
288+ if (auto sourceLoc = inst.getLoc ().getSourceLoc ()) {
289+ diagnose (astContext, sourceLoc,
290+ diag::sil_movechecking_nonconsuming_use_here);
291+ }
286292 break ;
287293 }
288294 }
@@ -340,8 +346,10 @@ void ConsumeOperatorCopyableValuesChecker::emitDiagnosticForMove(
340346 case PrunedLiveness::LifetimeEndingUse:
341347 LLVM_DEBUG (llvm::dbgs ()
342348 << " (3) Emitting diagnostic for user: " << inst);
343- diagnose (astContext, inst.getLoc ().getSourceLoc (),
344- diag::sil_movechecking_nonconsuming_use_here);
349+ if (auto sourceLoc = inst.getLoc ().getSourceLoc ()) {
350+ diagnose (astContext, sourceLoc,
351+ diag::sil_movechecking_nonconsuming_use_here);
352+ }
345353 break ;
346354 }
347355 }
@@ -366,8 +374,10 @@ void ConsumeOperatorCopyableValuesChecker::emitDiagnosticForMove(
366374 if (livenessInfo.nonLifetimeEndingUsesInLiveOut .contains (&inst)) {
367375 LLVM_DEBUG (llvm::dbgs ()
368376 << " (1) Emitting diagnostic for user: " << inst);
369- diagnose (astContext, inst.getLoc ().getSourceLoc (),
370- diag::sil_movechecking_nonconsuming_use_here);
377+ if (auto sourceLoc = inst.getLoc ().getSourceLoc ()) {
378+ diagnose (astContext, sourceLoc,
379+ diag::sil_movechecking_nonconsuming_use_here);
380+ }
371381 continue ;
372382 }
373383
@@ -388,8 +398,10 @@ void ConsumeOperatorCopyableValuesChecker::emitDiagnosticForMove(
388398
389399 LLVM_DEBUG (llvm::dbgs ()
390400 << " (2) Emitting diagnostic for user: " << inst);
391- diagnose (astContext, inst.getLoc ().getSourceLoc (),
392- diag::sil_movechecking_nonconsuming_use_here);
401+ if (auto sourceLoc = inst.getLoc ().getSourceLoc ()) {
402+ diagnose (astContext, sourceLoc,
403+ diag::sil_movechecking_nonconsuming_use_here);
404+ }
393405 }
394406 }
395407 }
0 commit comments