llvm-project
llvm-project copied to clipboard
clang coverage shows incorrect number of macro expansions
| Bugzilla Link | 47301 |
| Version | trunk |
| OS | All |
| CC | @DougGregor,@zygoloid |
Extended Description
In the following code example, it shows the macro executed 4 times, but it should be 1. It also generates 4 identical regions, File 1, 4:15 -> 4:24 = #0 , which I believe is the cause for that.
$ clang++ -fcoverage-mapping -fprofile-instr-generate b.cpp -Xclang -dump-coverage-mapping && ./a.out && llvm-profdata merge -sparse default.profraw -o a.profdata && llvm-cov show -color ./a.out -instr-profile=a.profdata -debug-only=coverage-mapping
main:
File 0, 3:12 -> 7:2 = #0
Expansion,File 0, 5:5 -> 5:6 = #0 (Expanded file = 1)
File 1, 4:15 -> 4:24 = #0
File 1, 4:15 -> 4:24 = #0
File 1, 4:15 -> 4:24 = #0
File 1, 4:15 -> 4:24 = #0
Counter in file 0 3:12 -> 7:2, #0
Counter in file 0 5:5 -> 5:6, Expands to file 1
Counter in file 1 4:15 -> 4:24, #0
Counter in file 1 4:15 -> 4:24, #0
Counter in file 1 4:15 -> 4:24, #0
Counter in file 1 4:15 -> 4:24, #0
Emitting segments for file: /usr/local/google/home/zequanwu/llvm-project/build/master/b.cpp
Combined regions:
3:12 -> 7:2 (count=1)
4:15 -> 4:24 (count=4)
5:5 -> 5:6 (count=1)
Segment at 3:12 (count = 1), RegionEntry
Segment at 4:15 (count = 4), RegionEntry
Segment at 4:24 (count = 1)
Segment at 5:5 (count = 1), RegionEntry
Segment at 5:6 (count = 1)
Segment at 7:2 (count = 0), Skipped
1| |#include <iostream>
2| |
3| 1|int main() {
4| 4| #define O std::cout
5| 1| O << "" << "" << "";
6| 1| return 0;
7| 1|}