-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infer# integration #1361
Infer# integration #1361
Conversation
Integration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good overall I think. I haven't read much of AnalyzeJson yet.
Are you able to run the auto-formatter with make fmt
? You'll need this version of ocamlformat: https://github.com/ocaml-ppx/ocamlformat/tree/nebuchadnezzar
I think this command does the trick: opam pin add ocamlformat.0.14.1-13-g000da99 -k git https://github.com/ocaml-ppx/ocamlformat.git#nebuchadnezzar
.github/workflows/install.yml
Outdated
@@ -65,7 +65,7 @@ jobs: | |||
|
|||
- name: Install Required Apt Packages for Ubuntu | |||
run: | | |||
sudo apt install libmpfr-dev libsqlite3-dev ninja-build | |||
sudo apt install libmpfr-dev sqlite3 libsqlite3-dev ninja-build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is sqlite3 itself used anywhere yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good overall I think. I haven't read much of AnalyzeJson yet.
Are you able to run the auto-formatter with
make fmt
? You'll need this version of ocamlformat: https://github.com/ocaml-ppx/ocamlformat/tree/nebuchadnezzar
I think this command does the trick:opam pin add ocamlformat.0.14.1-13-g000da99 -k git https://github.com/ocaml-ppx/ocamlformat.git#nebuchadnezzar
I got build error in this ocamlformat branch. I will try again after they fixed the pipeline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is sqlite3 itself used anywhere yet?
Removed. Good catch!
infer/src/IR/CallFlags.ml
Outdated
@@ -17,17 +17,19 @@ type t = | |||
; cf_injected_destructor: bool | |||
; cf_interface: bool | |||
; cf_is_objc_block: bool | |||
; cf_noreturn: bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was deleted by 9979489 because it is dead code. It looks like the flag has been reintroduced by mistake in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was deleted by 9979489 because it is dead code. It looks like the flag has been reintroduced by mistake in this PR.
Removed. Thanks
infer/src/IR/Cfg.ml
Outdated
@@ -40,6 +39,14 @@ let create_proc_desc cfg (proc_attributes : ProcAttributes.t) = | |||
Procname.Hash.add cfg pname pdesc ; | |||
pdesc | |||
|
|||
(** Get a procdesc or create if it is a new one*) | |||
let get_proc_desc cfg (proc_attributes : ProcAttributes.t) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a bit dangerous to add to the Cfg module and I'm not sure I understand why it's needed: what happens if the proc name is already present? The proc desc will get created but not recorded in the CFG, so in the end it's discarded?
This is only used once, could you maybe rewrite the call site to if not (Cfg.mem proc_attributes.proc_name) then Cfg.create_proc_desc ...
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a bit dangerous to add to the Cfg module and I'm not sure I understand why it's needed: what happens if the proc name is already present? The proc desc will get created but not recorded in the CFG, so in the end it's discarded?
This is only used once, could you maybe rewrite the call site to
if not (Cfg.mem proc_attributes.proc_name) then Cfg.create_proc_desc ...
?
Good suggestion. I have rewritten this call.
infer/src/IR/Procdesc.mli
Outdated
@@ -315,6 +317,8 @@ val fold_nodes : t -> init:'accum -> f:('accum -> Node.t -> 'accum) -> 'accum | |||
val fold_slope_range : Node.t -> Node.t -> init:'accum -> f:('accum -> Node.t -> 'accum) -> 'accum | |||
(** fold between two nodes or until we reach a branching structure *) | |||
|
|||
val set_succs_exn_base : Node.t -> Node.t list -> Node.t list -> unit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use set_succs
instead?
If this is needed could you add a doc string explaining that it should be used carefully because it won't update the node's successors' pred links? (not sure why that is ok except when the current node is known to have no succs, but then this is the same as set_succs
just below) Named arguments like set_succs
would be nice too since the types don't help to disambiguate the arguments here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use
set_succs
instead?If this is needed could you add a doc string explaining that it should be used carefully because it won't update the node's successors' pred links? (not sure why that is ok except when the current node is known to have no succs, but then this is the same as
set_succs
just below) Named arguments likeset_succs
would be nice too since the types don't help to disambiguate the arguments here.
It was an outdated function. I have replaced it with set_succs
infer/src/atd/InferCommand.mli
Outdated
@@ -8,6 +8,7 @@ | |||
(** Main modes of operation for infer *) | |||
type t = | |||
| Analyze (** analyze previously captured source files *) | |||
| AnalyzeJson |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A doc comment like the other commands would be nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A doc comment like the other commands would be nice.
Added. Thanks for suggestion
@@ -0,0 +1,13 @@ | |||
(* | |||
* Copyright (c) 2009-2013, Monoidics ltd. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please delete this line, it's only present on older source code where appropriate but new code should be just (c) Facebook.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please delete this line, it's only present on older source code where appropriate but new code should be just (c) Facebook.
Deleted
, Java ) | ||
;( interprocedural Payloads.Fields.lab_resource_leaks ResourceLeaks.checker | ||
, CIL ) ] } | ||
; (* toy resource analysis to use in the infer lab, see the lab/ directory *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
outdated comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
outdated comment?
Deleted
[ ( (* the checked-in version is intraprocedural, but the lab asks to make it | ||
interprocedural later on *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
outdated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
outdated?
Deleted
infer/src/base/DB.ml
Outdated
let clean_specs_dir () = | ||
(* create dir just in case it doesn't exist to avoid errors *) | ||
Utils.create_dir specs_dir ; | ||
Array.iter (Sys.readdir specs_dir) ~f:(fun specs -> | ||
Filename.concat specs_dir specs |> Sys.remove ) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a rebase error or is the specs/ directory really back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a rebase error or is the specs/ directory really back?
Yes, it is a rebase error. I have updated to comply with latest infer. Good catch. Thanks
infer/src/base/CommandDoc.ml
Outdated
mk_command_doc ~title:"Infer Analysis" ~short_description:"analyze the files captured by infer" | ||
~synopsis:{|$(b,infer) $(b,analyze) $(i,[options]) | ||
$(b,infer) $(i,[options])|} | ||
~description:[`P "Analyze the files captured in the project results directory and report."] | ||
~see_also:InferCommand.[Report; Run] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you update this to document the new command? Having an example of how to run the new command would be helpful. Would you be able to paste an example json somewhere? I'd love to be able to experiment with this PR locally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you update this to document the new command? Having an example of how to run the new command would be helpful. Would you be able to paste an example json somewhere? I'd love to be able to experiment with this PR locally.
Added. And I have added example jsons in examples/dotnet_hello/jsons
I was able to figure out Now all comments are resolved and this PR is ready for a second round of review. |
Makefile
Outdated
@@ -190,6 +190,25 @@ BUILD_SYSTEMS_TESTS += mvn | |||
endif | |||
endif | |||
|
|||
ifeq ($(BUILD_DOTNET_ANALYZERS),yes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this ifeq
needed? We provide compile-time options in ./configure
to disable the clang or Java frontends because sometimes it makes sense for the user, but these tests are independent of any frontends since they rely on infer-analyzejson
. If you remove the ifeq
or run make BUILD_DOTNET_ANALYZERS=yes
you should be able to run these tests as part of make test
or individually with, eg, make BUILD_DOTNET_ANALYZERS=yes direct_dotnet_box_test
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bigfootjon has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@xi-liu-ds has updated the pull request. You must reimport the pull request before landing. |
@xi-liu-ds has updated the pull request. You must reimport the pull request before landing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jvillard has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Hi~ I saw there might have some tests failed in Facebook Internal Builds & Tests. I can't see what exactly caused the failure... But if it is about infersharp unit tests, I can either check in compressed json files (they are ready and good to go!) or remove all of them from DIRECT_TESTS in make file. Let me know what is the best option for you~ Thanks! |
xz unit tests
@xi-liu-ds has updated the pull request. You must reimport the pull request before landing. |
The compilation failures are due to a small amount of extra code we have in the internal repo that needs to be updated by us. I'll do that. |
I see. Thanks! Now all compressed jsons are in. Feel free to give it a run simply with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jvillard has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@xi-liu-ds has updated the pull request. You must reimport the pull request before landing. |
Dear Infer team,
To contribute to Infer community, I would like to integrate infer#'s language agnostic layer into Infer.
Please help to review, discuss and consider to merge this feature.
Thanks,
Xiaoyu