Skip to content

Commit 885beed

Browse files
Cristiano CalcagnoFacebook Github Bot 1
authored andcommitted
Convert the Intermediate Representation to Reason.
Reviewed By: jberdine Differential Revision: D3138490 fbshipit-source-id: e3b53fa
1 parent bf7287e commit 885beed

54 files changed

Lines changed: 11241 additions & 9566 deletions

Some content is hidden

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

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ AC_PREREQ([2.63])
1717
AC_INIT([Infer],
1818
[0.8.1],
1919
[https://github.com/facebook/infer/issues/])
20-
AC_CONFIG_SRCDIR([infer/src/IR/sil.ml])
20+
AC_CONFIG_SRCDIR([infer/src/IR/Sil.re])
2121

2222
# WARNING: keep in sync with above
2323
INFER_MAJOR=0

infer/src/IR/AttributesTable.re

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* Copyright (c) 2015 - present Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
10+
open! Utils;
11+
12+
let module F = Format;
13+
14+
let module L = Logging;
15+
16+
17+
/** Module to manage the table of attributes. */
18+
let serializer: Serialization.serializer ProcAttributes.t = Serialization.create_serializer Serialization.attributes_key;
19+
20+
let attributes_filename pname => {
21+
let pname_file = Procname.to_filename pname;
22+
pname_file ^ ".attr"
23+
};
24+
25+
26+
/** path to the .attr file for the given procedure in the current results directory */
27+
let res_dir_attr_filename pname => {
28+
let attr_fname = attributes_filename pname;
29+
let bucket_dir = {
30+
let base = Filename.chop_extension attr_fname;
31+
let len = String.length base;
32+
if (len < 2) {
33+
Filename.current_dir_name
34+
} else {
35+
String.sub base (len - 2) 2
36+
}
37+
};
38+
let filename =
39+
DB.Results_dir.path_to_filename
40+
DB.Results_dir.Abs_root [Config.attributes_dir_name, bucket_dir, attr_fname];
41+
DB.filename_create_dir filename;
42+
filename
43+
};
44+
45+
let store_attributes proc_attributes => {
46+
let proc_name = proc_attributes.ProcAttributes.proc_name;
47+
let attributes_file = res_dir_attr_filename proc_name;
48+
let should_write =
49+
/* only overwrite defined procedures */
50+
proc_attributes.ProcAttributes.is_defined || not (DB.file_exists attributes_file);
51+
if should_write {
52+
Serialization.to_file serializer attributes_file proc_attributes
53+
}
54+
};
55+
56+
let load_attributes proc_name => {
57+
let attributes_file = res_dir_attr_filename proc_name;
58+
Serialization.from_file serializer attributes_file
59+
};
60+
61+
62+
/** Given a procdesure name, find the file where it is defined and */
63+
/** its corresponding type environment */
64+
let find_tenv_from_class_of_proc procname =>
65+
switch (load_attributes procname) {
66+
| None => None
67+
| Some attrs =>
68+
let source_file = attrs.ProcAttributes.loc.Location.file;
69+
let source_dir = DB.source_dir_from_source_file source_file;
70+
let tenv_fname = DB.source_dir_get_internal_file source_dir ".tenv";
71+
Tenv.load_from_file tenv_fname
72+
};
73+
74+
75+
/** Given an ObjC class c, extract the type from the tenv where the class was */
76+
/** defined. We do this by adding a method that is unique to each class, and then */
77+
/** finding the tenv that corresponds to the class definition. */
78+
let get_correct_type_from_objc_class_name c => {
79+
let class_method = Procname.get_default_objc_class_method (Mangled.to_string c);
80+
switch (find_tenv_from_class_of_proc class_method) {
81+
| None => None
82+
| Some tenv =>
83+
let type_name = Typename.TN_csu (Csu.Class Csu.Objc) c;
84+
Option.map (fun st => Sil.Tstruct st) (Tenv.lookup tenv type_name)
85+
}
86+
};

infer/src/IR/AttributesTable.rei

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2015 - present Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
10+
open! Utils;
11+
12+
13+
/** Module to manage the table of attributes. */
14+
/** Save .attr file for the procedure into the attributes database. */
15+
let store_attributes: ProcAttributes.t => unit;
16+
17+
18+
/** Load the attributes for the procedure from the attributes database. */
19+
let load_attributes: Procname.t => option ProcAttributes.t;
20+
21+
22+
/** Given a procdesure name, find the file where it is defined and */
23+
/** its corresponding type environment */
24+
let find_tenv_from_class_of_proc: Procname.t => option Tenv.t;
25+
26+
27+
/** Given an ObjC class c, extract the type from the tenv where the class was */
28+
/** defined. We do this by adding a method that is unique to each class, and then */
29+
/** finding the tenv that corresponds to the class definition. */
30+
let get_correct_type_from_objc_class_name: Mangled.t => option Sil.typ;

0 commit comments

Comments
 (0)