[PATCH] D95987: [llvm-cov] Reset ExecutionCount only if first line segment is start of a new region.

Pirama Arumuga Nainar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 3 22:53:32 PST 2021


pirama added subscribers: srhines, pirama.
pirama added a comment.

Thanks for the patch Zequan.  This fixes the C++ test case that prompted this issue.

The underlying Rust issue is not fixed though:

   1|       |fn notatest() -> Result<(), std::env::VarError> {
   2|      1|        let result = std::env::var("MEOW")
   3|      0|                    .or(Ok("a".to_string()))?;
   4|      1|            println!("{}", result);
   5|      1|                Ok(())
   6|      1|}
   7|       | 
   8|      1|fn main() {
   9|      1|        println!("Hello, world! {:?}", notatest());
  10|      1|}

Here're the regions from `-debug-only=coverage-mapping`:

  Segment at 2:13 (count = 1), RegionEntry
  Segment at 2:19 (count = 0), Skipped                                                          
  Segment at 2:22 (count = 1), RegionEntry                                                      
  Segment at 3:45 (count = 0), RegionEntry
  Segment at 3:46 (count = 0), Skipped
  Segment at 4:13 (count = 1), RegionEntry
  Segment at 5:23 (count = 0), Skipped
  Segment at 6:1 (count = 1), RegionEntry
  Segment at 6:2 (count = 0), Skipped
  Segment at 8:11 (count = 1), RegionEntry
  Segment at 10:2 (count = 0), Skipped

The ternary operator case in the C++ test case has a gap region corresponding to the `?`.  For the Rust `?` operator, there is no similar gap region.  In fact, the rust frontend associates the counter corresponding to the error path of the `?` operator to the `?` token .  Is there a better sequence of Segments that the Rust frontend can emit to handle this case?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95987/new/

https://reviews.llvm.org/D95987



More information about the llvm-commits mailing list