File tree Expand file tree Collapse file tree 3 files changed +55
-9
lines changed
Expand file tree Collapse file tree 3 files changed +55
-9
lines changed Original file line number Diff line number Diff line change 11open DeadCommon
22
3- let declarations = Hashtbl. create 1
3+ module PathMap = Map. Make (struct
4+ type t = DcePath .t
5+
6+ let compare = Stdlib. compare
7+ end )
8+
9+ let find_exception_from_decls (decls : Declarations.t ) :
10+ DcePath. t -> Location. t option =
11+ let index =
12+ Declarations. fold
13+ (fun _pos (decl : Decl.t ) acc ->
14+ match decl.Decl. declKind with
15+ | Exception ->
16+ (* Use raw decl positions: reference graph keys are raw positions. *)
17+ let loc : Location.t =
18+ {
19+ Location. loc_start = decl.pos;
20+ loc_end = decl.posEnd;
21+ loc_ghost = false ;
22+ }
23+ in
24+ PathMap. add decl.path loc acc
25+ | _ -> acc)
26+ decls PathMap. empty
27+ in
28+ fun path -> PathMap. find_opt path index
429
530let add ~config ~decls ~file ~path ~loc ~(strLoc : Location.t )
631 ~(moduleLoc : Location.t ) name =
7- let exceptionPath = name :: path in
8- Hashtbl. add declarations exceptionPath loc;
32+ addDeclaration_ ~config ~decls ~file ~pos End:strLoc.loc_end
33+ ~pos Start:strLoc.loc_start ~decl Kind: Exception ~module Loc ~path ~ loc name ;
934 name
10- |> addDeclaration_ ~config ~decls ~file ~pos End:strLoc.loc_end
11- ~pos Start:strLoc.loc_start ~decl Kind:Exception ~module Loc ~path ~loc
12-
13- let find_exception path = Hashtbl. find_opt declarations path
1435
1536let markAsUsed ~config ~refs ~file_deps ~cross_file ~(binding : Location.t )
1637 ~(locFrom : Location.t ) ~(locTo : Location.t ) path_ =
Original file line number Diff line number Diff line change 1+ open DeadCommon
2+
3+ val find_exception_from_decls : Declarations .t -> DcePath .t -> Location .t option
4+
5+ val add :
6+ config :DceConfig .t ->
7+ decls :Declarations .builder ->
8+ file :FileContext .t ->
9+ path :DcePath .t ->
10+ loc :Location .t ->
11+ strLoc :Location .t ->
12+ moduleLoc :Location .t ->
13+ Name .t ->
14+ Name .t
15+
16+ val markAsUsed :
17+ config :DceConfig .t ->
18+ refs :References .builder ->
19+ file_deps :FileDeps .builder ->
20+ cross_file :CrossFileItems .builder ->
21+ binding :Location .t ->
22+ locFrom :Location .t ->
23+ locTo :Location .t ->
24+ Path .t ->
25+ unit
Original file line number Diff line number Diff line change @@ -167,10 +167,10 @@ let runAnalysis ~dce_config ~cmtRoot =
167167 (* Compute type-label dependencies after merge (no global TypeLabels table during traversal) *)
168168 DeadType. process_type_label_dependencies ~config: dce_config ~decls
169169 ~refs: refs_builder;
170+ let find_exception = DeadException. find_exception_from_decls decls in
170171 (* Process cross-file exception refs - they write to refs_builder and file_deps_builder *)
171172 CrossFileItems. process_exception_refs cross_file ~refs: refs_builder
172- ~file_deps: file_deps_builder ~find_exception: DeadException. find_exception
173- ~config: dce_config;
173+ ~file_deps: file_deps_builder ~find_exception ~config: dce_config;
174174 (* Now freeze refs and file_deps for solver *)
175175 let refs = References. freeze_builder refs_builder in
176176 let file_deps = FileDeps. freeze_builder file_deps_builder in
You can’t perform that action at this time.
0 commit comments