Zubin pushed to branch wip/26135 at Glasgow Haskell Compiler / GHC
Commits:
-
6997abfc
by Zubin Duggal at 2025-06-24T16:32:03+05:30
3 changed files:
- compiler/GHC/Driver/Main.hs
- compiler/GHC/Types/Name/Cache.hs
- testsuite/tests/hiefile/should_run/TestUtils.hs
Changes:
| ... | ... | @@ -245,7 +245,7 @@ import GHC.Types.IPE |
| 245 | 245 | import GHC.Types.SourceFile
|
| 246 | 246 | import GHC.Types.SrcLoc
|
| 247 | 247 | import GHC.Types.Name
|
| 248 | -import GHC.Types.Name.Cache ( newNameCache, knownKeysOrigNameCache )
|
|
| 248 | +import GHC.Types.Name.Cache ( newNameCache )
|
|
| 249 | 249 | import GHC.Types.Name.Reader
|
| 250 | 250 | import GHC.Types.Name.Ppr
|
| 251 | 251 | import GHC.Types.TyThing
|
| ... | ... | @@ -322,7 +322,7 @@ newHscEnv top_dir dflags = do |
| 322 | 322 | |
| 323 | 323 | newHscEnvWithHUG :: FilePath -> DynFlags -> UnitId -> HomeUnitGraph -> IO HscEnv
|
| 324 | 324 | newHscEnvWithHUG top_dir top_dynflags cur_unit home_unit_graph = do
|
| 325 | - nc_var <- newNameCache 'r' knownKeysOrigNameCache
|
|
| 325 | + nc_var <- newNameCache
|
|
| 326 | 326 | fc_var <- initFinderCache
|
| 327 | 327 | logger <- initLogger
|
| 328 | 328 | tmpfs <- initTmpFs
|
| ... | ... | @@ -4,6 +4,7 @@ |
| 4 | 4 | module GHC.Types.Name.Cache
|
| 5 | 5 | ( NameCache (..)
|
| 6 | 6 | , newNameCache
|
| 7 | + , newNameCache'
|
|
| 7 | 8 | , initNameCache
|
| 8 | 9 | , takeUniqFromNameCache
|
| 9 | 10 | , updateNameCache'
|
| ... | ... | @@ -140,11 +141,27 @@ extendOrigNameCache nc mod occ name |
| 140 | 141 | where
|
| 141 | 142 | combine _ occ_env = extendOccEnv occ_env occ name
|
| 142 | 143 | |
| 143 | -newNameCache :: Char -> OrigNameCache -> IO NameCache
|
|
| 144 | -newNameCache c nc = NameCache c <$> newMVar nc
|
|
| 144 | +-- | Initialize a new name cache
|
|
| 145 | +newNameCache :: IO NameCache
|
|
| 146 | +newNameCache = newNameCache' 'r' knownKeysOrigNameCache
|
|
| 145 | 147 | |
| 148 | +-- | This is a version of `newNameCache` that lets you supply your
|
|
| 149 | +-- own unique tag and set of known key names. This can go wrong if the tag
|
|
| 150 | +-- supplied is one reserved by GHC for internal purposes. See #26055 for
|
|
| 151 | +-- an example.
|
|
| 152 | +--
|
|
| 153 | +-- Use `newNameCache` when possible.
|
|
| 154 | +newNameCache' :: Char -> OrigNameCache -> IO NameCache
|
|
| 155 | +newNameCache' c nc = NameCache c <$> newMVar nc
|
|
| 156 | + |
|
| 157 | +-- | This takes a tag for uniques to be generated and the list of knownKeyNames
|
|
| 158 | +-- These must be initialized properly to ensure that names generated from this
|
|
| 159 | +-- NameCache do not conflict with known key names.
|
|
| 160 | +--
|
|
| 161 | +-- Use `newNameCache` or `newNameCache'` instead
|
|
| 162 | +{-# DEPRECATED initNameCache "Use newNameCache or newNameCache' instead" #-}
|
|
| 146 | 163 | initNameCache :: Char -> [Name] -> IO NameCache
|
| 147 | -initNameCache c names = newNameCache c (initOrigNames names)
|
|
| 164 | +initNameCache c names = newNameCache' c (initOrigNames names)
|
|
| 148 | 165 | |
| 149 | 166 | initOrigNames :: [Name] -> OrigNameCache
|
| 150 | 167 | initOrigNames names = foldl' extendOrigNameCache' emptyModuleEnv names
|
| ... | ... | @@ -25,9 +25,6 @@ import GHC.Iface.Ext.Utils |
| 25 | 25 | import GHC.Driver.Session
|
| 26 | 26 | import GHC.SysTools
|
| 27 | 27 | |
| 28 | -makeNc :: IO NameCache
|
|
| 29 | -makeNc = initNameCache 'z' []
|
|
| 30 | - |
|
| 31 | 28 | dynFlagsForPrinting :: String -> IO DynFlags
|
| 32 | 29 | dynFlagsForPrinting libdir = do
|
| 33 | 30 | systemSettings <- initSysTools libdir
|
| ... | ... | @@ -37,7 +34,7 @@ readTestHie :: FilePath -> IO (DynFlags, HieFile) |
| 37 | 34 | readTestHie fp = do
|
| 38 | 35 | libdir:_ <- getArgs
|
| 39 | 36 | df <- dynFlagsForPrinting libdir
|
| 40 | - nc <- makeNc
|
|
| 37 | + nc <- newNameCache
|
|
| 41 | 38 | hfr <- readHieFile nc fp
|
| 42 | 39 | pure (df, hie_file_result hfr)
|
| 43 | 40 |