summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/GHC/Driver/Flags.hs3
-rw-r--r--compiler/GHC/Driver/Session.hs8
2 files changed, 6 insertions, 5 deletions
diff --git a/compiler/GHC/Driver/Flags.hs b/compiler/GHC/Driver/Flags.hs
index e0ddaff52b..05733c88e4 100644
--- a/compiler/GHC/Driver/Flags.hs
+++ b/compiler/GHC/Driver/Flags.hs
@@ -536,7 +536,7 @@ data WarningFlag =
| Opt_WarnMissingKindSignatures -- Since 9.2
| Opt_WarnMissingExportedPatternSynonymSignatures -- since 9.2
| Opt_WarnRedundantStrictnessFlags -- Since 9.4
- deriving (Eq, Show, Enum)
+ deriving (Eq, Ord, Show, Enum)
-- | Return the names of a WarningFlag
--
@@ -787,4 +787,3 @@ unusedBindsFlags = [ Opt_WarnUnusedTopBinds
, Opt_WarnUnusedLocalBinds
, Opt_WarnUnusedPatternBinds
]
-
diff --git a/compiler/GHC/Driver/Session.hs b/compiler/GHC/Driver/Session.hs
index 8f1cd31ece..aaedf4f2d7 100644
--- a/compiler/GHC/Driver/Session.hs
+++ b/compiler/GHC/Driver/Session.hs
@@ -268,6 +268,7 @@ import Data.Ord
import Data.Char
import Data.List (intercalate, sortBy)
import qualified Data.List.NonEmpty as NE
+import qualified Data.Map as Map
import qualified Data.Set as Set
import System.FilePath
import System.Directory
@@ -3084,9 +3085,10 @@ nop _ = return ()
-- | Find the 'FlagSpec' for a 'WarningFlag'.
flagSpecOf :: WarningFlag -> Maybe (FlagSpec WarningFlag)
-flagSpecOf flag = listToMaybe $ filter check wWarningFlags
- where
- check fs = flagSpecFlag fs == flag
+flagSpecOf = flip Map.lookup wWarningFlagMap
+
+wWarningFlagMap :: Map.Map WarningFlag (FlagSpec WarningFlag)
+wWarningFlagMap = Map.fromListWith (\_ x -> x) $ map (flagSpecFlag &&& id) wWarningFlags
-- | These @-W\<blah\>@ flags can all be reversed with @-Wno-\<blah\>@
wWarningFlags :: [FlagSpec WarningFlag]