#2052: hpc ignores files containing LINES pragmas that refer to .hsc files
----------------------------+-----------------------------------------------
    Reporter:  dons         |       Owner:  [EMAIL PROTECTED]
        Type:  bug          |      Status:  new            
    Priority:  normal       |   Component:  Code Coverage  
     Version:  6.8.2        |    Severity:  normal         
    Keywords:  hpc, hsc2hs  |    Testcase:                 
Architecture:  Multiple     |          Os:  Multiple       
----------------------------+-----------------------------------------------
 ghc -hpc generates no ticks for files containing LINE pragmas that point
 back to .hsc files. Removing the LINE pragmas, and ticks are generated.

 An example. This simple .hsc file:

 {{{
 main = print "hello, world"
 }}}

 Generates this A.hs file:

 {{{
 {-# LINE 1 "A.hsc" #-}
 main = print "hello, world"
 {-# LINE 2 "A.hsc" #-}
 }}}

 Compiling this with -fhpc, we see no ticks produced:

 {{{
 { AbsBinds [] [] [Main.main <= [] main_aif]

     Main.main :: GHC.IOBase.IO ()
     []
     { print_aie = System.IO.print @ [GHC.Base.Char] $dShow_ail
       main_aif = print_aie "hello, world" }
   :Main.main = GHC.TopHandler.runMainIO @ () Main.main
   $dShow_ail = GHC.Show.$f21 @ GHC.Base.Char $dShow_aiW
   $dShow_aiW = GHC.Show.$f18 }
 }}}

 Run this, and get the hpc report:

 {{{
 $ ./a.out
 "hello, world"

 $ hpc report a.out.tix
 100% expressions used (0/0)
 100% boolean coverage (0/0)
 }}}

 0/0 declarations.

 However, an identical file, without LINE pragmas, goes through just fine:

 {{{
 $ ghc -fhpc B.hs -ddump-hpc
 { AbsBinds [] [] [Main.main <= [] main_aif]
     Main.main :: GHC.IOBase.IO ()
     []
     { print_aie = System.IO.print @ [GHC.Base.Char] $dShow_ail
       -- tick id = (2, [])
       main_aif = tick<1>(print_aie (tick<0>("got you"))) }
   :Main.main = GHC.TopHandler.runMainIO @ () Main.main
   $dShow_ail = GHC.Show.$f21 @ GHC.Base.Char $dShow_aiW
   $dShow_aiW = GHC.Show.$f18 }
 }}}

 And the result has valid hpc .tix

 {{{
 $ hpc report a.out.tix
 100% expressions used (2/2)
 100% boolean coverage (0/0)
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2052>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to