40 lines · cpp
1// REQUIRES: x86-registered-target2 3// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -o - -emit-interface-stubs %s | FileCheck %s4 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 %s8 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 %s12 13// RUN: %clang -target x86_64-unknown-linux-gnu -o - -c %s | llvm-nm - 2>&1 | count 014 15// RUN: %clang -target x86_64-unknown-linux-gnu -o - -c \16// RUN: -DUSE_TEMPLATE_FUNCTION=1 %s | llvm-nm - 2>&1 | \17// RUN: FileCheck -check-prefix=CHECK-USES-TEMPLATE-FUNCTION %s18 19// RUN: %clang -target x86_64-unknown-linux-gnu -o - -c \20// RUN: -DSPECIALIZE_TEMPLATE_FUNCTION=1 %s | llvm-nm - 2>&1 | \21// RUN: FileCheck -check-prefix=CHECK-SPECIALIZES-TEMPLATE-FUNCTION %s22 23// CHECK-NOT: _Z16templateFunctionIiET_S0_24// CHECK-USES-TEMPLATE-FUNCTION-DAG: _Z16templateFunctionIiET_S0_25// CHECK-SPECIALIZES-TEMPLATE-FUNCTION-DAG: _Z16templateFunctionIiET_S0_26template <typename T>27T templateFunction(T t) { return t; }28 29#ifdef USE_TEMPLATE_FUNCTION30int FortyTwo = templateFunction<int>(42);31#endif32 33#ifdef SPECIALIZE_TEMPLATE_FUNCTION34template <>35int templateFunction<int>(int t);36// TODO: Make it so that -emit-interface-stubs does not emit37// _Z16templateFunctionIiET_S0_ if there is no user of the specialization.38int foo() { return templateFunction(42); }39#endif40