Skip to content

Commit

Permalink
Merge pull request ocaml#12508 from voodoos/store-index-in-cmt-trunk
Browse files Browse the repository at this point in the history
[shapes] Add support for project-wide occurrences
  • Loading branch information
Octachron authored Jan 22, 2024
2 parents c94d12c + 1dcdb6b commit a682d51
Show file tree
Hide file tree
Showing 79 changed files with 2,633 additions and 692 deletions.
48 changes: 48 additions & 0 deletions .depend
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,21 @@ typing/shape.cmi : \
typing/path.cmi \
utils/identifiable.cmi \
typing/ident.cmi
typing/shape_reduce.cmo : \
typing/shape.cmi \
utils/local_store.cmi \
typing/ident.cmi \
typing/env.cmi \
typing/shape_reduce.cmi
typing/shape_reduce.cmx : \
typing/shape.cmx \
utils/local_store.cmx \
typing/ident.cmx \
typing/env.cmx \
typing/shape_reduce.cmi
typing/shape_reduce.cmi : \
typing/shape.cmi \
typing/env.cmi
typing/signature_group.cmo : \
typing/types.cmi \
typing/ident.cmi \
Expand Down Expand Up @@ -1498,6 +1513,7 @@ typing/typedecl.cmo : \
typing/typedecl_immediacy.cmi \
typing/type_immediacy.cmi \
typing/subst.cmi \
typing/shape.cmi \
typing/printtyp.cmi \
typing/primitive.cmi \
typing/predef.cmi \
Expand Down Expand Up @@ -1535,6 +1551,7 @@ typing/typedecl.cmx : \
typing/typedecl_immediacy.cmx \
typing/type_immediacy.cmx \
typing/subst.cmx \
typing/shape.cmx \
typing/printtyp.cmx \
typing/primitive.cmx \
typing/predef.cmx \
Expand Down Expand Up @@ -1566,6 +1583,7 @@ typing/typedecl.cmi : \
typing/typedecl_variance.cmi \
typing/typedecl_separability.cmi \
typing/typedecl_immediacy.cmi \
typing/shape.cmi \
typing/path.cmi \
parsing/parsetree.cmi \
parsing/longident.cmi \
Expand Down Expand Up @@ -1733,6 +1751,7 @@ typing/typemod.cmo : \
typing/typeclass.cmi \
typing/subst.cmi \
typing/signature_group.cmi \
typing/shape_reduce.cmi \
typing/shape.cmi \
typing/printtyp.cmi \
typing/path.cmi \
Expand Down Expand Up @@ -1768,6 +1787,7 @@ typing/typemod.cmx : \
typing/typeclass.cmx \
typing/subst.cmx \
typing/signature_group.cmx \
typing/shape_reduce.cmx \
typing/shape.cmx \
typing/printtyp.cmx \
typing/path.cmx \
Expand Down Expand Up @@ -4069,37 +4089,53 @@ file_formats/cmt_format.cmo : \
typing/types.cmi \
typing/typedtree.cmi \
typing/tast_mapper.cmi \
typing/tast_iterator.cmi \
typing/shape_reduce.cmi \
typing/shape.cmi \
typing/predef.cmi \
typing/path.cmi \
utils/misc.cmi \
parsing/longident.cmi \
parsing/location.cmi \
utils/load_path.cmi \
parsing/lexer.cmi \
typing/ident.cmi \
typing/env.cmi \
utils/config.cmi \
file_formats/cmi_format.cmi \
utils/clflags.cmi \
typing/btype.cmi \
file_formats/cmt_format.cmi
file_formats/cmt_format.cmx : \
parsing/unit_info.cmx \
typing/types.cmx \
typing/typedtree.cmx \
typing/tast_mapper.cmx \
typing/tast_iterator.cmx \
typing/shape_reduce.cmx \
typing/shape.cmx \
typing/predef.cmx \
typing/path.cmx \
utils/misc.cmx \
parsing/longident.cmx \
parsing/location.cmx \
utils/load_path.cmx \
parsing/lexer.cmx \
typing/ident.cmx \
typing/env.cmx \
utils/config.cmx \
file_formats/cmi_format.cmx \
utils/clflags.cmx \
typing/btype.cmx \
file_formats/cmt_format.cmi
file_formats/cmt_format.cmi : \
parsing/unit_info.cmi \
typing/types.cmi \
typing/typedtree.cmi \
typing/shape_reduce.cmi \
typing/shape.cmi \
utils/misc.cmi \
parsing/longident.cmi \
parsing/location.cmi \
utils/load_path.cmi \
typing/env.cmi \
Expand Down Expand Up @@ -6688,6 +6724,7 @@ toplevel/byte/topeval.cmo : \
toplevel/topcommon.cmi \
bytecomp/symtable.cmi \
lambda/simplif.cmi \
typing/shape_reduce.cmi \
typing/shape.cmi \
typing/printtyped.cmi \
typing/printtyp.cmi \
Expand Down Expand Up @@ -6722,6 +6759,7 @@ toplevel/byte/topeval.cmx : \
toplevel/topcommon.cmx \
bytecomp/symtable.cmx \
lambda/simplif.cmx \
typing/shape_reduce.cmx \
typing/shape.cmx \
typing/printtyped.cmx \
typing/printtyp.cmx \
Expand Down Expand Up @@ -6825,6 +6863,7 @@ toplevel/native/topeval.cmo : \
toplevel/native/tophooks.cmi \
toplevel/topcommon.cmi \
lambda/simplif.cmi \
typing/shape_reduce.cmi \
typing/shape.cmi \
typing/printtyped.cmi \
typing/printtyp.cmi \
Expand Down Expand Up @@ -6856,6 +6895,7 @@ toplevel/native/topeval.cmx : \
toplevel/native/tophooks.cmx \
toplevel/topcommon.cmx \
lambda/simplif.cmx \
typing/shape_reduce.cmx \
typing/shape.cmx \
typing/printtyped.cmx \
typing/printtyp.cmx \
Expand Down Expand Up @@ -7148,11 +7188,15 @@ tools/make_opcodes.cmx : \
tools/make_opcodes.cmi
tools/make_opcodes.cmi :
tools/objinfo.cmo : \
typing/typedtree.cmi \
bytecomp/symtable.cmi \
middle_end/symbol.cmi \
typing/shape_reduce.cmi \
typing/shape.cmi \
middle_end/printclambda.cmi \
parsing/pprintast.cmi \
utils/misc.cmi \
parsing/location.cmi \
middle_end/linkage_name.cmi \
typing/ident.cmi \
middle_end/flambda/export_info.cmi \
Expand All @@ -7166,11 +7210,15 @@ tools/objinfo.cmo : \
utils/binutils.cmi \
tools/objinfo.cmi
tools/objinfo.cmx : \
typing/typedtree.cmx \
bytecomp/symtable.cmx \
middle_end/symbol.cmx \
typing/shape_reduce.cmx \
typing/shape.cmx \
middle_end/printclambda.cmx \
parsing/pprintast.cmx \
utils/misc.cmx \
parsing/location.cmx \
middle_end/linkage_name.cmx \
typing/ident.cmx \
middle_end/flambda/export_info.cmx \
Expand Down
6 changes: 6 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,12 @@ OCaml 5.2.0
- #12764: Move all installable headers in `caml/` sub-directories.
(Antonin Décimo, review by Gabriel Scherer and David Allsopp)

- #12508 : Add compiler-side support for project-wide occurrences in Merlin, by
generating index tables of all identifier occurrences. This extra data in .cmt
files is only added when the new flag -bin-annot-occurrences is passed.
(Ulysse Gérard, Nathanaëlle Courant, suggestions by Gabriel Scherer and Thomas
Refis, review by Florian Angeletti, Gabriel Scherer and Thomas Refis)

### Build system:

- #12198, #12321, #12586, #12616, #12706: continue the merge of the
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ typing_SOURCES = \
typing/tast_iterator.mli typing/tast_iterator.ml \
typing/tast_mapper.mli typing/tast_mapper.ml \
typing/stypes.mli typing/stypes.ml \
typing/shape_reduce.mli typing/shape_reduce.ml \
file_formats/cmt_format.mli file_formats/cmt_format.ml \
typing/cmt2annot.mli typing/cmt2annot.ml \
typing/untypeast.mli typing/untypeast.ml \
Expand Down
11 changes: 11 additions & 0 deletions driver/main_args.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ let mk_annot f =
let mk_binannot f =
"-bin-annot", Arg.Unit f, " Save typedtree in <filename>.cmt"

let mk_binannot_occurrences f =
"-bin-annot-occurrences", Arg.Unit f,
" Store every occurrence of a bound name in the .cmt file.\n\
This information can be used by external tools to provide\n\
features such as project-wide occurrences. This flag has\n\
no effect in the absence of '-bin-annot'."

let mk_c f =
"-c", Arg.Unit f, " Compile only (do not link)"

Expand Down Expand Up @@ -820,6 +827,7 @@ module type Compiler_options = sig
val _a : unit -> unit
val _annot : unit -> unit
val _binannot : unit -> unit
val _binannot_occurrences : unit -> unit
val _c : unit -> unit
val _cc : string -> unit
val _cclib : string -> unit
Expand Down Expand Up @@ -1015,6 +1023,7 @@ struct
mk_no_absname F._no_absname;
mk_annot F._annot;
mk_binannot F._binannot;
mk_binannot_occurrences F._binannot_occurrences;
mk_c F._c;
mk_cc F._cc;
mk_cclib F._cclib;
Expand Down Expand Up @@ -1208,6 +1217,7 @@ struct
mk_afl_inst_ratio F._afl_inst_ratio;
mk_annot F._annot;
mk_binannot F._binannot;
mk_binannot_occurrences F._binannot_occurrences;
mk_inline_branch_factor F._inline_branch_factor;
mk_c F._c;
mk_cc F._cc;
Expand Down Expand Up @@ -1736,6 +1746,7 @@ module Default = struct
let _args = Arg.read_arg
let _args0 = Arg.read_arg0
let _binannot = set binary_annotations
let _binannot_occurrences = set store_occurrences
let _c = set compile_only
let _cc s = c_compiler := (Some s)
let _cclib s = Compenv.defer (ProcessObjects (Misc.rev_split_words s))
Expand Down
1 change: 1 addition & 0 deletions driver/main_args.mli
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ module type Compiler_options = sig
val _a : unit -> unit
val _annot : unit -> unit
val _binannot : unit -> unit
val _binannot_occurrences : unit -> unit
val _c : unit -> unit
val _cc : string -> unit
val _cclib : string -> unit
Expand Down
Loading

0 comments on commit a682d51

Please sign in to comment.