Open wintered opened 7 months ago
The else arm of the if
expression gets its own region, even if there is no else
in the source file.
In your example program the else arm isn't executed and has an execution count of 0.
In the C++ program, this fact is represented by the Branch Coverage column instead. (Rust currently doesn't support LLVM branch coverage mappings.)
The else arm of the if expression gets its own region, even if there is no else in the source file.
Why in C++, the else branch does not get its own region even though it does in Rust?
In Rust with branch coverage enabled (--branch
, #8):
I believe this is an issue on the rustc rather than the cargo-llvm-cov.
Would you mind submitting an issue at https://github.com/rust-lang/rust?
I’m not quite sure what the bug here is supposed to be.
Are you referring to the fact that the uncovered else block isn’t highlighted on line 4?
Are you referring to the fact that the uncovered else block isn’t highlighted on line 4?
Yes.
I'm not 100% certain that this should be considered a bug, but in any case, since this is a discussion about the behavior of rustc and not cargo-llvm-cov, it is better to discuss it in the rust-lang/rust and not in this repository.
Hi,
cargo-llvm-cov reports that the following Rust code had 5 region coverage. Why? I count only 4: (1+2) both functions, (3) the if condition, (4) the "then branch". I also looked at the generated llvm-ir but could not figure out where the fifth region came from.
The corresponding C++ program has 4 regions.
cargo-llvm-cov: 0.5.36 LLVM version 17.0.4