MC/DC instrumentation and Werror

Hi everyone :wave:

I was playing around a bit with -fcoverage-mcdc added in Clang 18. The docs say:

When instrumenting for Modified Condition/Decision Coverage (MC/DC) using the clang option -fcoverage-mcdc, users are limited to at most six leaf-level conditions in a boolean expression. A warning will be generated for boolean expressions that contain more than six, and they will not be instrumented for MC/DC.

If I write an expression with more than 6 conditions, I can trigger the warning :+1:t2: However, if I want to make sure that all of the code is getting instrumented, I would need to promote this warning to an error. Is that possible out of the box? Even with -Werror, the compilation succeeds :confused:

I don’t really know much about MC/DC but I do know how to poke around in the sources… it looks like MC/DC doesn’t use a defined -W group/option for this warning, so I think there’s no way to control it.

@evodius96 looks like you did this work, it seems like a reasonable request to be able to error out instead of just getting a warning?

MC/DC warnings are issued as instant warnings. I think they should be labeled.

FYI, you can try my change if you want to play further.

Awesome you are using MC/DC!

Right, presently there is no way to change the warning to error (though I initially argued this should be an error by default, but I digress). We will need to add that.

However with @chapuni 's change, clang can instrument more than six conditions, so that ought to work for you. Hopefully we can get that landed soon.

1 Like

Sorry for the long delay - life thingsā„¢ were happening :sweat_smile:

I managed to try out @chapuni’s branch today - and this looks awesome. It raises the limit enough so that in practice, there is none anymore, it makes -Werror behave as expected and (at least, in my tests) it is even a tiny bit faster, both in terms of build and execution time. Really nice work! :raised_hands:

2 Likes

By the way: This was my first time building a compiler myself. The process for clang (and the related libs and coverage postprocessing tools) was really easy to get into - kudos to everyone involved :slight_smile:

3 Likes