Skip to content

Commit 4770622

Browse files
authored
Merge pull request #62137 from hamishknight/relax-assert
2 parents 4ec4051 + 663c0b2 commit 4770622

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/SIL/IR/SILProfiler.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ namespace {
191191
template <typename F>
192192
ASTWalker::PreWalkAction
193193
visitFunctionDecl(ASTWalker &Walker, AbstractFunctionDecl *AFD, F Func) {
194-
assert(AFD->hasBody());
195194
if (Walker.Parent.isNull()) {
195+
assert(AFD->hasBody());
196196
Func();
197197
return ASTWalker::Action::Continue();
198198
}
@@ -207,14 +207,14 @@ shouldWalkIntoExpr(Expr *E, ASTWalker::ParentTy Parent, SILDeclRef Constant) {
207207
// Profiling for closures should be handled separately. Do not visit
208208
// closure expressions twice.
209209
if (auto *CE = dyn_cast<AbstractClosureExpr>(E)) {
210-
assert(CE->hasBody());
211-
212210
// A non-null parent means we have a closure child, which we will visit
213211
// separately. Even if the parent is null, don't walk into a closure if the
214212
// SILDeclRef is not for a closure, as it could be for a property
215213
// initializer instead.
216214
if (!Parent.isNull() || !Constant || !Constant.getAbstractClosureExpr())
217215
return Action::SkipChildren(E);
216+
217+
assert(CE->hasBody());
218218
}
219219
return Action::Continue(E);
220220
}

test/Profiler/rdar102405053.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// rdar://102405053 – Make sure we can handle skipped bodies at the top level.
2+
// RUN: %target-swift-frontend -emit-module -experimental-skip-non-inlinable-function-bodies-without-types -profile-generate -profile-coverage-mapping %s
3+
4+
func foo() {}

0 commit comments

Comments
 (0)