summaryrefslogtreecommitdiff
path: root/compiler/GHC/Rename/Splice.hs
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-01-07 14:25:15 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-02-13 21:27:34 -0500
commit8e2f85f6b4662676f0d7addaff9bf2c7d751bb63 (patch)
tree6a5bea5db12d907874cdf26d709d829a3f3216ba /compiler/GHC/Rename/Splice.hs
parent40983d2331fe34c0af6925db7588d5ac6a19ae36 (diff)
downloadhaskell-8e2f85f6b4662676f0d7addaff9bf2c7d751bb63.tar.gz
Refactor Logger
Before this patch, the only way to override GHC's default logging behavior was to set `log_action`, `dump_action` and `trace_action` fields in DynFlags. This patch introduces a new Logger abstraction and stores it in HscEnv instead. This is part of #17957 (avoid storing state in DynFlags). DynFlags are duplicated and updated per-module (because of OPTIONS_GHC pragma), so we shouldn't store global state in them. This patch also fixes a race in parallel "--make" mode which updated the `generatedDumps` IORef concurrently. Bump haddock submodule The increase in MultilayerModules is tracked in #19293. Metric Increase: MultiLayerModules
Diffstat (limited to 'compiler/GHC/Rename/Splice.hs')
-rw-r--r--compiler/GHC/Rename/Splice.hs21
1 files changed, 11 insertions, 10 deletions
diff --git a/compiler/GHC/Rename/Splice.hs b/compiler/GHC/Rename/Splice.hs
index 19d9d333ec..b0e6bb1159 100644
--- a/compiler/GHC/Rename/Splice.hs
+++ b/compiler/GHC/Rename/Splice.hs
@@ -41,7 +41,7 @@ import GHC.Tc.Utils.Env ( checkWellStaged, tcMetaTy )
import GHC.Driver.Session
import GHC.Data.FastString
-import GHC.Utils.Error ( dumpIfSet_dyn_printer, DumpFormat (..) )
+import GHC.Utils.Logger ( dumpIfSet_dyn_printer, DumpFormat (..), getLogger )
import GHC.Utils.Panic
import GHC.Driver.Hooks
import GHC.Builtin.Names.TH ( decsQTyConName, expQTyConName, liftName
@@ -808,15 +808,16 @@ data SpliceInfo
traceSplice :: SpliceInfo -> TcM ()
traceSplice (SpliceInfo { spliceDescription = sd, spliceSource = mb_src
, spliceGenerated = gen, spliceIsDecl = is_decl })
- = do { loc <- case mb_src of
- Nothing -> getSrcSpanM
- Just (L loc _) -> return loc
- ; traceOptTcRn Opt_D_dump_splices (spliceDebugDoc loc)
-
- ; when is_decl $ -- Raw material for -dth-dec-file
- do { dflags <- getDynFlags
- ; liftIO $ dumpIfSet_dyn_printer alwaysQualify dflags Opt_D_th_dec_file
- "" FormatHaskell (spliceCodeDoc loc) } }
+ = do loc <- case mb_src of
+ Nothing -> getSrcSpanM
+ Just (L loc _) -> return loc
+ traceOptTcRn Opt_D_dump_splices (spliceDebugDoc loc)
+
+ when is_decl $ do -- Raw material for -dth-dec-file
+ dflags <- getDynFlags
+ logger <- getLogger
+ liftIO $ dumpIfSet_dyn_printer alwaysQualify logger dflags Opt_D_th_dec_file
+ "" FormatHaskell (spliceCodeDoc loc)
where
-- `-ddump-splices`
spliceDebugDoc :: SrcSpan -> SDoc