Two more QoI improvements to DI diagnostics. For enums,

diagnose failure to initialize with:
  "return from enum initializer method without storing to 'self'"
instead of:
  "variable 'self' used before being initialized"

For partially initialized super.init() calls, emit:
  "super.init not called on all paths leading to use of base object 'SomeClass'"
instead of:
  "use of base object 'SomeClass' before super.init call to initializes it on some paths"

... which didn't make any sense.



Swift SVN r11075
This commit is contained in:
Chris Lattner
2013-12-10 04:52:56 +00:00
parent 2420c48f88
commit 4b24b7f567
3 changed files with 31 additions and 9 deletions

View File

@@ -551,11 +551,25 @@ void LifetimeChecker::doIt() {
// initialization of the type.
// TODO: In the "partial" case, we can produce a more specific diagnostic
// indicating where the control flow merged.
if (getLivenessAtUse(Use) != DIKind::Yes) {
// Otherwise, this is a use of an uninitialized value. Emit a
// diagnostic.
diagnoseInitError(Use, diag::variable_used_before_initialized);
}
if (getLivenessAtUse(Use) == DIKind::Yes)
break;
// Otherwise, this is a use of an uninitialized value. Emit a
// diagnostic.
// If this is a load with a single user that is a return, then this is a
// return in the enum init case, and we haven't stored to self. Emit a
// specific diagnostic.
if (auto *LI = dyn_cast<LoadInst>(Inst))
if (TheMemory.isEnumSelf() && LI->hasOneUse() &&
isa<ReturnInst>((*LI->use_begin())->getUser())) {
if (shouldEmitError(Inst))
diagnose(Module, Inst->getLoc(),
diag::return_from_init_without_initing_self);
break;
}
diagnoseInitError(Use, diag::variable_used_before_initialized);
break;
case DIUseKind::InOutUse: