Add {-# OPTIONS_GHC -w #-} and some blurb to all compiler modules
[ghc-hetmet.git] / compiler / main / TidyPgm.lhs
index dc0ea7e..dec5c6b 100644 (file)
@@ -4,6 +4,13 @@
 \section{Tidying up Core}
 
 \begin{code}
+{-# OPTIONS_GHC -w #-}
+-- The above warning supression flag is a temporary kludge.
+-- While working on this module you are encouraged to remove it and fix
+-- any warnings in the module. See
+--     http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions#Warnings
+-- for details
+
 module TidyPgm( mkBootModDetails, tidyProgram ) where
 
 #include "HsVersions.h"
@@ -21,16 +28,14 @@ import VarSet
 import Var             ( Id, Var )
 import Id              ( idType, idInfo, idName, idCoreRules, isGlobalId,
                          isExportedId, mkVanillaGlobal, isLocalId, isNaughtyRecordSelector,
-                         idArity, idCafInfo, idUnfolding, isImplicitId, setIdInfo
+                         idArity, idCafInfo, idUnfolding, isImplicitId, setIdInfo,
+                         isTickBoxOp
                        ) 
 import IdInfo          {- loads of stuff -}
 import InstEnv         ( Instance, DFunId, instanceDFunId, setInstanceDFunId )
 import NewDemand       ( isBottomingSig, topSig )
 import BasicTypes      ( Arity, isNeverActive, isNonRuleLoopBreaker )
-import Name            ( Name, getOccName, nameOccName, mkInternalName,
-                         localiseName, isExternalName, nameSrcLoc,
-                         isWiredInName, getName
-                       )
+import Name
 import NameSet         ( NameSet, elemNameSet )
 import IfaceEnv                ( allocateGlobalBinder )
 import NameEnv         ( filterNameEnv, mapNameEnv )
@@ -48,11 +53,12 @@ import Maybes               ( orElse, mapCatMaybes )
 import ErrUtils                ( showPass, dumpIfSet_core )
 import PackageConfig   ( PackageId )
 import UniqSupply      ( splitUniqSupply, uniqFromSupply )
-import List            ( partition )
-import Maybe           ( isJust )
 import Outputable
-import DATA_IOREF      ( IORef, readIORef, writeIORef )
 import FastTypes  hiding ( fastOr )
+
+import Data.List       ( partition )
+import Data.Maybe      ( isJust )
+import Data.IORef      ( IORef, readIORef, writeIORef )
 \end{code}
 
 
@@ -122,7 +128,9 @@ mkBootModDetails hsc_env (ModGuts { mg_module    = mod
                                  , mg_exports   = exports
                                  , mg_types     = type_env
                                  , mg_insts     = insts
-                                 , mg_fam_insts = fam_insts })
+                                 , mg_fam_insts = fam_insts
+                                  , mg_modBreaks = modBreaks   
+                                  })
   = do { let dflags = hsc_dflags hsc_env 
        ; showPass dflags "Tidy [hoot] type env"
 
@@ -136,7 +144,10 @@ mkBootModDetails hsc_env (ModGuts { mg_module    = mod
                             , md_insts     = insts'
                             , md_fam_insts = fam_insts
                             , md_rules     = []
-                            , md_exports   = exports })
+                            , md_exports   = exports
+                             , md_modBreaks = modBreaks 
+                             , md_vect_info = noVectInfo
+                             })
        }
   where
 
@@ -237,8 +248,11 @@ tidyProgram hsc_env
                                mg_insts = insts, mg_fam_insts = fam_insts,
                                mg_binds = binds, 
                                mg_rules = imp_rules,
+                                mg_vect_info = vect_info,
                                mg_dir_imps = dir_imps, mg_deps = deps, 
-                               mg_foreign = foreign_stubs })
+                               mg_foreign = foreign_stubs,
+                               mg_hpc_info = hpc_info,
+                                mg_modBreaks = modBreaks })
 
   = do { let dflags = hsc_dflags hsc_env
        ; showPass dflags "Tidy Core"
@@ -289,13 +303,17 @@ tidyProgram hsc_env
                           cg_binds    = all_tidy_binds,
                           cg_dir_imps = dir_imps,
                           cg_foreign  = foreign_stubs,
-                          cg_dep_pkgs = dep_pkgs deps }, 
+                          cg_dep_pkgs = dep_pkgs deps,
+                          cg_hpc_info = hpc_info }, 
 
                   ModDetails { md_types     = tidy_type_env,
                                md_rules     = tidy_rules,
                                md_insts     = tidy_insts,
                                md_fam_insts = fam_insts,
-                               md_exports   = exports })
+                               md_exports   = exports,
+                                md_modBreaks = modBreaks,
+                                md_vect_info = vect_info    -- is already tidy
+                              })
        }
 
 lookup_dfun type_env dfun_id
@@ -660,7 +678,7 @@ tidyTopName mod nc_var ext_ids occ_env id
     global     = isExternalName name
     local      = not global
     internal   = not external
-    loc                = nameSrcLoc name
+    loc                = nameSrcSpan name
 
     (occ_env', occ') = tidyOccName occ_env (nameOccName name)
 
@@ -788,11 +806,13 @@ CAF list to keep track of non-collectable CAFs.
 \begin{code}
 hasCafRefs  :: PackageId -> VarEnv Var -> Arity -> CoreExpr -> CafInfo
 hasCafRefs this_pkg p arity expr 
-  | is_caf || mentions_cafs = MayHaveCafRefs
+  | is_caf || mentions_cafs 
+                            = MayHaveCafRefs
   | otherwise              = NoCafRefs
  where
   mentions_cafs = isFastTrue (cafRefs p expr)
   is_caf = not (arity > 0 || rhsIsStatic this_pkg expr)
+
   -- NB. we pass in the arity of the expression, which is expected
   -- to be calculated by exprArity.  This is because exprArity
   -- knows how much eta expansion is going to be done by