[clang-ifs] Clang Interface Stubs, first version.
Clang interface stubs (previously referred to as clang-ifsos) is a new frontend
action in clang that allows the generation of stub files that contain mangled
name info that can be used to produce a stub library. These stub libraries can
be useful for breaking up build dependencies and controlling access to a
library's internal symbols. Generation of these stubs can be invoked by:
clang -fvisibility=<visibility> -emit-interface-stubs \
                                -interface-stub-version=<interface format>
Notice that -fvisibility (along with use of visibility attributes) can be used
to control what symbols get generated. Currently the interface format is
experimental but there are a wide range of possibilities here.
Differential Revision: https://reviews.llvm.org/D60974
llvm-svn: 363626
diff --git a/clang/test/InterfaceStubs/externstatic.c b/clang/test/InterfaceStubs/externstatic.c
new file mode 100644
index 0000000..9224581
--- /dev/null
+++ b/clang/test/InterfaceStubs/externstatic.c
@@ -0,0 +1,29 @@
+// RUN: %clang -DSTORAGE="extern" -target x86_64-unknown-linux-gnu -o - \
+// RUN: -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-yaml-elf-v1 -std=c99 -xc %s | \
+// RUN: FileCheck -check-prefix=CHECK-EXTERN %s
+// RUN: %clang -DSTORAGE="extern" -target x86_64-linux-gnu -O0 -o - -c -std=c99 \
+// RUN: -xc %s | llvm-nm - 2>&1 | FileCheck -check-prefix=CHECK-EXTERN %s
+
+// RUN: %clang -DSTORAGE="extern" -target x86_64-unknown-linux-gnu -o - \
+// RUN: -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-yaml-elf-v1 -std=c99 -xc %s | \
+// RUN: FileCheck -check-prefix=CHECK-EXTERN2 %s
+// RUN: %clang -DSTORAGE="extern" -target x86_64-linux-gnu -O0 -o - -c -std=c99 \
+// RUN: -xc %s | llvm-nm - 2>&1 | FileCheck -check-prefix=CHECK-EXTERN2 %s
+
+// RUN: %clang -DSTORAGE="static" -target x86_64-unknown-linux-gnu -o - \
+// RUN: -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-yaml-elf-v1 -std=c99 -xc %s | \
+// RUN: FileCheck -check-prefix=CHECK-STATIC %s
+// RUN: %clang -DSTORAGE="static" -target x86_64-linux-gnu -O0 -o - -c -std=c99 \
+// RUN: -xc %s | llvm-nm - 2>&1 | FileCheck -check-prefix=CHECK-STATIC %s
+
+// CHECK-EXTERN-NOT: foo
+// CHECK-STATIC-NOT: foo
+// CHECK-STATIC-NOT: bar
+
+// We want to emit extern function symbols.
+// CHECK-EXTERN2: bar
+STORAGE int foo;
+STORAGE int bar() { return 42; }