mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Debug info: don't conflate generators and loop variable bindings.
<rdar://problem/17058606> for loop range variable shares name with iteration counter - that's wrong and misleading <rdar://problem/16786106> [Xcode 6.1] foreach generators are always named "$generator" Swift SVN r20683
This commit is contained in:
@@ -426,13 +426,9 @@ public:
|
|||||||
if (!getGenerator) return nullptr;
|
if (!getGenerator) return nullptr;
|
||||||
|
|
||||||
// Create a local variable to capture the generator.
|
// Create a local variable to capture the generator.
|
||||||
StringRef name = "$generator";
|
generator = new (TC.Context)
|
||||||
if (auto np = dyn_cast_or_null<NamedPattern>(S->getPattern()))
|
VarDecl(/*static*/ false, /*IsLet*/ false, S->getInLoc(),
|
||||||
name = np->getBoundName().str();
|
TC.Context.getIdentifier("$generator"), generatorTy, DC);
|
||||||
generator = new (TC.Context) VarDecl(/*static*/ false, /*IsLet*/ false,
|
|
||||||
S->getInLoc(),
|
|
||||||
TC.Context.getIdentifier(name),
|
|
||||||
generatorTy, DC);
|
|
||||||
generator->setImplicit();
|
generator->setImplicit();
|
||||||
|
|
||||||
// Create a pattern binding to initialize the generator.
|
// Create a pattern binding to initialize the generator.
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
// RUN: %swift -target x86_64-apple-macosx10.9 %s -emit-ir -g -o - | FileCheck %s
|
// RUN: %swift -target x86_64-apple-macosx10.9 %s -emit-ir -g -o - | FileCheck %s
|
||||||
var puzzleInput = "great minds think alike"
|
var puzzleInput = "great minds think alike"
|
||||||
var puzzleOutput = ""
|
var puzzleOutput = ""
|
||||||
|
// CHECK: [ DW_TAG_auto_variable ] [$generator] [line [[@LINE+2]]]
|
||||||
|
// CHECK: [ DW_TAG_auto_variable ] [letter] [line [[@LINE+1]]]
|
||||||
for letter in puzzleInput {
|
for letter in puzzleInput {
|
||||||
// CHECK: [ DW_TAG_auto_variable ] [letter] [line [[@LINE-1]]]
|
|
||||||
switch letter {
|
switch letter {
|
||||||
case "a", "e", "i", "o", "u", " ":
|
case "a", "e", "i", "o", "u", " ":
|
||||||
continue
|
continue
|
||||||
@@ -11,3 +12,13 @@ for letter in puzzleInput {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
println(puzzleOutput)
|
println(puzzleOutput)
|
||||||
|
|
||||||
|
|
||||||
|
func count() {
|
||||||
|
// CHECK: [ DW_TAG_auto_variable ] [$generator] [line [[@LINE+2]]]
|
||||||
|
// CHECK: [ DW_TAG_auto_variable ] [i] [line [[@LINE+1]]]
|
||||||
|
for i in 0...100 {
|
||||||
|
println(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
count()
|
||||||
|
|||||||
Reference in New Issue
Block a user