Implement parsing, AST, (de-)serialization, and placeholder global
metadata for linking against the libraries/frameworks for imported
modules.
The module map language is extended with a new "link" directive that
specifies what library or framework to link against when a module is
imported, e.g.,
link "clangAST"
or
link framework "MyFramework"
Importing the corresponding module (or any of its submodules) will
eventually link against the named library/framework.
For now, I've added some placeholder global metadata that encodes the
imported libraries/frameworks, so that we can test that this
information gets through to the IR. The format of the data is still
under discussion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172437 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Modules/Inputs/autolink-sub.h b/test/Modules/Inputs/autolink-sub.h
new file mode 100644
index 0000000..60f9aa0
--- /dev/null
+++ b/test/Modules/Inputs/autolink-sub.h
@@ -0,0 +1 @@
+int autolink_sub(void);
diff --git a/test/Modules/Inputs/autolink-sub2.h b/test/Modules/Inputs/autolink-sub2.h
new file mode 100644
index 0000000..c3ea702
--- /dev/null
+++ b/test/Modules/Inputs/autolink-sub2.h
@@ -0,0 +1 @@
+int autolink_sub2(void);
diff --git a/test/Modules/Inputs/autolink.h b/test/Modules/Inputs/autolink.h
new file mode 100644
index 0000000..1014e29
--- /dev/null
+++ b/test/Modules/Inputs/autolink.h
@@ -0,0 +1 @@
+extern int autolink;
diff --git a/test/Modules/Inputs/module.map b/test/Modules/Inputs/module.map
index 9657c16..702f5c1 100644
--- a/test/Modules/Inputs/module.map
+++ b/test/Modules/Inputs/module.map
@@ -124,3 +124,18 @@
header "linkage-merge-sub.h"
}
}
+
+module autolink {
+ header "autolink.h"
+ link "autolink"
+
+ explicit module sub {
+ header "autolink-sub.h"
+ link "autolink_sub"
+ }
+
+ explicit module sub2 {
+ header "autolink-sub2.h"
+ link framework "autolink_framework"
+ }
+}
diff --git a/test/Modules/autolink.m b/test/Modules/autolink.m
new file mode 100644
index 0000000..e4db699
--- /dev/null
+++ b/test/Modules/autolink.m
@@ -0,0 +1,18 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -emit-llvm -o - -fmodule-cache-path %t -fmodules -F %S/Inputs -I %S/Inputs %s | FileCheck %s
+
+@import autolink.sub2;
+
+int f() {
+ return autolink_sub2();
+}
+
+@import autolink;
+
+int g() {
+ return autolink;
+}
+
+// CHECK: !llvm.link.libraries = !{![[AUTOLINK:[0-9]+]], ![[AUTOLINK_FRAMEWORK:[0-9]+]]}
+// CHECK: ![[AUTOLINK]] = metadata !{metadata !"autolink", i1 false}
+// CHECK: ![[AUTOLINK_FRAMEWORK]] = metadata !{metadata !"autolink_framework", i1 true}