1 // REQUIRES: x86-registered-target
2 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
3 // RUN: -interface-stub-version=experimental-tapi-elf-v1 %s | FileCheck %s
4 
5 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
6 // RUN: -interface-stub-version=experimental-tapi-elf-v1 \
7 // RUN: -DUSE_TEMPLATE_FUNCTION=1 %s | \
8 // RUN: FileCheck -check-prefix=CHECK-USES-TEMPLATE-FUNCTION %s
9 
10 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
11 // RUN: -interface-stub-version=experimental-tapi-elf-v1 \
12 // RUN: -DSPECIALIZE_TEMPLATE_FUNCTION=1 %s | \
13 // RUN: FileCheck -check-prefix=CHECK-SPECIALIZES-TEMPLATE-FUNCTION %s
14 
15 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -c \
16 // RUN: %s | llvm-nm - 2>&1 | FileCheck %s
17 
18 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -c \
19 // RUN: -DUSE_TEMPLATE_FUNCTION=1 %s | llvm-nm - 2>&1 | \
20 // RUN: FileCheck -check-prefix=CHECK-USES-TEMPLATE-FUNCTION %s
21 
22 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -c \
23 // RUN: -DSPECIALIZE_TEMPLATE_FUNCTION=1 %s | llvm-nm - 2>&1 | \
24 // RUN: FileCheck -check-prefix=CHECK-SPECIALIZES-TEMPLATE-FUNCTION %s
25 
26 // CHECK-NOT: _Z16templateFunctionIiET_S0_
27 // CHECK-USES-TEMPLATE-FUNCTION-DAG: _Z16templateFunctionIiET_S0_
28 // CHECK-SPECIALIZES-TEMPLATE-FUNCTION-DAG: _Z16templateFunctionIiET_S0_
29 template <typename T>
30 T templateFunction(T t) { return t; }
31 
32 #ifdef USE_TEMPLATE_FUNCTION
33 int FortyTwo = templateFunction<int>(42);
34 #endif
35 
36 #ifdef SPECIALIZE_TEMPLATE_FUNCTION
37 template <>
38 int templateFunction<int>(int t);
39 // TODO: Make it so that -emit-interface-stubs does not emit
40 // _Z16templateFunctionIiET_S0_ if there is no user of the specialization.
41 int foo() { return templateFunction(42); }
42 #endif
43