236 Commits

Author SHA1 Message Date
int-zjt
f4cf610159
[Coverage] Add gap region between binary operator '&& and ||' and RHS (#149085)
## Issue Summary
We identified an inaccuracy in line coverage reporting when short-circuit evaluation occurs in multi-line conditional expressions.

Specifically:
1. Un-executed conditions following line breaks may be incorrectly marked as covered
(e.g., conditionB in a non-executed && chain shows coverage)
```
    1|       |#include <iostream>
    2|       |
    3|      1|int main() {
    4|      1|    bool conditionA = false;
    5|      1|    bool conditionB = true;
    6|      1|    if (conditionA &&
    7|      1|        conditionB) {
    8|      0|        std::cout << "IF-THEN" << std::endl;
    9|      0|    }
   10|      1|    return 0;
   11|      1|}
```
2. Inconsistent coverage reporting across un-executed conditions
*(adjacent un-executed conditions may show 1 vs 0 line coverage)*
```
    1|       |#include <iostream>
    2|       |
    3|      1|int main() {
    4|      1|    bool conditionA = false;
    5|      1|    bool conditionB = true;
    6|      1|    bool conditionC = true;
    7|      1|    if (conditionA &&
    8|      1|        (conditionB ||
    9|      0|        conditionC)) {
   10|      0|        std::cout << "IF-THEN" << std::endl;
   11|      0|    }
   12|      1|    return 0;
   13|      1|}
```

This is resolved by inserting a GapRegion when mapping logical operators to isolate coverage contexts around short-circuit evaluation.
2025-08-08 12:50:52 -05:00
Steven Wu
3c08498fe2
[clang][CodeGen] Remove CWD fallback in compilation directory (#150130)
CWD is queried in clang driver and passed to clang cc1 via flags when
needed. Respect the cc1 flags and do not repeated checking current
working directory in CodeGen.
2025-07-31 16:32:44 -07:00
Ethan Luis McDonough
67ff66e677
[PGO][Offload] Fix offload coverage mapping (#143490)
This pull request fixes coverage mapping on GPU targets. 

- It adds an address space cast to the coverage mapping generation pass.
- It reads the profiled function names from the ELF directly. Reading it
from public globals was causing issues in cases where multiple
device-code object files are linked together.
2025-06-10 20:19:38 -05:00
Nikita Popov
e2b536431d
[CodeGen] Move CodeGenPGO behind unique_ptr (NFC) (#142155)
The InstrProf headers are very expensive. Avoid including them in all of
CodeGen/ by moving the CodeGenPGO member behind a unqiue_ptr.

This reduces clang build time by 0.8%.
2025-06-02 09:51:54 +02:00
Justin Cady
025639bc39
[Coverage] Fix mapping for do-while loops with terminating statements (#139777)
The current region mapping for do-while loops that contain statements
such as break or continue results in inaccurate line coverage reports
for the line following the loop.

This change handles terminating statements the same way that other loop
constructs do, correcting the region mapping for accurate reports. It
also fixes a fragile test relying on exact line numbers.

Fixes #139122
2025-05-19 15:49:26 -04:00
Justin Cady
954a3de783
Reland [Coverage] Fix region termination for GNU statement expressions (#132222)
Relands #130976 with adjustments to test requirements.

Calls to __noreturn__ functions result in region termination for
coverage mapping. But this creates incorrect coverage results when
__noreturn__ functions (or other constructs that result in region
termination) occur within [GNU statement expressions][1].

In this scenario an extra gap region is introduced within VisitStmt,
such that if the following line does not introduce a new region it
is unconditionally counted as uncovered.

This change adjusts the mapping such that terminate statements
within statement expressions do not propagate that termination
state after the statement expression is processed.

[1]: https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html

Fixes #124296
2025-03-21 11:59:01 -04:00
Justin Cady
bd2d8c0a7e
Revert "[Coverage] Fix region termination for GNU statement expressions" (#132095)
Reverts llvm/llvm-project#130976

Breaks clang-cmake-x86_64-avx512-linux bot.
2025-03-19 16:48:34 -04:00
Justin Cady
0827e3aae6
[Coverage] Fix region termination for GNU statement expressions (#130976)
Calls to __noreturn__ functions result in region termination for
coverage mapping. But this creates incorrect coverage results when
__noreturn__ functions (or other constructs that result in region
termination) occur within [GNU statement expressions][1].

In this scenario an extra gap region is introduced within VisitStmt,
such that if the following line does not introduce a new region it
is unconditionally counted as uncovered.

This change adjusts the mapping such that terminate statements
within statement expressions do not propagate that termination
state after the statement expression is processed.

[1]: https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html

Fixes #124296
2025-03-19 16:22:26 -04:00
NAKAMURA Takumi
397ac44f62
[Coverage] Introduce the type CounterPair for RegionCounterMap. NFC. (#112724)
`CounterPair` can hold `<uint32_t, uint32_t>` instead of current
`unsigned`, to hold also the counter number of SkipPath. For now, this
change provides the skeleton and only `CounterPair::Executed` is used.

Each counter number can have `None` to suppress emitting counter
increment. 2nd element `Skipped` is initialized as `None` by default,
since most `Stmt*` don't have a pair of counters.

This change also provides stubs for the verifier. I'll provide the impl
of verifier for `+Asserts` later.

`markStmtAsUsed(bool, Stmt*)` may be used to inform that other side
counter may not emitted.

`markStmtMaybeUsed(S)` may be used for the `Stmt` and its inner will be
excluded for emission in the case of skipping by constant folding. I put
it into places where I found.

`verifyCounterMap()` will check the coverage map and the counter map,
and can be used to report inconsistency.

These verifier methods shall be eliminated in `-Asserts`.


https://discourse.llvm.org/t/rfc-integrating-singlebytecoverage-with-branch-coverage/82492
2025-01-09 17:11:07 +09:00
NAKAMURA Takumi
f5cd181ffb
[Coverage] Introduce getBranchCounterPair(). NFC. (#112702)
This aggregates the generation of branch counter pair as `ExecCnt` and
`SkipCnt`, to aggregate `CounterExpr::subtract`. At the moment:

- This change preserves the behavior of
`llvm::EnableSingleByteCoverage`. Almost of SingleByteCoverage will be
cleaned up by coming commits.

- `IsCounterEqual(Out, Par)` is introduced instead of
`Counter::operator==`. Tweaks would be required for the comparison for
additional counters.


https://discourse.llvm.org/t/rfc-integrating-singlebytecoverage-with-branch-coverage/82492
2025-01-09 16:47:01 +09:00
NAKAMURA Takumi
ef95590830
[Coverage] Resurrect Branch:FalseCnt in SwitchStmt that was pruned in #112694 (#120418)
I missed that FalseCnt for each Case was used to calculate percentage in
the SwitchStmt. At the moment I resurrect them.

In `!HasDefaultCase`, the pair of Counters shall be `[CaseCountSum,
FalseCnt]`. (Reversal of before #112694)
I think it can be considered as the False count on SwitchStmt.

FalseCnt shall be folded (same as current impl) in the coming
SingleByteCoverage changes, since percentage would not make sense.
2024-12-19 08:41:07 +09:00
NAKAMURA Takumi
5a5838fba3 Introduce CounterMappingRegion::isBranch(). NFC. 2024-12-18 20:00:02 +09:00
Kazu Hirata
e8a6624325
[CodeGen] Remove unused includes (NFC) (#116459)
Identified with misc-include-cleaner.
2024-11-16 07:37:13 -08:00
Jay Foad
4dd55c567a
[clang] Use {} instead of std::nullopt to initialize empty ArrayRef (#109399)
Follow up to #109133.
2024-10-24 10:23:40 +01:00
NAKAMURA Takumi
4a011ac84f
[Coverage] Introduce "partial fold" on BranchRegion (#112694)
Currently both True/False counts were folded. It lost the information,
"It is True or False before folding." It prevented recalling branch
counts in merging template instantiations.

In `llvm-cov`, a folded branch is shown as:

- `[True: n, Folded]`
- `[Folded, False n]`

In the case If `n` is zero, a branch is reported as "uncovered". This is
distinguished from "folded" branch. When folded branches are merged,
`Folded` may be dissolved.

In the coverage map, either `Counter` is `Zero`. Currently both were
`Zero`.

Since "partial fold" has been introduced, either case in `switch` is
omitted as `Folded`.

Each `case:` in `switch` is reported as `[True: n, Folded]`, since
`False` count doesn't show meaningful value.

When `switch` doesn't have `default:`, `switch (Cond)` is reported as
`[Folded, False: n]`, since `True` count was just the sum of `case`(s).
`switch` with `default` can be considered as "the statement that doesn't
have any `False`(s)".
2024-10-20 12:30:35 +09:00
NAKAMURA Takumi
5bcc66dc00 VisitIfStmt: Prune a redundant condition.
`S->isConsteval()` is evaluated at the top of this method.
Likely mis-merging in #75425
2024-10-17 20:04:00 +09:00
Kazu Hirata
08085eddfd
[CodeGen] Avoid repeated hash lookups (NFC) (#107759) 2024-09-08 09:04:20 -07:00
NAKAMURA Takumi
48017579e5 Move SystemHeadersCoverage into llvm::coverage in CoverageMappingGen.h
Part of #97952
2024-07-09 22:21:20 +09:00
NAKAMURA Takumi
71f8b441ed Reapply: [MC/DC][Coverage] Loosen the limit of NumConds from 6 (#82448)
By storing possible test vectors instead of combinations of conditions,
the restriction is dramatically relaxed.

This introduces two options to `cc1`:

* `-fmcdc-max-conditions=32767`
* `-fmcdc-max-test-vectors=2147483646`

This change makes coverage mapping, profraw, and profdata incompatible
with Clang-18.

- Bitmap semantics changed. It is incompatible with previous format.
- `BitmapIdx` in `Decision` points to the end of the bitmap.
- Bitmap is packed per function.
- `llvm-cov` can understand `profdata` generated by `llvm-profdata-18`.

RFC:
https://discourse.llvm.org/t/rfc-coverage-new-algorithm-and-file-format-for-mc-dc/76798

--
Change(s) since llvmorg-19-init-14288-g7ead2d8c7e91

- Update compiler-rt/test/profile/ContinuousSyncMode/image-with-mcdc.c
2024-06-14 19:31:56 +09:00
Hans Wennborg
b422fa6b62 Revert "[MC/DC][Coverage] Loosen the limit of NumConds from 6 (#82448)"
This broke the lit tests on Mac:
https://green.lab.llvm.org/job/llvm.org/job/clang-stage1-RA/1096/

> By storing possible test vectors instead of combinations of conditions,
> the restriction is dramatically relaxed.
>
> This introduces two options to `cc1`:
>
> * `-fmcdc-max-conditions=32767`
> * `-fmcdc-max-test-vectors=2147483646`
>
> This change makes coverage mapping, profraw, and profdata incompatible
> with Clang-18.
>
> - Bitmap semantics changed. It is incompatible with previous format.
> - `BitmapIdx` in `Decision` points to the end of the bitmap.
> - Bitmap is packed per function.
> - `llvm-cov` can understand `profdata` generated by `llvm-profdata-18`.
>
> RFC:
> https://discourse.llvm.org/t/rfc-coverage-new-algorithm-and-file-format-for-mc-dc/76798

This reverts commit 7ead2d8c7e9114b3f23666209a1654939987cb30.
2024-06-14 10:47:41 +02:00
NAKAMURA Takumi
7ead2d8c7e
[MC/DC][Coverage] Loosen the limit of NumConds from 6 (#82448)
By storing possible test vectors instead of combinations of conditions,
the restriction is dramatically relaxed.

This introduces two options to `cc1`:

* `-fmcdc-max-conditions=32767`
* `-fmcdc-max-test-vectors=2147483646`

This change makes coverage mapping, profraw, and profdata incompatible
with Clang-18.

- Bitmap semantics changed. It is incompatible with previous format.
- `BitmapIdx` in `Decision` points to the end of the bitmap.
- Bitmap is packed per function.
- `llvm-cov` can understand `profdata` generated by `llvm-profdata-18`.

RFC:
https://discourse.llvm.org/t/rfc-coverage-new-algorithm-and-file-format-for-mc-dc/76798
2024-06-13 20:09:02 +09:00
Andrey Ali Khan Bolshakov
6be1a1535e
[clang][c++20] Fix code coverage mapping crash with generalized NTTPs (#85837)
Introduced in #78041, originally reported as #79957 and fixed partially
in #80050.

`OpaqueValueExpr` used with `TemplateArgument::StructuralValue` has no
corresponding source expression.

A test case with subobject-referring NTTP added.
2024-05-24 13:04:18 -07:00
Wentao Zhang
f9e9e599c0
[Coverage][Expansion] handle nested macros in scratch space (#89869)
The problematic program is as follows:

```shell
#define pre_a 0
#define PRE(x) pre_##x

void f(void) {
    PRE(a) && 0;
}

int main(void) { return 0; }
```

in which after token concatenation (`##`), there's another nested macro
`pre_a`.

Currently only the outer expansion region will be produced. ([compiler
explorer
link](https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:___c,selection:(endColumn:29,endLineNumber:8,positionColumn:29,positionLineNumber:8,selectionStartColumn:29,selectionStartLineNumber:8,startColumn:29,startLineNumber:8),source:'%23define+pre_a+0%0A%23define+PRE(x)+pre_%23%23x%0A%0Avoid+f(void)+%7B%0A++++PRE(a)+%26%26+0%3B%0A%7D%0A%0Aint+main(void)+%7B+return+0%3B+%7D'),l:'5',n:'0',o:'C+source+%231',t:'0')),k:51.69491525423727,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((g:!((h:compiler,i:(compiler:cclang_assertions_trunk,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'0',intel:'0',libraryCode:'1',trim:'1',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:2,lang:___c,libs:!(),options:'-fprofile-instr-generate+-fcoverage-mapping+-fcoverage-mcdc+-Xclang+-dump-coverage-mapping+',overrides:!(),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+x86-64+clang+(assertions+trunk)+(Editor+%231)',t:'0')),k:34.5741843594503,l:'4',m:28.903654485049834,n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compilerName:'x86-64+clang+(trunk)',editorid:1,fontScale:14,fontUsePx:'0',j:2,wrap:'1'),l:'5',n:'0',o:'Output+of+x86-64+clang+(assertions+trunk)+(Compiler+%232)',t:'0')),header:(),l:'4',m:71.09634551495017,n:'0',o:'',s:0,t:'0')),k:48.30508474576271,l:'3',n:'0',o:'',t:'0')),l:'2',m:100,n:'0',o:'',t:'0')),version:4))

```text
f:
  File 0, 4:14 -> 6:2 = #0
  Decision,File 0, 5:5 -> 5:16 = M:0, C:2
  Expansion,File 0, 5:5 -> 5:8 = #0 (Expanded file = 1)
  File 0, 5:15 -> 5:16 = #1
  Branch,File 0, 5:15 -> 5:16 = 0, 0 [2,0,0] 
  File 1, 2:16 -> 2:23 = #0
  File 2, 1:15 -> 1:16 = #0
  File 2, 1:15 -> 1:16 = #0
  Branch,File 2, 1:15 -> 1:16 = 0, 0 [1,2,0] 
```

The inner expansion region isn't produced because:

1. In the range-based for loop quoted below, each sloc is processed and
possibly emit a corresponding expansion region.
2. For our sloc in question, its direct parent returned by
`getIncludeOrExpansionLoc()` is a `<scratch space>`, because that's how
`##` is processed.


88b6186af3/clang/lib/CodeGen/CoverageMappingGen.cpp (L518-L520)

3. This `<scratch space>` cannot be found in the FileID mapping so
`ParentFileID` will be assigned an `std::nullopt`


88b6186af3/clang/lib/CodeGen/CoverageMappingGen.cpp (L521-L526)

4. As a result this iteration of for loop finishes early and no
expansion region is added for the sloc.

This problem gets worse with MC/DC: as the example shows, there's a
branch from File 2 but File 2 itself is missing. This will trigger
assertion failures.

The fix is more or less a workaround and takes a similar approach as
#89573.

~~Depends on #89573.~~ This includes #89573. Kudos to @chapuni!
This and #89573 together fix #87000: I tested locally, both the reduced
program and my original use case (fwiw, Linux kernel) can run
successfully.

---------

Co-authored-by: NAKAMURA Takumi <geek4civic@gmail.com>
2024-05-24 12:06:43 +09:00
NAKAMURA Takumi
896bceb953
[MC/DC][Coverage] Add assertions into emitSourceRegions() (#89572)
`emitSourceRegions()` has bugs to emit malformed MC/DC coverage
mappings. They were detected in `llvm-cov` as the crash.

Detect inconsistencies earlier in `clang` with assertions.

* mcdc-scratch-space.c covers #87000.
2024-05-23 13:57:12 +09:00
NAKAMURA Takumi
702a2b627f
[Coverage] Rework !SystemHeadersCoverage (#91446)
- Introduce `LeafExprSet`,
  - Suppress traversing LAnd and LOr expr under system headers.
- Handle LAnd and LOr as instrumented leaves to override
`!isInstrumentedCondition(C)`.
- Replace Loc with FileLoc if it is expanded with system headers.

Fixes #78920
2024-05-20 18:06:03 +09:00
Andrey Ali Khan Bolshakov
5ff6c6542a
[Coverage] Handle array decomposition correctly (#88881)
`ArrayInitLoopExpr` AST node has two occurences of its as-written
initializing expression in its subexpressions through a non-unique
`OpaqueValueExpr`. It causes double-visiting of the initializing
expression if not handled explicitly, as discussed in #85837.
2024-05-15 15:40:03 -07:00
Andrey Ali Khan Bolshakov
050593fc4f
[Coverage] Handle CoroutineSuspendExpr correctly (#88898)
This avoids visiting `co_await` or `co_yield` operand 5 times (it is
repeated under transformed awaiter subexpression, and under
`await_ready`, `await_suspend`, and `await_resume` generated call
subexpressions).
2024-05-15 15:39:12 -07:00
NAKAMURA Takumi
2a61eebc66 Cleanup asserts in BranchParameters and DecisionParameters 2024-05-10 16:00:16 +09:00
Wentao Zhang
c1b6cca121
[clang][CoverageMapping] do not emit a gap region when either end doesn't have valid source locations (#89564)
Fixes #86998
2024-04-22 12:37:38 -05:00
Andrey Ali Khan Bolshakov
949e66baf1
[Coverage][NFC] Avoid visiting non-unique OpaqueValueExpr (#88910)
Only unique `OpaqueValueExpr`s should be handled in the mapping builder,
as
[discussed](https://github.com/llvm/llvm-project/pull/85837#discussion_r1542056451)
in #85837. However, `getCond()` returns non-unique `OpaqueValueExpr` for
`BinaryConditionalOperator` (because it is also used as the "true"
branch expression). Use `getCommon()` instead so as to bypass the
`OpaqueValueExpr`.
2024-04-18 17:04:26 -07:00
gulfemsavrun
23f895f656
[InstrProf] Single byte counters in coverage (#75425)
This patch inserts 1-byte counters instead of an 8-byte counters into
llvm profiles for source-based code coverage. The origial idea was
proposed as block-cov for PGO, and this patch repurposes that idea for
coverage: https://groups.google.com/g/llvm-dev/c/r03Z6JoN7d4

The current 8-byte counters mechanism add counters to minimal regions,
and infer the counters in the remaining regions via adding or
subtracting counters. For example, it infers the counter in the if.else
region by subtracting the counters between if.entry and if.then regions
in an if statement. Whenever there is a control-flow merge, it adds the
counters from all the incoming regions. However, we are not going to be
able to infer counters by subtracting two execution counts when using
single-byte counters. Therefore, this patch conservatively inserts
additional counters for the cases where we need to add or subtract
counters.

RFC:
https://discourse.llvm.org/t/rfc-single-byte-counters-for-source-based-code-coverage/75685
2024-02-26 14:44:55 -08:00
NAKAMURA Takumi
0c7a605ada clangCodeGen: [MC/DC] Refactor CoverageGen.
- Introduce `createDecision(E)` for the root node of `VisitBin`.
- Handle `mcdc::DecisionParameters` for each Decision method.
2024-02-26 16:44:19 +09:00
NAKAMURA Takumi
1f6a347c8a Refactor: Let MCDC::State have DecisionByStmt and BranchByStmt
- Prune `RegionMCDCBitmapMap` and `RegionCondIDMap`. They are handled
  by `MCDCState`.
- Rename `s/BitmapMap/DecisionByStmt/`. It can handle Decision stuff.
- Rename `s/CondIDMap/BranchByStmt/`. It can be handle Branch stuff.
- `MCDCRecordProcessor`: Use `DecisionParams.BitmapIdx` directly.
2024-02-25 18:33:53 +09:00
David Tellenbach
dc94eb57e3
[clang][CodeCoverage] Fix CoverageMapping for binary conditionals ops (#82141)
Fix an issue that produces a wrong coverage mapping when using binary
conditional operators as show in the example below.

Before this patch:

    1|      1|int binary_cond(int x) {
    2|      1|  x = x ?: 4;
    3|      1|  int y = 0;
    4|      0|  return x;       <-- Not covered
    5|      1|}

After this patch:

    1|      1|int binary_cond(int x) {
    2|      1|  x = x ?: 4;
    3|      1|  int y = 0;
    4|      1|  return x;       <-- Covered
    5|      1|}
2024-02-18 14:34:35 -08:00
NAKAMURA Takumi
75f0d40507 CoverageMapping: Move getParams<InnerParamTy>(MCDCParams) into mcdc::
Fixup for #81227
2024-02-15 20:27:47 +09:00
NAKAMURA Takumi
3fe5a0cfa5 MCDCCoverageBuilder: Use pop_back_val() 2024-02-15 20:27:47 +09:00
NAKAMURA Takumi
ab76e48ac2
[MC/DC] Refactor: Let MCDCConditionID int16_t with zero-origin (#81257)
Also, Let `NumConditions` `uint16_t`.

It is smarter to handle the ID as signed.
Narrowing to `int16_t` will reduce costs of handling byvalue. (See also
#81221 and #81227)

External behavior doesn't change. They below handle values as internal
values plus 1.
* `-dump-coverage-mapping`
* `CoverageMappingReader.cpp`
* `CoverageMappingWriter.cpp`
2024-02-15 16:24:37 +09:00
NAKAMURA Takumi
1a1fcacbce
[MC/DC] Refactor: Introduce ConditionIDs as std::array<2> (#81221)
Its 0th element corresponds to `FalseID` and 1st to `TrueID`.

CoverageMappingGen.cpp: `DecisionIDPair` is replaced with `ConditionIDs`
2024-02-14 23:17:00 +09:00
NAKAMURA Takumi
5c8985e770
clangCodeGen: Introduce MCDC::State with MCDCState.h (#81497)
This packs;
* `BitmapBytes`
* `BitmapMap`
* `CondIDMap`

into `MCDC::State`.
2024-02-14 17:27:53 +09:00
NAKAMURA Takumi
a17a3e9d9a
[MC/DC] Refactor: Make MCDCParams as std::variant (#81227)
Introduce `mcdc::DecisionParameters` and `mcdc::BranchParameters` and make
sure them not initialized as zero.

FIXME: Could we make `CoverageMappingRegion` as a smart tagged union?
2024-02-13 22:43:46 +09:00
NAKAMURA Takumi
f0db35b93f
[MC/DC] Refactor: Introduce MCDCTypes.h for coverage::mcdc (#81459)
They can be also used in `clang`.
Introduce the lightweight header instead of `CoverageMapping.h`.

This includes for now:
* `mcdc::ConditionID`
* `mcdc::Parameters`
2024-02-13 17:40:51 +09:00
ManuelvOK
c07fcd45f1 [Coverage] Map regions from system headers (#76950)
In 2155195131a57f2f01e7cfabb85bb027518c2dc6, the
"system-headers-coverage" option has been added but not used in all
necessary places.

This is the recommit since it has been reverted in
faef68bca852d08511ea0311d8a0d221cb202e73

Potential reviewers: @gulfemsavrun @petrhosek

Co-authored-by: Manuel Kalettka <manuel.kalettka@kernkonzept.com>
2024-02-02 18:04:24 +09:00
Hana Dusíková
bfc6eaa263
[coverage] fix crash in code coverage and if constexpr with ExprWithCleanups (#80292)
Fixes https://github.com/llvm/llvm-project/issues/80285
2024-02-01 23:31:32 +01:00
NAKAMURA Takumi
faef68bca8 Revert "[Coverage] Map regions from system headers (#76950)"
See #78920.

This reverts commit ce3e767ac5ea1a1d1a166e88c152e2125ec7662b.
2024-01-27 15:11:37 +09:00
ManuelvOK
ce3e767ac5
[Coverage] Map regions from system headers (#76950)
In 2155195131a57f2f01e7cfabb85bb027518c2dc6, the
"system-headers-coverage" option has been added but not used in all
necessary places.

Potential reviewers: @gulfemsavrun @petrhosek

Co-authored-by: Manuel Kalettka <manuel.kalettka@kernkonzept.com>
2024-01-22 21:41:49 -08:00
Hana Dusíková
865e4a1f33
[coverage] skipping code coverage for 'if constexpr' and 'if consteval' (#78033)
`if constexpr` and `if consteval` conditional statements code coverage
should behave more like a preprocesor `#if`-s than normal
ConditionalStmt. This PR should fix that.

---------

Co-authored-by: cor3ntin <corentinjabot@gmail.com>
2024-01-22 12:50:20 +01:00
Alan Phipps
22867890e4
[clang][CoverageMapping] Refactor setting MC/DC True/False Condition IDs (#78202)
Clean-up of the algorithm that assigns MC/DC True/False control-flow
condition IDs when constructing an MC/DC decision region. This patch
creates a common API for setting/getting the condition IDs, making the
binary logical operator visitor functions much cleaner.

This patch also fixes issue
https://github.com/llvm/llvm-project/issues/77873 in which a record's
control flow map can be malformed due to an incorrect calculation of the
True/False condition IDs.
2024-01-18 09:34:52 -06:00
Kazu Hirata
6bd488dd24 [CodeGen] Use DenseMap::contains (NFC) 2024-01-12 22:08:28 -08:00
Hana Dusíková
a26cc759ae
[clang][coverage] Fix "if constexpr" and "if consteval" coverage report (#77214)
Replace the discarded statement by an empty compound statement so we can keep track of the
whole source range we need to skip in coverage

Fixes #54419
2024-01-10 11:01:23 +01:00
Alan Phipps
8b2bdfbca7 [Coverage][clang] Enable MC/DC Support in LLVM Source-based Code Coverage (3/3)
Part 3 of 3. This includes the MC/DC clang front-end components.

Differential Revision: https://reviews.llvm.org/D138849
2024-01-04 12:29:18 -06:00