llvm.org GIT mirror llvm / f13ebed
[llvm-cov] Turn line numbers in html reports into clickable links git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285853 91177308-0d34-0410-b5e6-96231b3b80d8 Vedant Kumar 3 years ago
3 changed file(s) with 60 addition(s) and 58 deletion(s). Raw diff Collapse all Expand all
4444 // RUN: FileCheck -check-prefixes=HTML,HTML-WHOLE-FILE -input-file %t.html.dir/coverage/tmp/showLineExecutionCounts.cpp.html %s
4545 // RUN: FileCheck -check-prefixes=HTML,HTML-FILTER -input-file %t.html.dir/functions.html %s
4646 //
47 // HTML-WHOLE-FILE:
[[@LINE-44]]
// before

                  
                
48 // HTML-FILTER-NOT:
[[@LINE-45]]
// before

                  
                
49 // HTML:
[[@LINE-44]]
161
int main() {

                  
                
50 // HTML:
[[@LINE-44]]
161
  int x = 0

                  
                
51 // HTML:
[[@LINE-44]]
161

                  
                
52 // HTML:
[[@LINE-44]]
0
  if (x) {

                  
                
53 // HTML:
[[@LINE-44]]
0

                  
                
54 // HTML:
[[@LINE-44]]
161
  }

                  
                
55 // HTML:
[[@LINE-44]]
161
    x = 1;

                  
                
56 // HTML:
[[@LINE-44]]
161
  }

                  
                
57 // HTML:
[[@LINE-44]]
161

                  
                
58 // HTML:
[[@LINE-44]]
16.2k
  for (int i = 0; i < 100; ++i)

                  
                
59 // HTML:
[[@LINE-44]]
16.1k
    x = 1;

                  
                
60 // HTML:
[[@LINE-44]]
16.1k
  }

                  
                
61 // HTML:
[[@LINE-44]]
161

                  
                
62 // HTML:
[[@LINE-44]]
161
  x = x < 10

                  
                
63 // HTML:
[[@LINE-44]]
161
  x = x > 10

                  
                
64 // HTML:
[[@LINE-44]]
0
        x - 1:

                  
                
65 // HTML:
[[@LINE-44]]
161
        x + 1;

                  
                
66 // HTML:
[[@LINE-44]]
161

                  
                
67 // HTML:
[[@LINE-44]]
161
  return 0;

                  
                
68 // HTML:
[[@LINE-44]]
161
}

                  
                
69 // HTML-WHOLE-FILE:
[[@LINE-44]]
// after

                  
                
70 // HTML-FILTER-NOT:
[[@LINE-45]]
// after
                  
                
47 // HTML-WHOLE-FILE:
[[@LINE-44]]
// before
                  
                
48 // HTML-FILTER-NOT:
[[@LINE-45]]
// before

                  
                
49 // HTML:
[[@LINE-44]]
161
int main() {

                  
                
50 // HTML:
[[@LINE-44]]
161
  int x = 0

                  
                
51 // HTML:
[[@LINE-44]]
161

                  
                
52 // HTML:
[[@LINE-44]]
0
  if (x) {

                  
                
53 // HTML:
[[@LINE-44]]
0

                  
                
54 // HTML:
[[@LINE-44]]
161
  }

                  
                
55 // HTML:
[[@LINE-44]]
161
    x = 1;

                  
                
56 // HTML:
[[@LINE-44]]
161
  }

                  
                
57 // HTML:
[[@LINE-44]]
161

                  
                
58 // HTML:
[[@LINE-44]]
16.2k
  for (int i = 0; i < 100; ++i)

                  
                
59 // HTML:
[[@LINE-44]]
16.1k
    x = 1;

                  
                
60 // HTML:
[[@LINE-44]]
16.1k
  }

                  
                
61 // HTML:
[[@LINE-44]]
161

                  
                
62 // HTML:
[[@LINE-44]]
161
  x = x < 10

                  
                
63 // HTML:
[[@LINE-44]]
161
  x = x > 10

                  
                
64 // HTML:
[[@LINE-44]]
0
        x - 1:

                  
                
65 // HTML:
[[@LINE-44]]
161
        x + 1;

                  
                
66 // HTML:
[[@LINE-44]]
161

                  
                
67 // HTML:
[[@LINE-44]]
161
  return 0;

                  
                
68 // HTML:
[[@LINE-44]]
161
}

                  
                
69 // HTML-WHOLE-FILE:
[[@LINE-44]]
// after

                  
                
70 // HTML-FILTER-NOT:
[[@LINE-45]]
// after

                  
                
7171 //
7272 // Test index creation.
7373 // RUN: FileCheck -check-prefix=TEXT-INDEX -input-file %t.dir/index.txt %s
4444 // RUN: FileCheck -check-prefixes=HTML-SHARED,HTML-ALL -input-file=%t.html.dir/coverage/tmp/showTemplateInstantiations.cpp.html %s
4545 // RUN: FileCheck -check-prefixes=HTML-SHARED,HTML-FILTER -input-file=%t.html.dir/functions.html %s
4646
47 // HTML-ALL:
[[@LINE-44]]
// before

                  
                
48 // HTML-FILTER-NOT:
[[@LINE-45]]
// before

                  
                
49 // HTML-ALL:
[[@LINE-44]]
template<typename T>

                  
                
50 // HTML-ALL:
[[@LINE-44]]
2
int func(T x) {

                  
                
51 // HTML-ALL:
[[@LINE-44]]
2
  if(x)

                  
                
52 // HTML-ALL:
[[@LINE-44]]
1
    ret

                  
                
53 // HTML-ALL:
[[@LINE-44]]
2
  else

                  
                
54 // HTML-ALL:
[[@LINE-44]]
1
    ret

                  
                
55 // HTML-ALL:
[[@LINE-44]]
0

                  
                
56 // HTML-ALL: >
[[@LINE-44]]
2
}
                  
                
47 // HTML-ALL: href='#L[[@LINE-44]]'>
[[@LINE-44]]
// before
                  
                
48 // HTML-FILTER-NOT:
[[@LINE-45]]
// before

                  
                
49 // HTML-ALL:
[[@LINE-44]]
template<typename T>

                  
                
50 // HTML-ALL:
[[@LINE-44]]
2
int func(T x) {

                  
                
51 // HTML-ALL:
[[@LINE-44]]
2
  if(x)

                  
                
52 // HTML-ALL:
[[@LINE-44]]
1
    ret

                  
                
53 // HTML-ALL:
[[@LINE-44]]
2
  else

                  
                
54 // HTML-ALL:
[[@LINE-44]]
1
    ret

                  
                
55 // HTML-ALL:
[[@LINE-44]]
0

                  
                
56 // HTML-ALL:
[[@LINE-44]]
2
}

                  
                
5757
5858 // HTML-SHARED:
_Z4funcIbEiT_
59 // HTML-SHARED:
[[@LINE-53]]
1
int func(T x) {

                  
                
60 // HTML-SHARED:
[[@LINE-53]]
1
  if(x)

                  
                
61 // HTML-SHARED:
[[@LINE-53]]
1
    ret

                  
                
62 // HTML-SHARED:
[[@LINE-53]]
1
  else

                  
                
63 // HTML-SHARED:
[[@LINE-53]]
0

                  
                
64 // HTML-SHARED:
[[@LINE-53]]
0

                  
                
65 // HTML-SHARED: >
[[@LINE-53]]
1
}
                  
                
59 // HTML-SHARED: href='#L[[@LINE-53]]'>
[[@LINE-53]]
1
int func(T x) {
                  
                
60 // HTML-SHARED:
[[@LINE-53]]
1
  if(x)

                  
                
61 // HTML-SHARED:
[[@LINE-53]]
1
    ret

                  
                
62 // HTML-SHARED:
[[@LINE-53]]
1
  else

                  
                
63 // HTML-SHARED:
[[@LINE-53]]
0

                  
                
64 // HTML-SHARED:
[[@LINE-53]]
0

                  
                
65 // HTML-SHARED:
[[@LINE-53]]
1
}

                  
                
6666
6767 // HTML-ALL:
_Z4funcIiEiT_
6868 // HTML-FILTER-NOT:
_Z4funcIiEiT_
69 // HTML-ALL:
[[@LINE-63]]
1
int func(T x) {

                  
                
70 // HTML-ALL:
[[@LINE-63]]
1
  if(x)

                  
                
71 // HTML-ALL:
[[@LINE-63]]
0

                  
                
72 // HTML-ALL:
[[@LINE-63]]
1
  else

                  
                
73 // HTML-ALL:
[[@LINE-63]]
1
    ret

                  
                
74 // HTML-ALL:
[[@LINE-63]]
0

                  
                
75 // HTML-ALL: >
[[@LINE-63]]
1
}
                  
                
69 // HTML-ALL: href='#L[[@LINE-63]]'>
[[@LINE-63]]
1
int func(T x) {
                  
                
70 // HTML-ALL:
[[@LINE-63]]
1
  if(x)

                  
                
71 // HTML-ALL:
[[@LINE-63]]
0

                  
                
72 // HTML-ALL:
[[@LINE-63]]
1
  else

                  
                
73 // HTML-ALL:
[[@LINE-63]]
1
    ret

                  
                
74 // HTML-ALL:
[[@LINE-63]]
0

                  
                
75 // HTML-ALL:
[[@LINE-63]]
1
}

                  
                
7676
77 // HTML-ALL:
[[@LINE-44]]
1
int main() {

                  
                
78 // HTML-ALL:
[[@LINE-44]]
1
  func<int>(0);

                  
                
79 // HTML-ALL:
[[@LINE-44]]
1
  func<bool>(true);

                  
                
80 // HTML-ALL:
[[@LINE-44]]
1
  return 0;

                  
                
81 // HTML-ALL: >
[[@LINE-44]]
1
}
                  
                
77 // HTML-ALL: href='#L[[@LINE-44]]'>
[[@LINE-44]]
1
int main() {
                  
                
78 // HTML-ALL:
[[@LINE-44]]
1
  func<int>(0);

                  
                
79 // HTML-ALL:
[[@LINE-44]]
1
  func<bool>(true);

                  
                
80 // HTML-ALL:
[[@LINE-44]]
1
  return 0;

                  
                
81 // HTML-ALL:
[[@LINE-44]]
1
}

                  
                
8282
83 // HTML-ALL:
[[@LINE-45]]
// after

                  
                
84 // HTML-FILTER-NOT:
[[@LINE-46]]
// after
                  
                
83 // HTML-ALL:
[[@LINE-45]]
// after
                  
                
84 // HTML-FILTER-NOT:
[[@LINE-46]]
// after

                  
                
8585
8686 // RUN: FileCheck -check-prefix=HTML-JUMP -input-file=%t.html.dir/coverage/tmp/showTemplateInstantiations.cpp.html %s
8787 // HTML-JUMP:
Source (jump to first uncovered line)
6363
6464 // Create an anchor to \p Link with the label \p Str.
6565 std::string a(const std::string &Link, const std::string &Str,
66 const std::string &TargetType = "href") {
67 return "" + Str + "";
66 const std::string &TargetName = "") {
67 std::string Name = TargetName.empty() ? "" : ("name='" + TargetName + "' ");
68 return "" + Str + "";
6869 }
6970
7071 const char *BeginHeader =
559560 void SourceCoverageViewHTML::renderLineNumberColumn(raw_ostream &OS,
560561 unsigned LineNo) {
561562 std::string LineNoStr = utostr(uint64_t(LineNo));
562 OS << tag("td", a("L" + LineNoStr, tag("pre", LineNoStr), "name"),
563 std::string TargetName = "L" + LineNoStr;
564 OS << tag("td", a("#" + TargetName, tag("pre", LineNoStr), TargetName),
563565 "line-number");
564566 }
565567