@@ -64,6 +64,11 @@ To compile code with coverage enabled, pass ``-fprofile-instr-generate
6464 Note that linking together code with and without coverage instrumentation is
6565supported. Uninstrumented code simply won't be accounted for in reports.
6666
67+ To compile code with Modified Condition/Decision Coverage (MC/DC) enabled,
68+ pass ``-fcoverage-mcdc `` in addition to the clang options specified above.
69+ MC/DC is an advanced form of code coverage most applicable in the embedded
70+ space.
71+
6772Running the instrumented program
6873================================
6974
@@ -211,6 +216,10 @@ region counts:
211216 | 4| 1|}
212217 ------------------
213218
219+ If the application was instrumented for Modified Condition/Decision Coverage
220+ (MC/DC) using the clang option ``-fcoverage-mcdc ``, an MC/DC subview can be
221+ enabled using ``--show-mcdc `` that will show detailed MC/DC information for
222+ each complex condition boolean expression containing at most six conditions.
214223
215224To generate a file-level summary of coverage statistics instead of a
216225line-oriented report, try:
@@ -259,7 +268,7 @@ the exported data at a high level in the llvm-cov source code.
259268Interpreting reports
260269====================
261270
262- There are five statistics tracked in a coverage summary:
271+ There are six statistics tracked in a coverage summary:
263272
264273* Function coverage is the percentage of functions which have been executed at
265274 least once. A function is considered to be executed if any of its
@@ -288,10 +297,28 @@ There are five statistics tracked in a coverage summary:
288297 that is comprised of two individual conditions, each of which evaluates to
289298 either true or false, producing four total branch outcomes.
290299
291- Of these five statistics, function coverage is usually the least granular while
292- branch coverage is the most granular. 100% branch coverage for a function
293- implies 100% region coverage for a function. The project-wide totals for each
294- statistic are listed in the summary.
300+ * Modified Condition/Decision Coverage (MC/DC) is the percentage of individual
301+ branch conditions that have been shown to independently affect the decision
302+ outcome of the boolean expression they comprise. This is accomplished using
303+ the analysis of executed control flow through the expression (i.e. test
304+ vectors) to show that as a condition's outcome is varied between "true" and
305+ false", the decision's outcome also varies between "true" and false", while
306+ the outcome of all other conditions is held fixed (or they are masked out as
307+ unevaluatable, as happens in languages whose logical operators have
308+ short-circuit semantics). MC/DC builds on top of branch coverage and
309+ requires that all code blocks and all execution paths have been tested. This
310+ statistic is hidden by default in reports, but it can be enabled via the
311+ ``-show-mcdc-summary `` option as long as code was also compiled using the
312+ clang option ``-fcoverage-mcdc ``.
313+
314+ * Boolean expressions that are only comprised of one condition (and therefore
315+ have no logical operators) are not included in MC/DC analysis and are
316+ trivially deducible using branch coverage.
317+
318+ Of these six statistics, function coverage is usually the least granular while
319+ branch coverage (with MC/DC) is the most granular. 100% branch coverage for a
320+ function implies 100% region coverage for a function. The project-wide totals
321+ for each statistic are listed in the summary.
295322
296323Format compatibility guarantees
297324===============================
@@ -453,6 +480,21 @@ Branch coverage is tied directly to branch-generating conditions in the source
453480code. Users should not see hidden branches that aren't actually tied to the
454481source code.
455482
483+ MC/DC Instrumentation
484+ ---------------------
485+
486+ When instrumenting for Modified Condition/Decision Coverage (MC/DC) using the
487+ clang option ``-fcoverage-mcdc ``, users are limited to at most **six ** leaf-level
488+ conditions in a boolean expression. A warning will be generated for boolean
489+ expressions that contain more than six, and they will not be instrumented for
490+ MC/DC.
491+
492+ Also, if a boolean expression is embedded in the nest of another boolean
493+ expression but separated by a non-logical operator, this is also not supported.
494+ For example, in ``x = (a && b && c && func(d && f)) ``, the ``d && f `` case
495+ starts a new boolean expression that is separated from the other conditions by
496+ the operator ``func() ``. When this is encountered, a warning will be generated
497+ and the boolean expression will not be instrumented.
456498
457499Switch statements
458500-----------------
0 commit comments