Debug Info: Assign unique names to anonymous variables and arguments.

rdar://problem/18139663
This commit is contained in:
Adrian Prantl
2015-12-16 11:17:43 -08:00
parent fd6e8a9bef
commit ef84c81429
3 changed files with 60 additions and 44 deletions

View File

@@ -324,9 +324,17 @@ struct ArgumentInitVisitor :
++ArgNo;
auto PD = P->getDecl();
if (!PD->hasName()) {
ManagedValue argrv = makeArgument(P->getType(), &*f.begin(), PD);
// Emit debug information for the argument.
SILLocation loc(PD);
loc.markAsPrologue();
if (argrv.getType().isAddress())
gen.B.createDebugValueAddr(loc, argrv.getValue(), {PD->isLet(), ArgNo});
else
gen.B.createDebugValue(loc, argrv.getValue(), {PD->isLet(), ArgNo});
// A value bound to _ is unused and can be immediately released.
Scope discardScope(gen.Cleanups, CleanupLocation(P));
makeArgument(P->getType(), &*f.begin(), PD);
// Popping the scope destroys the value.
} else {
makeArgumentIntoBinding(P->getType(), &*f.begin(), PD);