8
8
// RUN: not %target-swift-frontend -typecheck -enable-experimental-feature Macros -load-plugin-library %t/%target-library-name(MacroDefinition) -I %swift-host-lib-dir -module-name MacroUser -DTEST_DIAGNOSTICS -serialize-diagnostics-path %t/macro_expand.dia %s
9
9
// RUN: c-index-test -read-diagnostics %t/macro_expand.dia 2>&1 | %FileCheck -check-prefix CHECK-DIAGS %s
10
10
11
+ // Debug IR testing
12
+ // RUN: %target-swift-frontend -emit-ir -enable-experimental-feature Macros -enable-experimental-feature Macros -load-plugin-library %t/%target-library-name(MacroDefinition) -I %swift-host-lib-dir %s -module-name MacroUser -o - -g | %FileCheck --check-prefix CHECK-IR %s
13
+
14
+
11
15
// Execution testing
12
- // RUN: %target-build-swift -enable-experimental-feature Macros -enable-experimental-feature Macros -load-plugin-library %t/%target-library-name(MacroDefinition) -I %swift-host-lib-dir -L %swift-host-lib-dir %s -o %t/main -module-name MacroUser
16
+ // RUN: %target-build-swift -g - enable-experimental-feature Macros -enable-experimental-feature Macros -load-plugin-library %t/%target-library-name(MacroDefinition) -I %swift-host-lib-dir -L %swift-host-lib-dir %s -o %t/main -module-name MacroUser
13
17
// RUN: %target-run %t/main | %FileCheck %s
14
18
// REQUIRES: executable_test
15
19
@@ -53,14 +57,24 @@ func testStringify(a: Int, b: Int) {
53
57
_ = ( b, b2, s2, s3)
54
58
}
55
59
56
- struct Outer {
60
+ // CHECK-IR-LABEL: define swiftcc void @"$s9MacroUser5OuterV4testyyF"
61
+ // CHECK-IR: call {{.*}}@"$sSS21_builtinStringLiteral17utf8CodeUnitCount7isASCIISSBp_BwBi1_tcfC"{{.*}}!dbg ![[STRING_LITERAL_DI:[0-9]+]]
62
+ // CHECK-IR: ![[STRING_LITERAL_DI]] = !DILocation(line: 1, column: 13, scope: ![[EXPANSION_FILE_SCOPE_DI:[0-9]+]])
63
+ // CHECK-IR: ![[EXPANSION_FILE_SCOPE_DI]] = !DILexicalBlockFile(scope: ![[EXPANSION_FILE_SCOPE_SCOPE_DI:[0-9]+]], file: ![[EXPANSION_FILE_DI:[0-9]+]], discriminator: 0)
64
+ // CHECK-IR: ![[EXPANSION_FILE_DI]] = !DIFile(filename: "{{.*}}swift-generated-sources{{.*}}.swift", directory: "")
65
+ public struct Outer {
57
66
var value : Int = 0
58
- func test( ) {
59
- _ = #stringify ( 1 + value)
67
+ public func test( ) {
68
+ let ( a , b ) = #stringify ( 1 + value)
60
69
61
- _ = #stringify ( { x in
70
+ let ( c , d ) = #stringify ( { x in
62
71
x + 1
63
72
} )
73
+
74
+ _ = a
75
+ _ = b
76
+ _ = c
77
+ _ = d
64
78
}
65
79
}
66
80
@@ -82,9 +96,9 @@ func testAddBlocker(a: Int, b: Int, c: Int, oa: OnlyAdds) {
82
96
// expected-note@-1{{in expansion of macro 'addBlocker' here}}
83
97
// expected-note@-2{{use '-'}}{{22-23=-}}
84
98
85
- // CHECK-DIAGS: macro_expand.swift:81 :7-81 :27:1:4: error: binary operator '-' cannot be applied to two 'OnlyAdds' operands [] []
99
+ // CHECK-DIAGS: macro_expand.swift:[[@LINE-4]] :7-[[@LINE-4]] :27:1:4: error: binary operator '-' cannot be applied to two 'OnlyAdds' operands [] []
86
100
// CHECK-DIAGS: CONTENTS OF FILE{{.*}}addBlocker
87
- // CHECK-DIAGS-NEXT: Original source range: {{.*}}macro_expand.swift:81 :7 - {{.*}}macro_expand.swift:81 :27
101
+ // CHECK-DIAGS-NEXT: Original source range: {{.*}}macro_expand.swift:[[@LINE-6]] :7 - {{.*}}macro_expand.swift:[[@LINE-6]] :27
88
102
// CHECK-DIAGS-NEXT: oa - oa
89
103
// CHECK-DIAGS-NEXT: END CONTENTS OF FILE
90
104
// Check recursion.
0 commit comments