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