Skip to content

Malformed MC/DC Coverage record with macro definitions #77871

Closed
@chapuni

Description

@chapuni

Clang -fcoverage-mcdc emits malformed records to crash llvm-cov with assert(NumConds == 0); if:

  1. At least two decisions (passes with one decision)
  2. Each expression has terms that come from macro definitions

Reproducible code (https://godbolt.org/z/xMGPafdvG)

#define D 1

extern void bar(void);

void foo(int a, int b) {
  if (a && D) bar();
  if (b && D) bar();
}

Unexpected Branch order will be seen.

  Decision,File 0, 6:7 -> 6:13 = M:0, C:2
  Branch,File 0, 6:7 -> 6:8 = #2, (#0 - #2) [1,2,0] 
  Expansion,File 0, 6:12 -> 6:13 = #2 (Expanded file = 1)
...
  Decision,File 0, 7:7 -> 7:13 = M:1, C:2
  Branch,File 0, 7:7 -> 7:8 = #5, (#0 - #5) [1,2,0] 
  Expansion,File 0, 7:12 -> 7:13 = #5 (Expanded file = 2)
...
  Branch,File 1, 1:11 -> 1:12 = 0, 0 [2,0,0] 
...
  Branch,File 2, 1:11 -> 1:12 = 0, 0 [2,0,0] 

("Decision, branch, branch, decision, branch, branch" is expected)

Metadata

Metadata

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions