[PATCH] D23160: [Coverage] Prevent creating a redundant counter if a nested body ends with a macro.
Igor Kudrin via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 4 06:16:42 PDT 2016
ikudrin added a comment.
The motivation sample:
$ cat > test.cpp << EOF
void dummy() {}
#define MACRO dummy()
int main()
{
int i = 0;
while (i++ < 10)
if (i < 5)
MACRO;
return 0;
}
EOF
$ clang++ -fprofile-instr-generate -fcoverage-mapping dummy.cpp test.cpp
$ ./a.out
$ llvm-profdata merge -o default.profdata default.profraw
$ llvm-cov show a.out -instr-profile --show-expansions default.profdata
test.cpp:
4| 1|void dummy() {}
| 2|
14| 3|#define MACRO dummy()
| 4|
| 5|int main()
1| 6|{
1| 7| int i = 0;
11| 8| while (i++ < 10)
10| 9| if (i < 5)
4| 10| MACRO;
------------------
| | 14| 3|#define MACRO dummy()
------------------
1| 11| return 0;
1| 12|}
After applying this patch the counter for MACRO shows a reasonable value:
$ llvm-cov show a.out -instr-profile --show-expansions default.profdata
test.cpp:
4| 1|void dummy() {}
| 2|
4| 3|#define MACRO dummy()
| 4|
| 5|int main()
1| 6|{
1| 7| int i = 0;
11| 8| while (i++ < 10)
10| 9| if (i < 5)
4| 10| MACRO;
------------------
| | 4| 3|#define MACRO dummy()
------------------
1| 11| return 0;
1| 12|}
https://reviews.llvm.org/D23160
More information about the cfe-commits
mailing list