[llvm-bugs] [Bug 47301] New: clang coverage shows incorrect number of macro expansions

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 24 18:23:23 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47301

            Bug ID: 47301
           Summary: clang coverage shows incorrect number of macro
                    expansions
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zequanwu at google.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

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|}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200825/13cc15ed/attachment-0001.html>


More information about the llvm-bugs mailing list