• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Basic handling of line counts.
2 // RUN: llvm-profdata merge %S/Inputs/lineExecutionCounts.proftext -o %t.profdata
3 
4 // before any coverage              // WHOLE-FILE:      | [[@LINE]]|// before
5                                     // FILTER-NOT:      | [[@LINE-1]]|// before
main()6 int main() {                              // TEXT:   161| [[@LINE]]|int main(
7   int x = 0;                              // TEXT:   161| [[@LINE]]|  int x
8                                           // TEXT:   161| [[@LINE]]|
9   if (x) {                                // TEXT:     0| [[@LINE]]|  if (x)
10     x = 0;                                // TEXT:     0| [[@LINE]]|    x = 0
11   } else {                                // TEXT:   161| [[@LINE]]|  } else
12     x = 1;                                // TEXT:   161| [[@LINE]]|    x = 1
13   }                                       // TEXT:   161| [[@LINE]]|  }
14                                           // TEXT:   161| [[@LINE]]|
15   for (int i = 0; i < 100; ++i) {         // TEXT: 16.2k| [[@LINE]]|  for (
16     x = 1;                                // TEXT: 16.1k| [[@LINE]]|    x = 1
17   }                                       // TEXT: 16.1k| [[@LINE]]|  }
18                                           // TEXT:   161| [[@LINE]]|
19   x = x < 10 ? x + 1 : x - 1;             // TEXT:   161| [[@LINE]]|  x =
20   x = x > 10 ?                            // TEXT:   161| [[@LINE]]|  x =
21         x - 1:                            // TEXT:     0| [[@LINE]]|        x
22         x + 1;                            // TEXT:   161| [[@LINE]]|        x
23                                           // TEXT:   161| [[@LINE]]|
24   return 0;                               // TEXT:   161| [[@LINE]]|  return
25 }                                         // TEXT:   161| [[@LINE]]|}
26 // after coverage                   // WHOLE-FILE:      | [[@LINE]]|// after
27                                     // FILTER-NOT:      | [[@LINE-1]]|// after
28 
29 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -instr-profile %t.profdata -filename-equivalence %s | FileCheck -check-prefixes=TEXT,WHOLE-FILE %s
30 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -instr-profile %t.profdata -filename-equivalence -name=main %s | FileCheck -check-prefixes=TEXT,FILTER %s
31 
32 // Test -output-dir.
33 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -o %t.dir -instr-profile %t.profdata -filename-equivalence %s
34 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -output-dir %t.dir -instr-profile %t.profdata -filename-equivalence -name=main %s
35 // RUN: FileCheck -check-prefixes=TEXT,WHOLE-FILE -input-file %t.dir/coverage/tmp/showLineExecutionCounts.cpp.txt %s
36 // RUN: FileCheck -check-prefixes=TEXT,FILTER -input-file %t.dir/functions.txt %s
37 //
38 // Test index creation.
39 // RUN: FileCheck -check-prefix=INDEX -input-file %t.dir/index.txt %s
40 // INDEX: showLineExecutionCounts.cpp.txt
41 //
42 // Test html output.
43 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -format html -o %t.html.dir -instr-profile %t.profdata -filename-equivalence %s
44 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -format html -o %t.html.dir -instr-profile %t.profdata -filename-equivalence -name=main %s
45 // RUN: FileCheck -check-prefixes=HTML,HTML-WHOLE-FILE -input-file %t.html.dir/coverage/tmp/showLineExecutionCounts.cpp.html %s
46 // RUN: FileCheck -check-prefixes=HTML,HTML-FILTER -input-file %t.html.dir/functions.html %s
47 //
48 // HTML-WHOLE-FILE: <td class='uncovered-line'></td><td class='line-number'><pre>[[@LINE-44]]</pre></td><td class='code'><pre>// before
49 // HTML-FILTER-NOT: <td class='uncovered-line'></td><td class='line-number'><pre>[[@LINE-45]]</pre></td><td class='code'><pre>// before
50 // HTML: <td class='covered-line'><pre>161</pre></td><td class='line-number'><pre>[[@LINE-44]]</pre></td><td class='code'><pre>int main() {
51 // HTML: <td class='covered-line'><pre>161</pre></td><td class='line-number'><pre>[[@LINE-44]]</pre></td><td class='code'><pre>  int x = 0
52 // HTML: <td class='covered-line'><pre>161</pre></td><td class='line-number'><pre>[[@LINE-44]]</pre></td><td class='code'><pre>
53 // HTML: <td class='uncovered-line'><pre>0</pre></td><td class='line-number'><pre>[[@LINE-44]]</pre></td><td class='code'><pre><span class='red'>  if (x) {
54 // HTML: <td class='uncovered-line'><pre>0</pre></td><td class='line-number'><pre>[[@LINE-44]]</pre></td><td class='code'><pre>
55 // HTML: <td class='covered-line'><pre>161</pre></td><td class='line-number'><pre>[[@LINE-44]]</pre></td><td class='code'><pre><span class='red'>  }</span>
56 // HTML: <td class='covered-line'><pre>161</pre></td><td class='line-number'><pre>[[@LINE-44]]</pre></td><td class='code'><pre>    x = 1;
57 // HTML: <td class='covered-line'><pre>161</pre></td><td class='line-number'><pre>[[@LINE-44]]</pre></td><td class='code'><pre>  }
58 // HTML: <td class='covered-line'><pre>161</pre></td><td class='line-number'><pre>[[@LINE-44]]</pre></td><td class='code'><pre>
59 // HTML: <td class='covered-line'><pre>16.2k</pre></td><td class='line-number'><pre>[[@LINE-44]]</pre></td><td class='code'><pre>  for (int i = 0; i &lt; 100; ++i)
60 // HTML: <td class='covered-line'><pre>16.1k</pre></td><td class='line-number'><pre>[[@LINE-44]]</pre></td><td class='code'><pre>    x = 1;
61 // HTML: <td class='covered-line'><pre>16.1k</pre></td><td class='line-number'><pre>[[@LINE-44]]</pre></td><td class='code'><pre>  }
62 // HTML: <td class='covered-line'><pre>161</pre></td><td class='line-number'><pre>[[@LINE-44]]</pre></td><td class='code'><pre>
63 // HTML: <td class='covered-line'><pre>161</pre></td><td class='line-number'><pre>[[@LINE-44]]</pre></td><td class='code'><pre>  x = x &lt; 10
64 // HTML: <td class='covered-line'><pre>161</pre></td><td class='line-number'><pre>[[@LINE-44]]</pre></td><td class='code'><pre>  x = x &gt; 10
65 // HTML: <td class='uncovered-line'><pre>0</pre></td><td class='line-number'><pre>[[@LINE-44]]</pre></td><td class='code'><pre><span class='red'>        x - 1:
66 // HTML: <td class='covered-line'><pre>161</pre></td><td class='line-number'><pre>[[@LINE-44]]</pre></td><td class='code'><pre>        x + 1;
67 // HTML: <td class='covered-line'><pre>161</pre></td><td class='line-number'><pre>[[@LINE-44]]</pre></td><td class='code'><pre>
68 // HTML: <td class='covered-line'><pre>161</pre></td><td class='line-number'><pre>[[@LINE-44]]</pre></td><td class='code'><pre>  return 0;
69 // HTML: <td class='covered-line'><pre>161</pre></td><td class='line-number'><pre>[[@LINE-44]]</pre></td><td class='code'><pre>}
70 // HTML-WHOLE-FILE: <td class='uncovered-line'></td><td class='line-number'><pre>[[@LINE-44]]</pre></td><td class='code'><pre>// after
71 // HTML-FILTER-NOT: <td class='uncovered-line'></td><td class='line-number'><pre>[[@LINE-45]]</pre></td><td class='code'><pre>// after
72