-
Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathinlined-shadowed-clang-vs-swift.swift
64 lines (50 loc) · 1.59 KB
/
inlined-shadowed-clang-vs-swift.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/// Ensure inlined code in swiftmodules differentiates between shadowed Swift
/// and clang decls.
// RUN: %empty-directory(%t)
// RUN: split-file %s %t
// REQUIRES: objc_interop
/// Reference build: Build libs and client for a normal build.
// RUN: %target-swift-frontend -emit-module %t/RootLib.swift -I %t \
// RUN: -emit-module-path %t/RootLib.swiftmodule
// RUN: %target-swift-frontend -emit-module %t/MiddleLib.swift -I %t \
// RUN: -emit-module-path %t/MiddleLib.swiftmodule
// RUN: %target-swift-frontend -emit-sil -O %t/Client.swift -I %t > %t/Client.sil
// RUN: %FileCheck %s --input-file=%t/Client.sil
//--- module.modulemap
module RootLib {
header "RootLib.h"
}
//--- RootLib.h
#include <stdio.h>
void ShadowedFunc() {
printf("Clang\n");
}
//--- RootLib.swift
@_exported import RootLib
@usableFromInline
internal func ShadowedFunc() {
print("Swift")
}
@inlinable
@inline(__always)
public func swiftUser() {
ShadowedFunc() // Swift one
}
//--- MiddleLib.swift
import RootLib
@inlinable
@inline(__always)
public func clangUser() {
ShadowedFunc() // Clang one
}
//--- Client.swift
import RootLib
import MiddleLib
swiftUser()
// CHECK: [[SWIFT_FUNC:%.*]] = function_ref @$s7RootLib12ShadowedFuncyyF : $@convention(thin) () -> ()
// CHECK: apply [[SWIFT_FUNC]]() : $@convention(thin) () -> ()
// CHECK-NOT: apply [[SWIFT_FUNC]]() : $@convention(thin) () -> ()
clangUser()
// CHECK: [[CLANG_FUNC:%.*]] = function_ref @ShadowedFunc : $@convention(c) () -> ()
// CHECK: apply [[CLANG_FUNC]]() : $@convention(c) () -> ()
// CHECK-NOT: apply [[CLANG_FUNC]]() : $@convention(c) () -> ()