Skip to content

Commit 0a9a4e7

Browse files
committed
[PlaygroundTransform] Implemented support for defer statements.
Added handling of `defer` statements in the playground transform. Tests will be added in a follow-on commit. Patch by Roman Levenstein! This addresses SR-5641/<rdar://problem/33764082>.
1 parent e45fba7 commit 0a9a4e7

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/Sema/PlaygroundTransform.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ class Instrumenter : InstrumenterBase {
126126
return S;
127127
case StmtKind::Brace:
128128
return transformBraceStmt(cast<BraceStmt>(S));
129+
case StmtKind::Defer:
130+
return transformDeferStmt(cast<DeferStmt>(S));
129131
case StmtKind::If:
130132
return transformIfStmt(cast<IfStmt>(S));
131133
case StmtKind::Guard:
@@ -153,6 +155,17 @@ class Instrumenter : InstrumenterBase {
153155
}
154156
}
155157

158+
DeferStmt *transformDeferStmt(DeferStmt *DS) {
159+
if (auto *FD = DS->getTempDecl()) {
160+
auto Implicit = FD->isImplicit();
161+
FD->setImplicit(false);
162+
auto *D = transformDecl(FD);
163+
D->setImplicit(Implicit);
164+
assert(D == FD);
165+
}
166+
return DS;
167+
}
168+
156169
// transform*() return their input if it's unmodified,
157170
// or a modified copy of their input otherwise.
158171
IfStmt *transformIfStmt(IfStmt *IS) {

0 commit comments

Comments
 (0)