Debug info: No longer emit debug info for variables defined in implicit

patterns.

<rdar://problem/19184859> Swift methods defining closures that capture self in the "in" clause end up with two "self" variables in the debug info

Swift SVN r24461
This commit is contained in:
Adrian Prantl
2015-01-16 00:30:14 +00:00
parent fea55d98f2
commit 897e6eaace
3 changed files with 23 additions and 3 deletions

View File

@@ -29,6 +29,7 @@
#include "swift/Basic/STLExtras.h"
#include "swift/AST/ASTContext.h"
#include "swift/AST/IRGenOptions.h"
#include "swift/AST/Pattern.h"
#include "swift/SIL/PrettyStackTrace.h"
#include "swift/SIL/SILDebugScope.h"
#include "swift/SIL/SILDeclRef.h"
@@ -2940,7 +2941,9 @@ void IRGenSILFunction::visitAllocStackInst(swift::AllocStackInst *i) {
auto addr = type.allocateStack(*this,
i->getElementType(),
dbgname);
if (IGM.DebugInfo && Decl) {
if (IGM.DebugInfo && Decl &&
(!Decl->getParentPattern() ||
!Decl->getParentPattern()->getPattern()->isImplicit())) {
// Discard any inout or lvalue qualifiers. Since the object itself
// is stored in the alloca, emitting it as a reference type would
// be wrong.

View File

@@ -2,7 +2,7 @@
// RUN: cat %t.ll | FileCheck %s
var puzzleInput = "great minds think alike"
var puzzleOutput = ""
// CHECK: [ DW_TAG_auto_variable ] [$letter$generator] [line [[@LINE+2]]]
// CHECK-NOT: [ DW_TAG_auto_variable ] [$letter$generator] [line [[@LINE+2]]]
// CHECK: [ DW_TAG_auto_variable ] [letter] [line [[@LINE+1]]]
for letter in puzzleInput {
switch letter {
@@ -16,7 +16,7 @@ println(puzzleOutput)
func count() {
// CHECK: [ DW_TAG_auto_variable ] [$i$generator] [line [[@LINE+2]]]
// CHECK-NOT: [ DW_TAG_auto_variable ] [$i$generator] [line [[@LINE+2]]]
// CHECK: [ DW_TAG_auto_variable ] [i] [line [[@LINE+1]]]
for i in 0...100 {
println(i)

View File

@@ -0,0 +1,17 @@
// RUN: %swift -primary-file %s -emit-ir -g -o - | FileCheck %s
class Foo
{
func DefinesClosure (a_string : String) -> () -> String
{
// Verify that we only emit the implicit argument,
// and not the unowned local copy of self.
//
// CHECK-NOT: [ DW_TAG_auto_variable ] [self]
// CHECK: [ DW_TAG_arg_variable ] [self]
// CHECK-NOT: [ DW_TAG_auto_variable ] [self]
return { [unowned self] in
var tmp_string = a_string
return tmp_string
}
}
}