Permalink
Browse files

Change how macros like ASSERT are defined

By using Haskell's debugIsOn rather than CPP's "#ifdef DEBUG", we
don't need to kludge things to keep the warning checker happy etc.
  • Loading branch information...
1 parent 50fddb2 commit 243439e6e77eca548a6583722792d6b96e3f6bcd @igfoo igfoo committed Jun 4, 2012
Showing with 73 additions and 32 deletions.
  1. +2 −11 compiler/HsVersions.h
  2. +1 −1 compiler/basicTypes/Id.lhs
  3. +2 −0 compiler/basicTypes/Literal.lhs
  4. +1 −0 compiler/basicTypes/Unique.lhs
  5. +1 −1 compiler/cmm/CmmBuildInfoTables.hs
  6. +2 −0 compiler/cmm/CmmInfo.hs
  7. +1 −0 compiler/cmm/CmmUtils.hs
  8. +1 −0 compiler/cmm/MkGraph.hs
  9. +1 −0 compiler/cmm/OptimizationFuel.hs
  10. +1 −0 compiler/codeGen/CgMonad.lhs
  11. +1 −0 compiler/codeGen/CgTailCall.lhs
  12. +1 −0 compiler/codeGen/ClosureInfo.lhs
  13. +1 −0 compiler/codeGen/CodeGen.lhs
  14. +1 −0 compiler/codeGen/StgCmm.hs
  15. +1 −0 compiler/codeGen/StgCmmClosure.hs
  16. +1 −1 compiler/codeGen/StgCmmCon.hs
  17. +1 −0 compiler/codeGen/StgCmmHeap.hs
  18. +1 −0 compiler/codeGen/StgCmmPrim.hs
  19. +1 −1 compiler/coreSyn/MkCore.lhs
  20. +1 −0 compiler/deSugar/DsCCall.lhs
  21. +2 −0 compiler/deSugar/DsForeign.lhs
  22. +1 −0 compiler/deSugar/DsListComp.lhs
  23. +1 −1 compiler/deSugar/DsMeta.hs
  24. +1 −1 compiler/deSugar/MatchCon.lhs
  25. +1 −0 compiler/ghci/ByteCodeAsm.lhs
  26. +1 −0 compiler/ghci/ByteCodeLink.lhs
  27. +1 −1 compiler/hsSyn/HsExpr.lhs
  28. +1 −0 compiler/iface/BinIface.hs
  29. +1 −1 compiler/iface/BuildTyCl.lhs
  30. +1 −0 compiler/iface/IfaceEnv.lhs
  31. +1 −0 compiler/main/HscMain.hs
  32. +1 −0 compiler/nativeGen/PPC/CodeGen.hs
  33. +1 −0 compiler/nativeGen/X86/CodeGen.hs
  34. +2 −0 compiler/parser/RdrHsSyn.lhs
  35. +1 −0 compiler/prelude/PrelRules.lhs
  36. +1 −0 compiler/prelude/TysWiredIn.lhs
  37. +1 −0 compiler/profiling/SCCfinal.lhs
  38. +1 −1 compiler/rename/RnExpr.lhs
  39. +1 −1 compiler/rename/RnPat.lhs
  40. +1 −1 compiler/rename/RnTypes.lhs
  41. +1 −1 compiler/simplCore/FloatIn.lhs
  42. +1 −1 compiler/simplCore/OccurAnal.lhs
  43. +1 −0 compiler/simplCore/SimplEnv.lhs
  44. +1 −0 compiler/simplCore/Simplify.lhs
  45. +1 −0 compiler/stgSyn/StgSyn.lhs
  46. +1 −1 compiler/stranal/DmdAnal.lhs
  47. +1 −1 compiler/stranal/WorkWrap.lhs
  48. +1 −1 compiler/typecheck/FamInst.lhs
  49. +1 −1 compiler/typecheck/TcCanonical.lhs
  50. +1 −0 compiler/typecheck/TcClassDcl.lhs
  51. +1 −0 compiler/typecheck/TcEnv.lhs
  52. +1 −0 compiler/typecheck/TcForeign.lhs
  53. +1 −0 compiler/typecheck/TcGenGenerics.lhs
  54. +1 −0 compiler/typecheck/TcHsSyn.lhs
  55. +2 −0 compiler/typecheck/TcHsType.lhs
  56. +1 −0 compiler/typecheck/TcInteract.lhs
  57. +1 −0 compiler/typecheck/TcRnTypes.lhs
  58. +1 −1 compiler/typecheck/TcSplice.lhs
  59. +1 −0 compiler/types/InstEnv.lhs
  60. +1 −0 compiler/types/Kind.lhs
  61. +1 −0 compiler/types/OptCoercion.lhs
  62. +1 −0 compiler/types/TypeRep.lhs
  63. +2 −1 compiler/utils/Outputable.lhs
  64. +1 −0 compiler/vectorise/Vectorise/Exp.hs
  65. +1 −0 compiler/vectorise/Vectorise/Monad/InstEnv.hs
  66. +1 −2 ghc/InteractiveUI.hs
View
@@ -46,18 +46,9 @@ name :: IORef (ty); \
name = Util.globalM (value);
#endif
-#ifdef DEBUG
-#define ASSERT(e) if (not (e)) then (assertPanic __FILE__ __LINE__) else
-#define ASSERT2(e,msg) if (not (e)) then (assertPprPanic __FILE__ __LINE__ (msg)) else
+#define ASSERT(e) if debugIsOn && not (e) then (assertPanic __FILE__ __LINE__) else
+#define ASSERT2(e,msg) if debugIsOn && not (e) then (assertPprPanic __FILE__ __LINE__ (msg)) else
#define WARN( e, msg ) (warnPprTrace (e) __FILE__ __LINE__ (msg)) $
-#else
--- We have to actually use all the variables we are given or we may get
--- unused variable warnings when DEBUG is off.
-#define ASSERT(e) if False && (not (e)) then panic "ASSERT" else
-#define ASSERT2(e,msg) if False && (const False (e,msg)) then pprPanic "ASSERT2" (msg) else
-#define WARN(e,msg) if False && (e) then pprPanic "WARN" (msg) else
--- Here we deliberately don't use when as Control.Monad might not be imported
-#endif
-- Examples: Assuming flagSet :: String -> m Bool
--
@@ -126,7 +126,7 @@ import Outputable
import Unique
import UniqSupply
import FastString
-import Util( count )
+import Util
import StaticFlags
-- infixl so you can say (id `set` a `set` b)
@@ -62,6 +62,8 @@ import BasicTypes
import Binary
import Constants
import UniqFM
+import Util
+
import Data.Int
import Data.Ratio
import Data.Word
@@ -71,6 +71,7 @@ import FastTypes
import FastString
import Outputable
-- import StaticFlags
+import Util
#if defined(__GLASGOW_HASKELL__)
--just for implementing a fast [0,61) -> Char function
@@ -32,7 +32,7 @@ import Constants
import Digraph
import qualified Prelude as P
import Prelude hiding (succ)
-import Util (sortLe)
+import Util
import BlockId
import Bitmap
View
@@ -27,6 +27,8 @@ import Platform
import StaticFlags
import UniqSupply
import MonadUtils
+import Util
+
import Data.Bits
import Data.Word
View
@@ -83,6 +83,7 @@ import OptimizationFuel as F
import Unique
import UniqSupply
import Constants( wORD_SIZE, tAG_MASK )
+import Util
import Data.Word
import Data.Maybe
View
@@ -42,6 +42,7 @@ import SMRep (ByteOff)
import StaticFlags
import Unique
import UniqSupply
+import Util
#include "HsVersions.h"
@@ -22,6 +22,7 @@ import Control.Monad
import StaticFlags (opt_Fuel)
import UniqSupply
import Panic
+import Util
import Compiler.Hoopl
import Compiler.Hoopl.GHC (getFuel, setFuel)
@@ -77,6 +77,7 @@ import VarEnv
import OrdList
import Unique
import UniqSupply
+import Util
import Outputable
import Control.Monad
@@ -43,6 +43,7 @@ import StgSyn
import PrimOp
import Outputable
import StaticFlags
+import Util
import Control.Monad
import Data.Maybe
@@ -96,6 +96,7 @@ import Outputable
import FastString
import Constants
import DynFlags
+import Util
\end{code}
@@ -45,6 +45,7 @@ import TyCon
import Module
import ErrUtils
import Panic
+import Util
codeGen :: DynFlags
-> Module -- Module we are compiling
@@ -46,6 +46,7 @@ import TyCon
import Module
import ErrUtils
import Outputable
+import Util
codeGen :: DynFlags
-> Module
@@ -90,6 +90,7 @@ import Outputable
import Platform
import Constants
import DynFlags
+import Util
-----------------------------------------------------------------------------
-- Representations
@@ -41,7 +41,7 @@ import PrelInfo
import Outputable
import Platform
import StaticFlags
-import Util ( lengthIs )
+import Util
import Control.Monad
import Data.Char
@@ -44,6 +44,7 @@ import Module
import FastString( mkFastString, fsLit )
import Constants
import DynFlags
+import Util
-----------------------------------------------------------
-- Initialise dynamic heap objects
@@ -43,6 +43,7 @@ import Module
import FastString
import Outputable
import StaticFlags
+import Util
------------------------------------------------------------------------
-- Primitive operations and foreign calls
@@ -85,7 +85,7 @@ import Outputable
import FastString
import UniqSupply
import BasicTypes
-import Util ( notNull, zipEqual, sortLe )
+import Util
import Pair
import Constants
@@ -49,6 +49,7 @@ import PrelNames
import VarSet
import Constants
import Outputable
+import Util
\end{code}
Desugaring of @ccall@s consists of adding some state manipulation,
@@ -47,6 +47,8 @@ import Config
import Constants
import OrdList
import Pair
+import Util
+
import Data.Maybe
import Data.List
\end{code}
@@ -33,6 +33,7 @@ import SrcLoc
import Outputable
import FastString
import TcType
+import Util
\end{code}
List comprehensions may be desugared in one of two ways: ``ordinary''
@@ -65,7 +65,7 @@ import Bag
import FastString
import ForeignCall
import MonadUtils
-import Util( equalLength, filterOut )
+import Util
import Data.Maybe
import Control.Monad
@@ -26,7 +26,7 @@ import TcType
import DsMonad
import DsUtils
import MkCore ( mkCoreLets )
-import Util ( all2, takeList, zipEqual )
+import Util
import ListSetOps ( runs )
import Id
import NameEnv
@@ -34,6 +34,7 @@ import ClosureInfo -- CgRep stuff
import DynFlags
import Outputable
import Platform
+import Util
import Control.Monad
import Control.Monad.ST ( runST )
@@ -27,6 +27,7 @@ import Module
import FastString
import Panic
import Outputable
+import Util
-- Standard libraries
@@ -32,7 +32,7 @@ import Name
import BasicTypes
import DataCon
import SrcLoc
-import Util( dropTail )
+import Util
import StaticFlags( opt_PprStyle_Debug )
import Outputable
import FastString
@@ -51,6 +51,7 @@ import Outputable
import Platform
import FastString
import Constants
+import Util
import Data.Bits
import Data.Char
@@ -38,7 +38,7 @@ import Type
import Coercion
import TcRnMonad
-import Util ( isSingleton )
+import Util
import Outputable
\end{code}
@@ -41,6 +41,7 @@ import FastString
import UniqSupply
import SrcLoc
import BasicTypes
+import Util
import Outputable
import Exception ( evaluate )
View
@@ -147,6 +147,7 @@ import UniqFM ( emptyUFM )
import UniqSupply ( initUs_ )
import Bag
import Exception
+import Util
import Data.List
import Control.Monad
@@ -57,6 +57,7 @@ import Data.Word
import BasicTypes
import FastString
+import Util
-- -----------------------------------------------------------------------------
-- Top-level of the instruction selector
@@ -54,6 +54,7 @@ import FastString
import FastBool ( isFastTrue )
import Constants ( wORD_SIZE )
import DynFlags
+import Util
import Control.Monad
import Data.Bits
@@ -76,6 +76,8 @@ import Bag ( Bag, emptyBag, consBag )
import Outputable
import FastString
import Maybes
+import Util
+
import Control.Applicative ((<$>))
import Control.Monad
import Text.ParserCombinators.ReadP as ReadP
@@ -41,6 +41,7 @@ import FastString
import StaticFlags ( opt_SimplExcessPrecision )
import Constants
import BasicTypes
+import Util
import Data.Bits as Bits
import Data.Int ( Int64 )
@@ -104,6 +104,7 @@ import Data.Array
import FastString
import Outputable
import Config
+import Util
alpha_tyvar :: [TyVar]
alpha_tyvar = [alphaTyVar]
@@ -34,6 +34,7 @@ import Outputable
import DynFlags
import FastString
import SrcLoc
+import Util
stgMassageForProfiling
@@ -46,7 +46,7 @@ import RdrName
import LoadIface ( loadInterfaceForName )
import UniqSet
import Data.List
-import Util ( isSingleton, snocView )
+import Util
import ListSetOps ( removeDups )
import Outputable
import SrcLoc
@@ -55,7 +55,7 @@ import Name
import NameSet
import RdrName
import BasicTypes
-import Util ( notNull )
+import Util
import ListSetOps ( removeDups )
import Outputable
import SrcLoc
@@ -49,7 +49,7 @@ import Name
import SrcLoc
import NameSet
-import Util ( filterOut )
+import Util
import BasicTypes ( IPName(..), ipNameName, compareFixity, funTyFixity, negateFixity,
Fixity(..), FixityDirection(..) )
import Outputable
@@ -31,7 +31,7 @@ import Id ( isOneShotBndr, idType )
import Var
import Type ( isUnLiftedType )
import VarSet
-import Util ( zipEqual, zipWithEqual, count )
+import Util
import UniqFM
import Outputable
\end{code}
@@ -44,7 +44,7 @@ import Digraph ( SCC(..), stronglyConnCompFromEdgedVerticesR )
import PrelNames ( buildIdKey, foldrIdKey, runSTRepIdKey, augmentIdKey )
import Unique
import UniqFM
-import Util ( mapAndUnzip, filterOut, fstOf3 )
+import Util
import Bag
import Outputable
import FastString
@@ -63,6 +63,7 @@ import BasicTypes
import MonadUtils
import Outputable
import FastString
+import Util
import Data.List
\end{code}
@@ -49,6 +49,7 @@ import Data.List ( mapAccumL )
import Outputable
import FastString
import Pair
+import Util
\end{code}
@@ -67,6 +67,7 @@ import Type ( Type )
import Type ( typePrimRep )
import UniqSet
import Unique ( Unique )
+import Util
import VarSet ( IdSet, isEmptyVarSet )
\end{code}
@@ -44,7 +44,7 @@ import UniqFM ( addToUFM_Directly, lookupUFM_Directly,
minusUFM, filterUFM )
import Type ( isUnLiftedType, eqType, tyConAppTyCon_maybe )
import Coercion ( coercionKind )
-import Util ( mapAndUnzip, lengthIs, zipEqual )
+import Util
import BasicTypes ( Arity, TopLevelFlag(..), isTopLevel, isNeverActive,
RecFlag(..), isRec, isMarkedStrict )
import Maybes ( orElse, expectJust )
Oops, something went wrong.

0 comments on commit 243439e

Please sign in to comment.