[C Frontend] Get support for map pointer -> decl from fcp

Summary:
This adds support for having lookup from pointer to decl in C frontend
NOTE: with this diff atdgen 1.6 or later is required.

To upgrade atdgen, please run `opam install atdgen.1.6.0`
master
Andrzej Kotulski 10 years ago
parent 72c4354395
commit 2d087b7142

4
.gitignore vendored

@ -88,5 +88,9 @@ infer/models/out/
/infer/src/clang/clang_ast_proj.mli /infer/src/clang/clang_ast_proj.mli
/infer/src/clang/clang_ast_t.ml /infer/src/clang/clang_ast_t.ml
/infer/src/clang/clang_ast_t.mli /infer/src/clang/clang_ast_t.mli
/infer/src/clang/clang_ast_v.ml
/infer/src/clang/clang_ast_v.mli
/infer/src/clang/clang_ast_cache.ml
/infer/src/clang/clang_ast_main.ml
/infer/annotations/annotations.jar /infer/annotations/annotations.jar

@ -49,7 +49,7 @@ Install the OCaml dependencies:
```bash ```bash
opam init --comp=4.01.0 # (answer 'y' to the question) opam init --comp=4.01.0 # (answer 'y' to the question)
eval `opam config env` eval `opam config env`
opam install sawja.1.5 atdgen.1.5.0 javalib.2.3a extlib.1.5.4 opam install sawja.1.5 atdgen.1.6.0 javalib.2.3a extlib.1.5.4
``` ```
If you do not require support for the C/Objective-C analysis in Infer, If you do not require support for the C/Objective-C analysis in Infer,
@ -93,7 +93,7 @@ wget https://github.com/ocaml/opam/releases/download/1.2.2/opam-1.2.2-x86_64-Lin
chmod +x opam chmod +x opam
./opam init --comp=4.01.0 #(then say 'y' to the final question) ./opam init --comp=4.01.0 #(then say 'y' to the final question)
eval `./opam config env` eval `./opam config env`
./opam install sawja.1.5 atdgen.1.5.0 javalib.2.3a extlib.1.5.4 #(then say 'y' to the question) ./opam install sawja.1.5 atdgen.1.6.0 javalib.2.3a extlib.1.5.4 #(then say 'y' to the question)
``` ```
If you do not require support for the C/Objective-C analysis in Infer, If you do not require support for the C/Objective-C analysis in Infer,

@ -1 +1 @@
332177951f9004e44adb554b0ab31be4710c7d7e c4197d9f677a129304711a82c1f2e0fda4952314

@ -12,7 +12,7 @@ OCAML_INCLUDE_DIR = $(shell ocamlc -where)
#### ATDGEN declarations #### #### ATDGEN declarations ####
ATDGEN_SUFFIXES = _t.ml _t.mli _j.ml _j.mli ATDGEN_SUFFIXES = _t.ml _t.mli _j.ml _j.mli _v.ml _v.mli
ATDGEN_INCLUDE_DIR = $(shell ocamlfind query atdgen) ATDGEN_INCLUDE_DIR = $(shell ocamlfind query atdgen)
BINIOU_INCLUDE_DIR = $(shell ocamlfind query biniou) BINIOU_INCLUDE_DIR = $(shell ocamlfind query biniou)
@ -99,6 +99,7 @@ CLANG_ATDGEN_STUBS = $(addprefix $(CLANG_SOURCES)/$(CLANG_AST_BASE_NAME), $(ATDG
INFER_CLANG_AST_PROJ = $(addprefix $(CLANG_SOURCES)/, clang_ast_proj.ml clang_ast_proj.mli) INFER_CLANG_AST_PROJ = $(addprefix $(CLANG_SOURCES)/, clang_ast_proj.ml clang_ast_proj.mli)
FCP_CLANG_AST_PROJ = $(addprefix $(CLANG_OCAML_BUILD)/, clang_ast_proj.ml clang_ast_proj.mli) FCP_CLANG_AST_PROJ = $(addprefix $(CLANG_OCAML_BUILD)/, clang_ast_proj.ml clang_ast_proj.mli)
FCP_CLANG_AST_CACHE = $(addprefix $(CLANG_OCAML_ROOT)/, clang_ast_cache.ml clang_ast_main.ml)
#### LLVM declarations #### #### LLVM declarations ####
@ -149,13 +150,16 @@ $(INFERPRINT_ATDGEN_STUBS): $(INFERPRINT_ATDGEN_STUB_ATD)
atdgen -t $(INFERPRINT_ATDGEN_STUB_ATD) -o $(INFERPRINT_ATDGEN_STUB_BASE) atdgen -t $(INFERPRINT_ATDGEN_STUB_ATD) -o $(INFERPRINT_ATDGEN_STUB_BASE)
atdgen -j $(INFERPRINT_ATDGEN_STUB_ATD) -o $(INFERPRINT_ATDGEN_STUB_BASE) atdgen -j $(INFERPRINT_ATDGEN_STUB_ATD) -o $(INFERPRINT_ATDGEN_STUB_BASE)
$(CLANG_ATDGEN_STUBS) $(INFER_CLANG_AST_PROJ): $(CLANG_ATDGEN_STUB_ATD) $(CLANG_PLUGIN_BINARIES) $(FCP_CLANG_AST_PROJ) $(CLANG_ATDGEN_STUBS) $(INFER_CLANG_AST_PROJ): $(CLANG_ATDGEN_STUB_ATD) $(CLANG_PLUGIN_BINARIES) $(FCP_CLANG_AST_PROJ) $(FCP_CLANG_AST_CACHE)
# rebuild the artifacts of the AST files whenever they're upated in FCP # rebuild the artifacts of the AST files whenever they're upated in FCP
# also copy the ast_proj files whenever they are updated # also copy the ast_proj files whenever they are updated
atdgen -rec -t $(CLANG_ATDGEN_STUB_ATD) -o $(CLANG_ATDGEN_STUB_BASE) atdgen -rec -t $(CLANG_ATDGEN_STUB_ATD) -o $(CLANG_ATDGEN_STUB_BASE)
atdgen -rec -j $(CLANG_ATDGEN_STUB_ATD) -o $(CLANG_ATDGEN_STUB_BASE) atdgen -rec -j $(CLANG_ATDGEN_STUB_ATD) -o $(CLANG_ATDGEN_STUB_BASE)
atdgen -rec -v $(CLANG_ATDGEN_STUB_ATD) -o $(CLANG_ATDGEN_STUB_BASE)
$(COPY) $(CLANG_OCAML_BUILD)/clang_ast_proj.ml $(CLANG_SOURCES) $(COPY) $(CLANG_OCAML_BUILD)/clang_ast_proj.ml $(CLANG_SOURCES)
$(COPY) $(CLANG_OCAML_BUILD)/clang_ast_proj.mli $(CLANG_SOURCES) $(COPY) $(CLANG_OCAML_BUILD)/clang_ast_proj.mli $(CLANG_SOURCES)
$(COPY) $(CLANG_OCAML_ROOT)/clang_ast_cache.ml $(CLANG_SOURCES)
$(COPY) $(CLANG_OCAML_ROOT)/clang_ast_main.ml $(CLANG_SOURCES)
init: sanitize version $(BUILDDIR) init: sanitize version $(BUILDDIR)

@ -39,6 +39,8 @@ let ast_file : string option ref = ref None
let json = ref "" let json = ref ""
let pointer_decl_index = ref Clang_ast_cache.PointerMap.empty
let debug_mode = ref false let debug_mode = ref false
let stats_mode = ref false let stats_mode = ref false

@ -37,6 +37,8 @@ val testing_mode : bool ref
val json : string ref val json : string ref
val pointer_decl_index : Clang_ast_t.decl Clang_ast_cache.PointerMap.t ref
val objc_object : string val objc_object : string
val id_cl : string val id_cl : string

@ -104,7 +104,7 @@ let do_run source_path ast_path =
Printing.log_out "Original AST@.%a@." CAstProcessor.pp_ast_decl ast_decl; Printing.log_out "Original AST@.%a@." CAstProcessor.pp_ast_decl ast_decl;
Printing.log_out "AST with explicit locations:@.%a@." CAstProcessor.pp_ast_decl ast_decl'; Printing.log_out "AST with explicit locations:@.%a@." CAstProcessor.pp_ast_decl ast_decl';
CFrontend_config.pointer_decl_index := Clang_ast_main.index_decl_pointers ast_decl';
CFrontend_config.json := ast_filename; CFrontend_config.json := ast_filename;
CLocation.check_source_file source_path; CLocation.check_source_file source_path;
let source_file = CLocation.source_file_from_path source_path in let source_file = CLocation.source_file_from_path source_path in

@ -13,7 +13,7 @@ remove: []
depends: [ depends: [
"ocamlfind" {build} "ocamlfind" {build}
"sawja" {>="1.5"} "sawja" {>="1.5"}
"atdgen" {>="1.5"} "atdgen" {>="1.6"}
"javalib" {>="2.3"} "javalib" {>="2.3"}
"extlib" {>="1.5.4"} "extlib" {>="1.5.4"}
] ]

Loading…
Cancel
Save