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