File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,8 @@ class Instrumenter : InstrumenterBase {
52
52
return S;
53
53
case StmtKind::Brace:
54
54
return transformBraceStmt (cast<BraceStmt>(S));
55
+ case StmtKind::Defer:
56
+ return transformDeferStmt (cast<DeferStmt>(S));
55
57
case StmtKind::If:
56
58
return transformIfStmt (cast<IfStmt>(S));
57
59
case StmtKind::Guard:
@@ -282,6 +284,18 @@ class Instrumenter : InstrumenterBase {
282
284
}
283
285
return DCS;
284
286
}
287
+
288
+ DeferStmt *transformDeferStmt (DeferStmt *DS) {
289
+ if (auto *FD = DS->getTempDecl ()) {
290
+ auto Implicit = FD->isImplicit ();
291
+ FD->setImplicit (false );
292
+ auto *D = transformDecl (FD);
293
+ D->setImplicit (Implicit);
294
+ assert (D == FD);
295
+ }
296
+ return DS;
297
+
298
+ }
285
299
286
300
Decl *transformDecl (Decl *D) {
287
301
if (D->isImplicit ())
Original file line number Diff line number Diff line change
1
+ // RUN: rm -rf %t
2
+ // RUN: mkdir -p %t
3
+ // RUN: cp %s %t/main.swift
4
+ // RUN: %target-build-swift -Xfrontend -pc-macro -o %t/main %S/Inputs/PCMacroRuntime.swift %t/main.swift
5
+ // RUN: %target-run %t/main | %FileCheck %s
6
+ // RUN: %target-build-swift -Xfrontend -pc-macro -Xfrontend -playground -Xfrontend -debugger-support -o %t/main %S/Inputs/PCMacroRuntime.swift %t/main.swift %S/Inputs/SilentPlaygroundsRuntime.swift
7
+ // RUN: %target-run %t/main | %FileCheck %s
8
+ // REQUIRES: executable_test
9
+
10
+ // FIXME: rdar://problem/30234450 PCMacro tests fail on linux in optimized mode
11
+ // UNSUPPORTED: OS=linux-gnu
12
+
13
+ #sourceLocation(file: "main.swift", line: 8)
14
+ func foo( ) {
15
+ defer {
16
+ 2
17
+ }
18
+ 1
19
+ }
20
+
21
+ foo ( )
22
+
23
+ // CHECK: [15:1-15:6] pc before
24
+ // CHECK-NEXT: [8:1-8:11] pc before
25
+ // CHECK-NEXT: [8:1-8:11] pc after
26
+ // CHECK-NEXT: [12:3-12:4] pc before
27
+ // CHECK-NEXT: [12:3-12:4] pc after
28
+ // CHECK-NEXT: [10:5-10:6] pc before
29
+ // CHECK-NEXT: [10:5-10:6] pc after
30
+ // CHECK-NEXT: [15:1-15:6] pc after
You can’t perform that action at this time.
0 commit comments