summaryrefslogtreecommitdiff
path: root/testsuite/tests/regalloc/regalloc_unit_tests.hs
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-08-19 20:16:21 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-10-01 18:36:11 -0400
commita5aaceecaa04ce7ea5bade6eb96c0d129109c15a (patch)
tree80035738c384ef5e4bf8a4f943bbac5808c8c921 /testsuite/tests/regalloc/regalloc_unit_tests.hs
parentdca1cb22cab4fa7f5937e9ffdc0ee32313dbd01c (diff)
downloadhaskell-a5aaceecaa04ce7ea5bade6eb96c0d129109c15a.tar.gz
Use ADTs for parser errors/warnings
Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001
Diffstat (limited to 'testsuite/tests/regalloc/regalloc_unit_tests.hs')
-rw-r--r--testsuite/tests/regalloc/regalloc_unit_tests.hs5
1 files changed, 4 insertions, 1 deletions
diff --git a/testsuite/tests/regalloc/regalloc_unit_tests.hs b/testsuite/tests/regalloc/regalloc_unit_tests.hs
index d8176cd644..c6902d48be 100644
--- a/testsuite/tests/regalloc/regalloc_unit_tests.hs
+++ b/testsuite/tests/regalloc/regalloc_unit_tests.hs
@@ -33,6 +33,7 @@ import GHC.Cmm.Pipeline
import GHC.Cmm.Parser
import GHC.Cmm.Info
import GHC.Cmm
+import GHC.Parser.Errors.Ppr
import GHC.Unit.Module
import GHC.Cmm.DebugBlock
import GHC
@@ -109,7 +110,9 @@ compileCmmForRegAllocStats dflags' cmmFile ncgImplF us = do
hscEnv <- newHscEnv dflags
-- parse the cmm file and output any warnings or errors
- ((warningMsgs, errorMsgs), parsedCmm) <- parseCmmFile dflags cmmFile
+ (warnings, errors, parsedCmm) <- parseCmmFile dflags cmmFile
+ let warningMsgs = fmap pprWarning warnings
+ errorMsgs = fmap pprError errors
-- print parser errors or warnings
mapM_ (printBagOfErrors dflags) [warningMsgs, errorMsgs]