1// RUN: rm -rf %t
2// RUN: %clang_cc1 -emit-pch -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -o %t.pch -I %S/Inputs -x objective-c-header %S/Inputs/autolink-sub3.pch
3// RUN: %clang_cc1 -emit-llvm -o - -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -I %S/Inputs -include-pch %t.pch %s | FileCheck %s
4// RUN: %clang_cc1 -emit-llvm -fno-autolink -o - -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -I %S/Inputs -include-pch %t.pch %s | FileCheck --check-prefix=CHECK-AUTOLINK-DISABLED %s
5
6@import autolink.sub2;
7
8int f() {
9  return autolink_sub2();
10}
11
12@import autolink;
13
14int g() {
15  return autolink;
16}
17
18@import Module.SubFramework;
19const char *get_module_subframework() {
20  return module_subframework;
21}
22
23@import DependsOnModule.SubFramework;
24float *get_module_subframework_dep() {
25  return sub_framework;
26}
27
28@import NoUmbrella;
29int use_no_umbrella() {
30  return no_umbrella_A;
31}
32
33int use_autolink_sub3() {
34  return autolink_sub3();
35}
36
37// NOTE: "autolink_sub" is intentionally not linked.
38
39// CHECK: !llvm.module.flags = !{{{.*}}}
40// CHECK: !{{[0-9]+}} = !{i32 6, !"Linker Options", ![[AUTOLINK_OPTIONS:[0-9]+]]}
41// CHECK: ![[AUTOLINK_OPTIONS]] = !{![[AUTOLINK_PCH:[0-9]+]], ![[AUTOLINK_FRAMEWORK:[0-9]+]], ![[AUTOLINK:[0-9]+]], ![[DEPENDSONMODULE:[0-9]+]], ![[MODULE:[0-9]+]], ![[NOUMBRELLA:[0-9]+]]}
42// CHECK: ![[AUTOLINK_PCH]] = !{!"{{(\\01|-l|/DEFAULTLIB:)}}autolink_from_pch{{(\.lib)?}}"}
43// CHECK: ![[AUTOLINK_FRAMEWORK]] = !{!"-framework", !"autolink_framework"}
44// CHECK: ![[AUTOLINK]] = !{!"{{(\\01|-l|/DEFAULTLIB:)}}autolink{{(\.lib)?}}"}
45// CHECK: ![[DEPENDSONMODULE]] = !{!"-framework", !"DependsOnModule"}
46// CHECK: ![[MODULE]] = !{!"-framework", !"Module"}
47// CHECK: ![[NOUMBRELLA]] = !{!"-framework", !"NoUmbrella"}
48
49// CHECK-AUTOLINK-DISABLED: !llvm.module.flags
50// CHECK-AUTOLINK-DISABLED-NOT: "Linker Options"
51