Monotonic locations (#17632)
When GHC is parsing a file generated by a tool, e.g. by the C preprocessor, the tool may insert #line pragmas to adjust the locations reported to the user. As the result, the locations recorded in RealSrcLoc are not monotonic. Elements that appear later in the StringBuffer are not guaranteed to have a higher line/column number. In fact, there are no guarantees whatsoever, as #line pragmas can arbitrarily modify locations. This lack of guarantees makes ideas such as #17544 infeasible. This patch adds an additional bit of information to every SrcLoc: newtype BufPos = BufPos { bufPos :: Int } A BufPos represents the location in the StringBuffer, unaffected by any pragmas. Updates haddock submodule. Metric Increase: haddock.Cabal haddock.base haddock.compiler MultiLayerModules Naperian parsing001 T12150
Showing
- compiler/GHC.hs 3 additions, 3 deletionscompiler/GHC.hs
- compiler/GHC/Cmm/Lexer.x 10 additions, 10 deletionscompiler/GHC/Cmm/Lexer.x
- compiler/GHC/Cmm/Parser.y 1 addition, 1 deletioncompiler/GHC/Cmm/Parser.y
- compiler/GHC/CoreToStg/Prep.hs 1 addition, 1 deletioncompiler/GHC/CoreToStg/Prep.hs
- compiler/GHC/HsToCore/Coverage.hs 5 additions, 5 deletionscompiler/GHC/HsToCore/Coverage.hs
- compiler/GHC/HsToCore/Docs.hs 2 additions, 2 deletionscompiler/GHC/HsToCore/Docs.hs
- compiler/GHC/HsToCore/Expr.hs 2 additions, 1 deletioncompiler/GHC/HsToCore/Expr.hs
- compiler/GHC/HsToCore/Monad.hs 2 additions, 2 deletionscompiler/GHC/HsToCore/Monad.hs
- compiler/GHC/HsToCore/PmCheck.hs 2 additions, 2 deletionscompiler/GHC/HsToCore/PmCheck.hs
- compiler/GHC/Iface/Ext/Ast.hs 5 additions, 5 deletionscompiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Iface/Ext/Utils.hs 7 additions, 7 deletionscompiler/GHC/Iface/Ext/Utils.hs
- compiler/GHC/Rename/Names.hs 1 addition, 1 deletioncompiler/GHC/Rename/Names.hs
- compiler/GHC/Rename/Unbound.hs 1 addition, 1 deletioncompiler/GHC/Rename/Unbound.hs
- compiler/basicTypes/Name.hs 1 addition, 1 deletioncompiler/basicTypes/Name.hs
- compiler/basicTypes/RdrName.hs 1 addition, 1 deletioncompiler/basicTypes/RdrName.hs
- compiler/basicTypes/SrcLoc.hs 127 additions, 27 deletionscompiler/basicTypes/SrcLoc.hs
- compiler/main/ErrUtils.hs 1 addition, 1 deletioncompiler/main/ErrUtils.hs
- compiler/main/HeaderInfo.hs 2 additions, 2 deletionscompiler/main/HeaderInfo.hs
- compiler/parser/Lexer.x 117 additions, 106 deletionscompiler/parser/Lexer.x
- compiler/parser/Parser.y 2 additions, 2 deletionscompiler/parser/Parser.y
Loading
Please register or sign in to comment