mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[DebugInfo] Avoid applying a misleading cleanup loc in case blocks
Switch cases without a trailing curly brace have ambiguous cleanup
locations. Here's what the current stepping behavior looks like:
switch x {
case ...:
if true { foo() } // Step
else { bar() } // Step
}
The second step can be misleading, because users might think that the
else branch is taken.
rdar://35628620
This commit is contained in:
committed by
Vedant Kumar
parent
810505b759
commit
b27ed065b6
@@ -2317,7 +2317,13 @@ void PatternMatchEmission::emitCaseBody(CaseStmt *caseBlock) {
|
||||
|
||||
// Implicitly break out of the pattern match statement.
|
||||
if (SGF.B.hasValidInsertionPoint()) {
|
||||
SGF.emitBreakOutOf(CleanupLocation(caseBlock), PatternMatchStmt);
|
||||
// Case blocks without trailing braces have ambiguous cleanup locations.
|
||||
SILLocation cleanupLoc = getCompilerGeneratedLocation();
|
||||
if (auto *braces = dyn_cast<BraceStmt>(caseBlock->getBody()))
|
||||
if (braces->getNumElements() == 1 &&
|
||||
dyn_cast_or_null<DoStmt>(braces->getElement(0).dyn_cast<Stmt *>()))
|
||||
cleanupLoc = CleanupLocation(caseBlock);
|
||||
SGF.emitBreakOutOf(cleanupLoc, PatternMatchStmt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user