Skip to content

Commit cf3fdff

Browse files
committed
Simplify the definition of isExplicitClosure().
NFC.
1 parent 1abe85a commit cf3fdff

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,11 @@ static SILLocation::DebugLoc getDebugLocation(Optional<SILLocation> OptLoc,
224224

225225

226226
/// Determine whether this debug scope belongs to an explicit closure.
227-
static bool isExplicitClosure(const SILDebugScope *DS) {
228-
if (DS) {
229-
auto *SILFn = DS->getInlinedFunction();
230-
if (SILFn && SILFn->hasLocation())
231-
if (Expr *E = SILFn->getLocation().getAsASTNode<Expr>())
232-
if (isa<ClosureExpr>(E))
233-
return true;
234-
}
227+
static bool isExplicitClosure(const SILFunction *SILFn) {
228+
if (SILFn && SILFn->hasLocation())
229+
if (Expr *E = SILFn->getLocation().getAsASTNode<Expr>())
230+
if (isa<ClosureExpr>(E))
231+
return true;
235232
return false;
236233
}
237234

@@ -676,10 +673,10 @@ llvm::DISubprogram *IRGenDebugInfo::emitFunction(
676673
// Mark everything that is not visible from the source code (i.e.,
677674
// does not have a Swift name) as artificial, so the debugger can
678675
// ignore it. Explicit closures are exempt from this rule. We also
679-
// make an exception for main, which, albeit it does not
676+
// make an exception for toplevel code, which, although it does not
680677
// have a Swift name, does appear prominently in the source code.
681678
if ((Name.empty() && LinkageName != SWIFT_ENTRY_POINT_FUNCTION &&
682-
!isExplicitClosure(DS)) ||
679+
!isExplicitClosure(SILFn)) ||
683680
// ObjC thunks should also not show up in the linetable, because we
684681
// never want to set a breakpoint there.
685682
(Rep == SILFunctionTypeRepresentation::ObjCMethod) ||

0 commit comments

Comments
 (0)