Units that contain only `pragma No_Body;` should be ignored when
computing an Ada source closure: LibGPR2 assigns them no name (so
gnatcov could crash with an assertion failure), and they cannot have
dependencies anyway.
This allows passing to `gnatcov coverage` traces produced before the
addition of exemption annotations (or gnatcov-unrelated annotation) to
source code.
This commit also adapts `320-varying-scos` tests so that SCOS that are
supposed to be distinct get different column numbers, in order to
correctly exercise the "SCO fingerprint mismatch" behavior.
Do not go through `LU_Info` in order to access the unit name, as there
is a local variable that provides the same information (and with the
needed type).
Make `gnatcov instrument` refrain from instrumenting Ada source files
that GPRbuild would not compile when given the same project options. For
instance, do not instrument source files that belong to the root project
but which are not in the closure of GPR mains.
Adapt relevant existing testcases to accomodate this new behavior: this
makes source instrumentation behave mor like coverage with binary
traces.
Fix the statement instrumentation of expression functions in Ada 2022
mode so that the sloc of the resulting SCO statement is identical to
what we get for pre-2022 code: the parens around the expression must not
be included.
This fixes 213-sarif-report test failures with `--cargs:Ada=-gnat22`.
Current, we never instrument calls when a qualified expr is needed to
wrap the inserted if expression: remove preliminary code that was
introduced to handle this case (it's never used and we always emit a
warning saying we could not instrument instead).
Also duplicate the test with code, and run them once with the
--instrument-ghost instrumentation switch, and once without, and check
that the coverage results are as expected.
Migrate ghost code tests from the gnatcoverage-extra repository
Using this aspect is not supported in Ghost code when the SPARK mode is
explicitly enforced. As this was introduced to avoid the compiler
optimizing away witness declarations, devise an alternate mechanism to
that avail: adding an additional limited record parameter to the witness
call.
Use Libadalang's heuristics to detect source encodings from GPR files to
decode Ada source files with the right encoding. Also make sure
instrumented sources are written with the same encoding.