summaryrefslogtreecommitdiff
path: root/compiler/GHC/Utils
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-05-21 17:46:22 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-05-24 00:15:33 -0400
commit3e4ef4b2d05ce0bdd70abd96066f0376dc0e13d6 (patch)
treef6fdfa1e1a47524c5c6254cefa9153ef2cf39b50 /compiler/GHC/Utils
parentfc23ae8958fdf197f1df4239d85682593e9f54c5 (diff)
downloadhaskell-3e4ef4b2d05ce0bdd70abd96066f0376dc0e13d6.tar.gz
Move warning flag handling into Flags module
I need this to make the Logger independent of DynFlags. Also fix copy-paste errors: Opt_WarnNonCanonicalMonadInstances was associated to "noncanonical-monadfail-instances" (MonadFailInstances vs MonadInstances). In the process I've also made the default name for each flag more explicit.
Diffstat (limited to 'compiler/GHC/Utils')
-rw-r--r--compiler/GHC/Utils/Logger.hs14
1 files changed, 8 insertions, 6 deletions
diff --git a/compiler/GHC/Utils/Logger.hs b/compiler/GHC/Utils/Logger.hs
index 2e5a9b06a7..164aa4d387 100644
--- a/compiler/GHC/Utils/Logger.hs
+++ b/compiler/GHC/Utils/Logger.hs
@@ -44,6 +44,7 @@ where
import GHC.Prelude
import GHC.Driver.Session
+import GHC.Driver.Flags
import GHC.Driver.Ppr
import GHC.Types.Error
import GHC.Types.SrcLoc
@@ -59,6 +60,7 @@ import System.FilePath ( takeDirectory, (</>) )
import qualified Data.Set as Set
import Data.Set (Set)
import Data.List (intercalate, stripPrefix)
+import qualified Data.List.NonEmpty as NE
import Data.Time
import System.IO
import Control.Monad
@@ -247,21 +249,21 @@ defaultLogAction dflags msg_class srcSpan msg
flagMsg SevIgnore _ = panic "Called flagMsg with SevIgnore"
flagMsg SevError WarningWithoutFlag = Just "-Werror"
flagMsg SevError (WarningWithFlag wflag) = do
- spec <- flagSpecOf wflag
+ let name = NE.head (warnFlagNames wflag)
return $
- "-W" ++ flagSpecName spec ++ warnFlagGrp wflag ++
- ", -Werror=" ++ flagSpecName spec
+ "-W" ++ name ++ warnFlagGrp wflag ++
+ ", -Werror=" ++ name
flagMsg SevError ErrorWithoutFlag = Nothing
flagMsg SevWarning WarningWithoutFlag = Nothing
flagMsg SevWarning (WarningWithFlag wflag) = do
- spec <- flagSpecOf wflag
- return ("-W" ++ flagSpecName spec ++ warnFlagGrp wflag)
+ let name = NE.head (warnFlagNames wflag)
+ return ("-W" ++ name ++ warnFlagGrp wflag)
flagMsg SevWarning ErrorWithoutFlag =
panic "SevWarning with ErrorWithoutFlag"
warnFlagGrp flag
| gopt Opt_ShowWarnGroups dflags =
- case smallestGroups flag of
+ case smallestWarningGroups flag of
[] -> ""
groups -> " (in " ++ intercalate ", " (map ("-W"++) groups) ++ ")"
| otherwise = ""