Skip to content

[Coverage][MC/DC] Wrong BitmapIdx calculation in getMaxBitmapSize #78922

@chapuni

Description

@chapuni

In CoverageMapping.cpp:getMaxBitmapSize,
8ecbb04#diff-44b7cba1a9d87f9ec9e067d93ea9d29ea4d9c669942d73f89233e39e28f9a5f0R565-R581

This assumes the last Decision has the maximum BitmapIdx. It is not true.
It may crashllvm-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)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions