19 Commits

Author SHA1 Message Date
Dorian Peron
cc41798171 tests: Add tests for try-catch blocks 2025-11-28 13:37:41 +00:00
Dorian Peron
eed2817139 tests: Add tests for nested records instrumentation 2025-11-17 11:27:06 +00:00
Matthieu Eyraud
8fb057098d Instrument.C: explicitly pass -m32 for 32 bits targets to clang
Otherwise, it yields a mismatching for the size_t type, resulting in
clang failing to parse / check C++ constructs such as initializer lists.
2025-09-02 11:27:16 +02:00
Pierre-Marie de Rodat
a488e5d803 C++/stmt/ForRange/WithoutInit: adapt for bareboard targets 2025-07-24 17:36:35 +00:00
Pierre-Marie de Rodat
35f02b609c C++/stmt/ForRange/WithInit: skip when exception propagation not avail. 2025-07-24 17:36:35 +00:00
Pierre-Marie de Rodat
9949b5b018 C++/mcdc/AandB/In_Dtor: remove useless dynamic allocation 2025-07-24 17:36:35 +00:00
Pierre-Marie de Rodat
f1565f2252 C++/stmt/ForRange/WithInitializerRange: XFAIL for bareboard+src-traces 2025-07-23 15:05:21 +00:00
Matthieu Eyraud
cf7e004776 Do not generate coverage obligations for C++ constexpr
Similarly to what is done in Ada with static expressions.
2025-07-18 10:10:46 +02:00
Dorian Peron
ab36dfca5d fix precommit 2025-06-24 11:38:44 +02:00
Pierre-Marie de Rodat
34a3662ae6 Run clang-format on all C/C++ sources 2024-02-27 13:40:05 +00:00
Pierre-Marie de Rodat
c170322a90 Testsuite: fix style issues in text files
Remove trailing whitespaces and trailing lines, ensure that the last
line of each file ends with a newline.
2024-02-14 16:04:48 +00:00
Matthieu Eyraud
7de24b5c69 Fix handling of lambda expressions
When retrieving the lambda expressions inside a clang cursor, we were
traversing recursively all the nodes in the cursor subtree. In addition
to being very inefficient, this resulted in lambda expressions being
processed multiple times.

To fix this, we integrate the processing of lambda expression to the
processing of decisions, similarly to what is done to process declare
expressions in Ada.
2023-10-23 12:15:36 +00:00
Matthieu Eyraud
e0c80ad871 C++ instrumentation: fix for ranges support
The instrumentation scheme for C++ for ranges resulted in incorrect code
when initializer lists were involved, e.g.:

```
for (auto i : {1, 2) {
   <for_body>
}
```

being instrumented as

```
for (auto i : (witness(), {1, 2}) {
   <for_body>
}
```

which is invalid C++ code.

To fix this, we now instrument such expressions as followed:

```
witness();
for (auto i : {1, 2}) {
   <for_body>
}
```

We can't execute the loop statement without executing the witness
with a goto as it is forbidden to bypass initialization statements in C++.

When there is an initialization statement, e.g.:

```
for (int j = 0; auto i : {1, 2}){}
```

we actually introduce an outer scope and instrument as followed:

```
{
   witness_j();
   int j = 0;
   witness_i();
   for (auto i : {1, 2}){}
}
```

(cherry picked from commit c29e1be8bf)
2023-09-25 12:19:07 +02:00
Matthieu Eyraud
21f5650694 Instrument.C: fix instrumentation when no SCO can be instrumented
gnatcov used to crash when instrumenting source code that consisted
solely of non-instrumentable constructs. This was due to an implicit
assumption that every source of interest should be present in the
UIC.Instrumented_Entities map, which wasn't the case in this scenario.
Fix the code to ensure the assumption's validity.
2023-09-19 08:33:30 +00:00
Matthieu Eyraud
c233f9a05e C++ instr: do not instrument constexpr
Instrumenting constexpr functions violates the constexpr semantics and
there is no straightforward valid way of instrumenting such code
constructs.

Skip their instrumentation altogether for the moment, as their use is
quite limited (they are only allowed to return literal values).
2023-09-08 12:08:27 +02:00
Matthieu Eyraud
ceafe2ee31 C++ instr: consider struct member functions 2023-08-16 18:07:16 +02:00
Matthieu Eyraud
b6f3809664 Revert "Merge branch 'eyraud/diagnostics' into 'master'"
This reverts commit dc22acfae3, reversing
changes made to 9330e90766.
2023-07-07 14:21:01 +02:00
Matthieu Eyraud
834fb95077 Instrument.C: output clang diagnostics
If the parsing failed because of an error in the user code, we should
emit the diagnostics reported by clang to let the user know that
coverage analysis may be incomplete.

As we preprocess code with another compiler configuration than the clang
one, we may have compiler-specific code, notably in system-headers, so
we also need to filter out a lot of messages to avoid issuing spurious
warning messages. The heuristic picked is to only keep diagnostics whose
presumed location file is a file of interest (belonging to the project).
This could be revisited if there are still too many false positives (as
we will have false positives raised on compiler-specific user code).
2023-07-06 12:27:46 +00:00
Matthieu Eyraud
357734997c Import tests from gnatcoverage-extra 2023-06-12 15:48:08 +00:00