Skip to content

Commit 0668289

Browse files
committed
Remove an obsolete workaround for error variables.
This is a revert of the workaround for creating debug info for error variables in b2109ab, while leaving the test added back then in place. The compiler is now emitting debug info for the error pattern binding as it's supposed to and after the recent migration to stricter debug scope generation, there are now situations where the variable added for the workaround and the correct one are in conflict. rdar://108576484
1 parent 3901219 commit 0668289

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

lib/SILGen/SILGenExpr.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,15 +1060,6 @@ SILValue SILGenFunction::emitTemporaryAllocation(SILLocation loc, SILType ty,
10601060
if (generateDebugInfo)
10611061
if (auto *VD = loc.getAsASTNode<VarDecl>())
10621062
DbgVar = SILDebugVariable(VD->isLet(), 0);
1063-
// Recognize "catch let errorvar" bindings.
1064-
if (auto *DRE = loc.getAsASTNode<DeclRefExpr>())
1065-
if (auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
1066-
if (!isa<ParamDecl>(VD) && VD->isImplicit() &&
1067-
VD->getType()->isExistentialType() &&
1068-
VD->getType()->getExistentialLayout().isErrorExistential()) {
1069-
DbgVar = SILDebugVariable(VD->isLet(), 0);
1070-
loc = SILLocation(VD);
1071-
}
10721063
auto *alloc =
10731064
B.createAllocStack(loc, ty, DbgVar, hasDynamicLifetime, isLexical, false
10741065
#ifndef NDEBUG

test/DebugInfo/catch_error.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// REQUIRES: objc_interop
2+
// RUN: %target-swift-frontend -emit-sil -Xllvm -sil-print-debuginfo %s \
3+
// RUN: -parse-as-library | %FileCheck %s
4+
import Foundation
5+
6+
open class Cache<T> {
7+
let _negativeCache: NSMutableDictionary = NSMutableDictionary()
8+
func cachedValue(creationBlock: () throws -> T) throws -> T {
9+
do {
10+
let value = try creationBlock()
11+
return value
12+
} catch {
13+
// CHECK: debug_value {{.*}} : $any Error, let, name "error", implicit, loc "{{.*}}":[[@LINE-1]]:13, scope [[SCOPE:[0-9]+]]
14+
// CHECK: alloc_stack $@opened({{.*}}, any Error) Self, loc{{.*}}, scope [[SCOPE]]
15+
16+
_negativeCache.setObject(error, forKey: NSNumber(1))
17+
throw error
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)