xref: /llvm-project/clang/test/CoverageMapping/branch-templates.cpp (revision 8b2bdfbca7c1db272e4e703445f5626b4bc4b9d3)
19f2967bcSAlan Phipps // Test that branch regions are generated for conditions in function template
29f2967bcSAlan Phipps // instantiations.
39f2967bcSAlan Phipps 
416f3401eSAlan Phipps // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name branch-templates.cpp %s | FileCheck %s
5*8b2bdfbcSAlan Phipps // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 -fcoverage-mcdc -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name branch-templates.cpp %s | FileCheck %s
69f2967bcSAlan Phipps 
79f2967bcSAlan Phipps template<typename T>
unused(T x)89f2967bcSAlan Phipps void unused(T x) {
99f2967bcSAlan Phipps   return;
109f2967bcSAlan Phipps }
119f2967bcSAlan Phipps 
129f2967bcSAlan Phipps template<typename T>
func(T x)139f2967bcSAlan Phipps int func(T x) {
149f2967bcSAlan Phipps   if(x)
159f2967bcSAlan Phipps     return 0;
169f2967bcSAlan Phipps   else
179f2967bcSAlan Phipps     return 1;
189f2967bcSAlan Phipps   int j = 1;
199f2967bcSAlan Phipps }
209f2967bcSAlan Phipps 
main()219f2967bcSAlan Phipps int main() {
229f2967bcSAlan Phipps   func<int>(0);
239f2967bcSAlan Phipps   func<bool>(true);
249f2967bcSAlan Phipps   func<float>(0.0);
259f2967bcSAlan Phipps   return 0;
269f2967bcSAlan Phipps }
279f2967bcSAlan Phipps 
289f2967bcSAlan Phipps // CHECK-LABEL: _Z4funcIiEiT_:
299f2967bcSAlan Phipps // CHECK: Branch,File 0, [[@LINE-15]]:6 -> [[@LINE-15]]:7 = #1, (#0 - #1)
309f2967bcSAlan Phipps // CHECK-LABEL: _Z4funcIbEiT_:
319f2967bcSAlan Phipps // CHECK: Branch,File 0, [[@LINE-17]]:6 -> [[@LINE-17]]:7 = #1, (#0 - #1)
329f2967bcSAlan Phipps // CHECK-LABEL: _Z4funcIfEiT_:
339f2967bcSAlan Phipps // CHECK: Branch,File 0, [[@LINE-19]]:6 -> [[@LINE-19]]:7 = #1, (#0 - #1)
34