Skip to content

Commit e95fb10

Browse files
stroxlerfacebook-github-bot
authored andcommitted
Rename Callable -> Target [1/n] rename module
Summary: We decided recently to rename many of the interprocedural modules to better reflect what they actually do, and also minimize collisions with `Analysis` module names. The one rename that we decided made sense but we put off at first was `Callable -> Target`... this rename is desirable because (a) we already have non-callable targets in taint and (b) there's an open wish-list item to allow tracking taint through attributes. But it will take quite a while to rename all the various functions and variables that have `callable` in the name. This is the first commit of a rename, and by far the biggest bulk commit we need to make, it renames the module without changing anything else. After we land this, I can go through this change line-by-line as well as use code search to identify variables and functions that need renames in much smaller follow-up diffs. Reviewed By: grievejia Differential Revision: D30184905 fbshipit-source-id: f5cedb9da53fa3e0280a1c857f339f6c7271fd1d
1 parent 208a012 commit e95fb10

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+493
-518
lines changed

source/command/analyzeCommand.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ let run_analysis
167167
~environment:(Analysis.TypeEnvironment.read_only environment)
168168
~functions:
169169
(List.map callables_with_dependency_information ~f:fst
170-
:> Interprocedural.Callable.t list)
171-
~stubs:(stubs :> Interprocedural.Callable.t list)
170+
:> Interprocedural.Target.t list)
171+
~stubs:(stubs :> Interprocedural.Target.t list)
172172
in
173173

174174
let environment, initial_callables =

source/command/inferCommand.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ let run_infer_interprocedural
138138
~environment
139139
~qualifiers
140140
~initial_callables
141-
~initial_models:Interprocedural.Callable.Map.empty
141+
~initial_models:Interprocedural.Target.Map.empty
142142
~skip_overrides:Ast.Reference.Set.empty
143143
();
144144
let { Caml.Gc.minor_collections; major_collections; compactions; _ } = Caml.Gc.stat () in

source/command/newInferCommand.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ let run_infer_interprocedural ~configuration ~build_system () =
293293
~environment
294294
~qualifiers
295295
~initial_callables
296-
~initial_models:Interprocedural.Callable.Map.empty
296+
~initial_models:Interprocedural.Target.Map.empty
297297
~skip_overrides:Ast.Reference.Set.empty
298298
()));
299299
Lwt.return ExitStatus.Ok

source/interprocedural/analysisResult.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ type 'part pkg =
7474

7575
module InitializedModels = struct
7676
type 'call_model initialize_result = {
77-
initial_models: 'call_model Callable.Map.t;
77+
initial_models: 'call_model Target.Map.t;
7878
skip_overrides: Ast.Reference.Set.t;
7979
}
8080

@@ -85,7 +85,7 @@ module InitializedModels = struct
8585

8686
let empty =
8787
create (fun ~updated_environment:_ ->
88-
{ initial_models = Callable.Map.empty; skip_overrides = Ast.Reference.Set.empty })
88+
{ initial_models = Target.Map.empty; skip_overrides = Ast.Reference.Set.empty })
8989

9090

9191
let get_models f = f ~updated_environment:None
@@ -102,7 +102,7 @@ module type ANALYZER = sig
102102

103103
val analyze
104104
: environment:Analysis.TypeEnvironment.ReadOnly.t ->
105-
callable:Callable.real_target ->
105+
callable:Target.real_target ->
106106
qualifier:Reference.t ->
107107
define:Define.t Node.t ->
108108
existing:call_model option ->
@@ -118,16 +118,16 @@ module type ANALYZER = sig
118118
: scheduler:Scheduler.t ->
119119
static_analysis_configuration:Configuration.StaticAnalysis.t ->
120120
environment:Analysis.TypeEnvironment.ReadOnly.t ->
121-
functions:Callable.t list ->
122-
stubs:Callable.t list ->
121+
functions:Target.t list ->
122+
stubs:Target.t list ->
123123
call_model InitializedModels.t
124124

125125
val report
126126
: scheduler:Scheduler.t ->
127127
static_analysis_configuration:Configuration.StaticAnalysis.t ->
128128
environment:Analysis.TypeEnvironment.ReadOnly.t ->
129129
filename_lookup:(Ast.Reference.t -> string option) ->
130-
callables:Callable.Set.t ->
130+
callables:Target.Set.t ->
131131
skipped_overrides:Ast.Reference.t list ->
132132
fixpoint_timer:Timer.t ->
133133
fixpoint_iterations:int option ->

source/interprocedural/analysisResult.mli

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ module InitializedModels : sig
8585
type 'call_model t
8686

8787
type 'call_model initialize_result = {
88-
initial_models: 'call_model Callable.Map.t;
88+
initial_models: 'call_model Target.Map.t;
8989
skip_overrides: Ast.Reference.Set.t;
9090
}
9191

@@ -114,7 +114,7 @@ module type ANALYZER = sig
114114

115115
val analyze
116116
: environment:Analysis.TypeEnvironment.ReadOnly.t ->
117-
callable:Callable.real_target ->
117+
callable:Target.real_target ->
118118
qualifier:Reference.t ->
119119
define:Statement.Define.t Node.t ->
120120
existing:call_model option ->
@@ -130,16 +130,16 @@ module type ANALYZER = sig
130130
: scheduler:Scheduler.t ->
131131
static_analysis_configuration:Configuration.StaticAnalysis.t ->
132132
environment:Analysis.TypeEnvironment.ReadOnly.t ->
133-
functions:Callable.t list ->
134-
stubs:Callable.t list ->
133+
functions:Target.t list ->
134+
stubs:Target.t list ->
135135
call_model InitializedModels.t
136136

137137
val report
138138
: scheduler:Scheduler.t ->
139139
static_analysis_configuration:Configuration.StaticAnalysis.t ->
140140
environment:Analysis.TypeEnvironment.ReadOnly.t ->
141141
filename_lookup:(Ast.Reference.t -> string option) ->
142-
callables:Callable.Set.t ->
142+
callables:Target.Set.t ->
143143
skipped_overrides:Ast.Reference.t list ->
144144
fixpoint_timer:Timer.t ->
145145
fixpoint_iterations:int option ->

source/interprocedural/callGraph.ml

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ open Pyre
1515
type regular_targets = {
1616
implicit_self: bool;
1717
collapse_tito: bool;
18-
targets: Callable.t list;
18+
targets: Target.t list;
1919
}
2020
[@@deriving eq, show { with_path = false }]
2121

2222
type raw_callees =
2323
| ConstructorTargets of {
24-
new_targets: Callable.t list;
25-
init_targets: Callable.t list;
24+
new_targets: Target.t list;
25+
init_targets: Target.t list;
2626
}
2727
| RegularTargets of regular_targets
2828
| HigherOrderTargets of {
@@ -218,9 +218,9 @@ let compute_indirect_targets ~resolution ~receiver_type implementation_target =
218218
let get_class_type = GlobalResolution.parse_reference global_resolution in
219219
let get_actual_target method_name =
220220
if DependencyGraphSharedMemory.overrides_exist method_name then
221-
Callable.create_override method_name
221+
Target.create_override method_name
222222
else
223-
Callable.create_method method_name
223+
Target.create_method method_name
224224
in
225225
let receiver_type = receiver_type |> strip_meta |> strip_optional |> Type.weaken_literals in
226226
let declaring_type = Reference.prefix implementation_target in
@@ -231,7 +231,7 @@ let compute_indirect_targets ~resolution ~receiver_type implementation_target =
231231
then (* case a *)
232232
[get_actual_target implementation_target]
233233
else
234-
let target_callable = Callable.create_method implementation_target in
234+
let target_callable = Target.create_method implementation_target in
235235
match DependencyGraphSharedMemory.get_overriding_types ~member:implementation_target with
236236
| None ->
237237
(* case b *)
@@ -304,15 +304,15 @@ let rec resolve_callees_from_type
304304
| Some receiver_type ->
305305
let targets =
306306
match callee_kind with
307-
| Method { is_direct_call = true } -> [Callable.create_method name]
307+
| Method { is_direct_call = true } -> [Target.create_method name]
308308
| _ -> compute_indirect_targets ~resolution ~receiver_type name
309309
in
310310
Some (RegularTargets { implicit_self = true; targets; collapse_tito })
311311
| None ->
312312
let target =
313313
match callee_kind with
314-
| Method _ -> Callable.create_method name
315-
| _ -> Callable.create_function name
314+
| Method _ -> Target.create_method name
315+
| _ -> Target.create_function name
316316
in
317317
Some (RegularTargets { implicit_self = false; targets = [target]; collapse_tito }))
318318
| Type.Callable { kind = Anonymous; _ } -> None
@@ -355,7 +355,7 @@ let rec resolve_callees_from_type
355355
targets =
356356
[
357357
`Method
358-
{ Callable.class_name = primitive_callable_name; method_name = "__call__" };
358+
{ Target.class_name = primitive_callable_name; method_name = "__call__" };
359359
];
360360
collapse_tito;
361361
})
@@ -585,7 +585,7 @@ let resolve_callees_ignoring_decorators ~resolution ~collapse_tito callee =
585585
(RegularTargets
586586
{
587587
implicit_self = not static;
588-
targets = [`Method { Callable.class_name; method_name = attribute }];
588+
targets = [`Method { Target.class_name; method_name = attribute }];
589589
collapse_tito;
590590
})
591591
| _ -> None)
@@ -606,7 +606,7 @@ let resolve_callees_ignoring_decorators ~resolution ~collapse_tito callee =
606606
(RegularTargets
607607
{
608608
implicit_self = true;
609-
targets = [`Method { Callable.class_name; method_name = attribute }];
609+
targets = [`Method { Target.class_name; method_name = attribute }];
610610
collapse_tito;
611611
})
612612
| _ -> None)
@@ -669,18 +669,18 @@ let resolve_property_targets ~resolution ~base ~attribute ~setter =
669669
let targets =
670670
let receiver_type = resolve_ignoring_optional ~resolution base in
671671
if Type.is_meta receiver_type then
672-
[Callable.create_method (Reference.create ~prefix:parent attribute)]
672+
[Target.create_method (Reference.create ~prefix:parent attribute)]
673673
else
674674
let callee = Reference.create ~prefix:parent attribute in
675675
compute_indirect_targets ~resolution ~receiver_type callee
676676
in
677677
if setter then
678678
let to_setter target =
679679
match target with
680-
| `OverrideTarget { Callable.class_name; method_name } ->
681-
`OverrideTarget { Callable.class_name; method_name = method_name ^ "$setter" }
682-
| `Method { Callable.class_name; method_name } ->
683-
`Method { Callable.class_name; method_name = method_name ^ "$setter" }
680+
| `OverrideTarget { Target.class_name; method_name } ->
681+
`OverrideTarget { Target.class_name; method_name = method_name ^ "$setter" }
682+
| `Method { Target.class_name; method_name } ->
683+
`Method { Target.class_name; method_name = method_name ^ "$setter" }
684684
| _ -> target
685685
in
686686
List.map targets ~f:to_setter
@@ -864,7 +864,7 @@ let call_graph_of_define
864864
value))
865865
in
866866
let deduplicate callees =
867-
let deduplicate_targets targets = List.dedup_and_sort ~compare:Callable.compare targets in
867+
let deduplicate_targets targets = List.dedup_and_sort ~compare:Target.compare targets in
868868
let deduplicate_regular_targets { targets; implicit_self; collapse_tito } =
869869
{ targets = deduplicate_targets targets; implicit_self; collapse_tito }
870870
in
@@ -896,7 +896,7 @@ let call_graph_of_define
896896
module SharedMemory = struct
897897
include
898898
Memory.WithCache.Make
899-
(Callable.RealKey)
899+
(Target.RealKey)
900900
(struct
901901
type t = callees Location.Map.Tree.t
902902

@@ -930,7 +930,7 @@ let create_callgraph ?(use_shared_memory = false) ~environment ~source =
930930
let call_graph_of_define =
931931
if use_shared_memory then
932932
SharedMemory.get_or_compute
933-
~callable:(Callable.create define)
933+
~callable:(Target.create define)
934934
~environment
935935
~define:(Node.value define)
936936
else
@@ -955,9 +955,8 @@ let create_callgraph ?(use_shared_memory = false) ~environment ~source =
955955
in
956956
Location.Map.data call_graph_of_define
957957
|> List.concat_map ~f:callees
958-
|> List.dedup_and_sort ~compare:Callable.compare
959-
|> fun callees ->
960-
Callable.RealMap.set dependencies ~key:(Callable.create define) ~data:callees
958+
|> List.dedup_and_sort ~compare:Target.compare
959+
|> fun callees -> Target.RealMap.set dependencies ~key:(Target.create define) ~data:callees
961960
in
962961
Preprocessing.defines ~include_nested:true source
963-
|> List.fold ~init:Callable.RealMap.empty ~f:fold_defines
962+
|> List.fold ~init:Target.RealMap.empty ~f:fold_defines

source/interprocedural/callGraph.mli

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ open Expression
1313
type regular_targets = {
1414
implicit_self: bool;
1515
collapse_tito: bool;
16-
targets: Callable.t list;
16+
targets: Target.t list;
1717
}
1818
[@@deriving eq, show]
1919

2020
type raw_callees =
2121
| ConstructorTargets of {
22-
new_targets: Callable.t list;
23-
init_targets: Callable.t list;
22+
new_targets: Target.t list;
23+
init_targets: Target.t list;
2424
}
2525
| RegularTargets of regular_targets
2626
| HigherOrderTargets of {
@@ -48,17 +48,17 @@ val resolve_ignoring_optional : resolution:Resolution.t -> Ast.Expression.t -> T
4848
val redirect_special_calls : resolution:Resolution.t -> Call.t -> Call.t
4949

5050
module SharedMemory : sig
51-
val add : callable:Callable.real_target -> callees:callees Location.Map.t -> unit
51+
val add : callable:Target.real_target -> callees:callees Location.Map.t -> unit
5252

5353
(* Attempts to read the call graph for the given callable from shared memory. If it doesn't exist,
5454
computes the call graph and writes to shard memory. *)
5555
val get_or_compute
56-
: callable:Callable.real_target ->
56+
: callable:Target.real_target ->
5757
environment:Analysis.TypeEnvironment.ReadOnly.t ->
5858
define:Ast.Statement.Define.t ->
5959
callees Ast.Location.Map.t
6060

61-
val remove : Callable.real_target list -> unit
61+
val remove : Target.real_target list -> unit
6262
end
6363

6464
val create_callgraph

0 commit comments

Comments
 (0)