Skip to content

[Coverage][MC/DC] Condition position reported at macro position #130760

Open
@ManuelvOK

Description

@ManuelvOK
Contributor

When using macros in conditions, the MC/DC report sais the position of those conditions is where the macro is.

Example:

#define ID(exp) exp

int main(void) {
    int a = 1;
    int b = 1;

    if (ID(a == 1) && b == 1) {
        return 0;
    }
    return 1;
}

The condition ID(a == 1) is located in line 7 but the MC/DC report will say it is in line 1:

    1|      2|#define ID(exp) exp
    2|       |
    3|      1|int main(void) {
    4|      1|    int a = 1;
    5|      1|    int b = 1;
    6|       |
    7|      1|    if (ID(a == 1) && b == 1) {
  ------------------
  |---> MC/DC Decision Region (7:9) to (7:29)
  |
  |  Number of Conditions: 2
  |     Condition C1 --> (1:17)
  |     Condition C2 --> (7:23)
  |
  |  Executed MC/DC Test Vectors:
  |
  |     C1, C2    Result
  |  1 { T,  T  = T      }
  |
  |  C1-Pair: not covered
  |  C2-Pair: not covered
  |  MC/DC Coverage for Decision: 0.00%
  |
  ------------------
    8|      1|        return 0;
    9|      1|    }
   10|      0|    return 1;
   11|      1|}

I would expect the report to refer to the actual position inside the decision.

Activity

evodius96

evodius96 commented on Mar 15, 2025

@evodius96
Contributor

Hmm. I think what confuses it is the fact that branch coverage (with or without MC/DC) shows the covered macro line (which contains the actual condition). If you use --show-expansions it ought to show you the expanded instance(s) of the macro, but MC/DC isn't distinguishing the expanded case. We'd have to consider what it should show.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ManuelvOK@EugeneZelenko@evodius96@llvmbot

        Issue actions

          [Coverage][MC/DC] Condition position reported at macro position · Issue #130760 · llvm/llvm-project