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