1678e19d8SPuyan Lotfi // REQUIRES: x86-registered-target 2c382d03cSPuyan Lotfi 3e782192dSPuyan Lotfi // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -o - -emit-interface-stubs %s | FileCheck %s 468f29dacSPuyan Lotfi 5e782192dSPuyan Lotfi // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -o - -emit-interface-stubs \ 668f29dacSPuyan Lotfi // RUN: -DUSE_TEMPLATE_FUNCTION=1 %s | \ 768f29dacSPuyan Lotfi // RUN: FileCheck -check-prefix=CHECK-USES-TEMPLATE-FUNCTION %s 868f29dacSPuyan Lotfi 9e782192dSPuyan Lotfi // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -o - -emit-interface-stubs \ 1068f29dacSPuyan Lotfi // RUN: -DSPECIALIZE_TEMPLATE_FUNCTION=1 %s | \ 1168f29dacSPuyan Lotfi // RUN: FileCheck -check-prefix=CHECK-SPECIALIZES-TEMPLATE-FUNCTION %s 1268f29dacSPuyan Lotfi 13*a9f0025aSFangrui Song // RUN: %clang -target x86_64-unknown-linux-gnu -o - -c %s | llvm-nm - 2>&1 | count 0 1468f29dacSPuyan Lotfi 1568f29dacSPuyan Lotfi // RUN: %clang -target x86_64-unknown-linux-gnu -o - -c \ 1668f29dacSPuyan Lotfi // RUN: -DUSE_TEMPLATE_FUNCTION=1 %s | llvm-nm - 2>&1 | \ 1768f29dacSPuyan Lotfi // RUN: FileCheck -check-prefix=CHECK-USES-TEMPLATE-FUNCTION %s 1868f29dacSPuyan Lotfi 1968f29dacSPuyan Lotfi // RUN: %clang -target x86_64-unknown-linux-gnu -o - -c \ 2068f29dacSPuyan Lotfi // RUN: -DSPECIALIZE_TEMPLATE_FUNCTION=1 %s | llvm-nm - 2>&1 | \ 2168f29dacSPuyan Lotfi // RUN: FileCheck -check-prefix=CHECK-SPECIALIZES-TEMPLATE-FUNCTION %s 2268f29dacSPuyan Lotfi 2368f29dacSPuyan Lotfi // CHECK-NOT: _Z16templateFunctionIiET_S0_ 2468f29dacSPuyan Lotfi // CHECK-USES-TEMPLATE-FUNCTION-DAG: _Z16templateFunctionIiET_S0_ 2568f29dacSPuyan Lotfi // CHECK-SPECIALIZES-TEMPLATE-FUNCTION-DAG: _Z16templateFunctionIiET_S0_ 2668f29dacSPuyan Lotfi template <typename T> templateFunction(T t)2768f29dacSPuyan LotfiT templateFunction(T t) { return t; } 2868f29dacSPuyan Lotfi 2968f29dacSPuyan Lotfi #ifdef USE_TEMPLATE_FUNCTION 3068f29dacSPuyan Lotfi int FortyTwo = templateFunction<int>(42); 3168f29dacSPuyan Lotfi #endif 3268f29dacSPuyan Lotfi 3368f29dacSPuyan Lotfi #ifdef SPECIALIZE_TEMPLATE_FUNCTION 3468f29dacSPuyan Lotfi template <> 3568f29dacSPuyan Lotfi int templateFunction<int>(int t); 3668f29dacSPuyan Lotfi // TODO: Make it so that -emit-interface-stubs does not emit 3768f29dacSPuyan Lotfi // _Z16templateFunctionIiET_S0_ if there is no user of the specialization. foo()3868f29dacSPuyan Lotfiint foo() { return templateFunction(42); } 3968f29dacSPuyan Lotfi #endif 40