Issue 78922
Summary [Coverage][MC/DC] Wrong BitmapIdx calculation in `getMaxBitmapSize`
Labels new issue
Assignees evodius96
Reporter chapuni
    In `CoverageMapping.cpp:getMaxBitmapSize`,
https://github.com/llvm/llvm-project/commit/8ecbb0404d740d1ab173554e47cef39cd5e3ef8c#diff-44b7cba1a9d87f9ec9e067d93ea9d29ea4d9c669942d73f89233e39e28f9a5f0R565-R581

This assumes the last `Decision` has the maximum `BitmapIdx`. It is not true.
It may crash`llvm-cov` with unexpected test vector. 

(https://godbolt.org/z/5bGYa8foe)
```
#define RANGE(a,b,c) ((a) <= (b) && (b) <= (c))

int foo(int c) {
  if (RANGE('A', c, 'F')) return 1;
  return ('0' <= c && c <= '9');
}
```

```
foo:
  (snip)
  Expansion,File 0, 4:7 -> 4:12 = #0 (Expanded file = 1)
  (snip)
  Decision,File 0, 5:11 -> 5:31 = M:1, C:2
  (snip)
  Decision,File 1, 1:23 -> 1:47 = M:0, C:2
 (snip)
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to