Commit 0a5f2918 authored by Sylvain Henry's avatar Sylvain Henry Committed by Marge Bot

Parser: don't require the HomeUnitId

The HomeUnitId is only used by the Cmm parser and this one has access to
the DynFlags, so it can grab the UnitId of the HomeUnit from them.

Bump haddock submodule
parent 7fdcce6d
Pipeline #26271 failed with stages
in 552 minutes and 25 seconds
......@@ -20,7 +20,7 @@ import GHC.Prelude
import GHC.Cmm.Expr
import GHC.Parser.Lexer
import GHC.Cmm.Monad
import GHC.Cmm.Parser.Monad
import GHC.Types.SrcLoc
import GHC.Types.Unique.FM
import GHC.Data.StringBuffer
......
This diff is collapsed.
......@@ -7,13 +7,14 @@
-- The parser for C-- requires access to a lot more of the 'DynFlags',
-- so 'PD' provides access to 'DynFlags' via a 'HasDynFlags' instance.
-----------------------------------------------------------------------------
module GHC.Cmm.Monad (
module GHC.Cmm.Parser.Monad (
PD(..)
, liftP
, failMsgPD
, getProfile
, getPlatform
, getPtrOpts
, getHomeUnitId
) where
import GHC.Prelude
......@@ -28,6 +29,8 @@ import GHC.Driver.Session
import GHC.Parser.Lexer
import GHC.Parser.Errors
import GHC.Types.SrcLoc
import GHC.Unit.Types
import GHC.Unit.Home
newtype PD a = PD { unPD :: DynFlags -> PState -> ParseResult a }
......@@ -73,3 +76,9 @@ getPtrOpts = do
{ po_profile = profile
, po_align_check = gopt Opt_AlignmentSanitisation dflags
}
-- | Return the UnitId of the home-unit. This is used to create labels.
getHomeUnitId :: PD UnitId
getHomeUnitId = do
dflags <- getDynFlags
pure (homeUnitId (mkHomeUnitFromFlags dflags))
......@@ -32,7 +32,6 @@ initParserOpts =
mkParserOpts
<$> warningFlags
<*> extensionFlags
<*> homeUnitId_
<*> safeImportsOn
<*> gopt Opt_Haddock
<*> gopt Opt_KeepRawTokenStream
......
......@@ -55,7 +55,7 @@ module GHC.Parser.Lexer (
P(..), ParseResult(..),
allocateComments,
MonadP(..),
getRealSrcLoc, getPState, withHomeUnitId,
getRealSrcLoc, getPState,
failMsgP, failLocMsgP, srcParseFail,
getErrorMessages, getMessages,
popContext, pushModuleContext, setLastToken, setSrcLoc,
......@@ -104,7 +104,6 @@ import GHC.Data.OrdList
import GHC.Utils.Misc ( readRational, readHexRational )
import GHC.Types.SrcLoc
import GHC.Unit.Types
import GHC.Types.Basic ( InlineSpec(..), RuleMatchInfo(..),
IntegralLit(..), FractionalLit(..),
SourceText(..) )
......@@ -2210,10 +2209,8 @@ warnopt f options = f `EnumSet.member` pWarningFlags options
-- | Parser options.
--
-- See 'mkParserOpts' to construct this.
data ParserOpts = ParserOpts {
pWarningFlags :: EnumSet WarningFlag
, pHomeUnitId :: UnitId -- ^ id of the unit currently being compiled
-- (only used in Cmm parser)
data ParserOpts = ParserOpts
{ pWarningFlags :: EnumSet WarningFlag -- ^ enabled warning flags
, pExtsBitmap :: !ExtsBitmap -- ^ bitmap of permitted extensions
}
......@@ -2322,9 +2319,6 @@ failLocMsgP loc1 loc2 f =
getPState :: P PState
getPState = P $ \s -> POk s s
withHomeUnitId :: (UnitId -> a) -> P a
withHomeUnitId f = P $ \s@(PState{options = o}) -> POk s (f (pHomeUnitId o))
getExts :: P ExtsBitmap
getExts = P $ \s -> POk s (pExtsBitmap . options $ s)
......@@ -2637,8 +2631,6 @@ data ExtBits
mkParserOpts
:: EnumSet WarningFlag -- ^ warnings flags enabled
-> EnumSet LangExt.Extension -- ^ permitted language extensions enabled
-> UnitId -- ^ id of the unit currently being compiled
-- (used in Cmm parser)
-> Bool -- ^ are safe imports on?
-> Bool -- ^ keeping Haddock comment tokens
-> Bool -- ^ keep regular comment tokens
......@@ -2650,11 +2642,10 @@ mkParserOpts
-> ParserOpts
-- ^ Given exactly the information needed, set up the 'ParserOpts'
mkParserOpts warningFlags extensionFlags homeUnitId
mkParserOpts warningFlags extensionFlags
safeImports isHaddock rawTokStream usePosPrags =
ParserOpts {
pWarningFlags = warningFlags
, pHomeUnitId = homeUnitId
, pExtsBitmap = safeHaskellBit .|. langExtBits .|. optBits
}
where
......
......@@ -239,7 +239,7 @@ Library
GHC.Cmm.Lint
GHC.Cmm.Liveness
GHC.Cmm.MachOp
GHC.Cmm.Monad
GHC.Cmm.Parser.Monad
GHC.Cmm.Switch
GHC.Cmm.Node
GHC.Cmm.Opt
......
Subproject commit 7b5972402afad755cd45aaad1a96aac509e9d5d2
Subproject commit 6f16399e0320d0ef5e6c3dd0329ce7ed3715b6b2
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment