diff options
author | int-zjt <zhangjiatong.0@bytedance.com> | 2025-06-20 16:24:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-20 01:24:19 -0700 |
commit | b6b8fa3b15d334c51fcf8763ccda0102a01aeb9c (patch) | |
tree | 4ed02d97005bf2c6e42e730ca8278a9e31cf2176 /clang/lib/Sema/SemaModule.cpp | |
parent | bc14e5e5e9c717a7699cf10b13a7661a9e033594 (diff) | |
download | llvm-b6b8fa3b15d334c51fcf8763ccda0102a01aeb9c.zip llvm-b6b8fa3b15d334c51fcf8763ccda0102a01aeb9c.tar.gz llvm-b6b8fa3b15d334c51fcf8763ccda0102a01aeb9c.tar.bz2 |
[llvm-cov][gcov] Support multi-files coverage in one basic block (#144504)
In the current gcov implementation, all lines within a basic block are
attributed to the source file of the block's containing function. This
is inaccurate when a block contains lines from other files (e.g., via
#include "foo.inc").
Commit
[406e81b](https://github.com/llvm/llvm-project/commit/406e81b79d26dae6838cc69d10a3e22635da09ef)
attempted to address this by filtering lines based on debug info types,
but this approach has two limitations:
* **Over-filtering**: Some valid lines belonging to the function are
incorrectly excluded.
* **Under-counting**: Lines not belonging to the function are filtered
out and omitted from coverage statistics.
**GCC Reference Behavior**
GCC's gcov implementation handles this case correctly.This change aligns
the LLVM behavior with GCC.
**Proposed Solution**
1. **GCNO Generation**:
* **Current**: Each block stores a single GCOVLines record (filename +
lines).
* **New**: Dynamically create new GCOVLines records whenever consecutive
lines in a block originate from different source files. Group subsequent
lines from the same file under one record.
2. **GCNO Parsing**:
* **Current**: Lines are directly attributed to the function's source
file.
* **New**: Introduce a GCOVLocation type to track filename/line mappings
within blocks. Statistics will reflect the actual source file for each
line.
Diffstat (limited to 'clang/lib/Sema/SemaModule.cpp')
0 files changed, 0 insertions, 0 deletions