Skip to content
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

Closed
wants to merge 35 commits into from
Closed

Infer# integration #1361

wants to merge 35 commits into from

Conversation

xi-liu-ds
Copy link
Contributor

@xi-liu-ds xi-liu-ds commented Dec 16, 2020

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

Copy link
Contributor

@jvillard jvillard left a 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

@@ -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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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!

@@ -17,17 +17,19 @@ type t =
; cf_injected_destructor: bool
; cf_interface: bool
; cf_is_objc_block: bool
; cf_noreturn: bool
Copy link
Contributor

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.

Copy link
Contributor Author

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

@@ -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) =
Copy link
Contributor

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 ...?

Copy link
Contributor Author

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.

@@ -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
Copy link
Contributor

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.

Copy link
Contributor Author

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.

It was an outdated function. I have replaced it with set_succs

@@ -8,6 +8,7 @@
(** Main modes of operation for infer *)
type t =
| Analyze (** analyze previously captured source files *)
| AnalyzeJson
Copy link
Contributor

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.

Copy link
Contributor Author

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.
Copy link
Contributor

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.

Copy link
Contributor Author

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 *)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outdated comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outdated comment?

Deleted

Comment on lines 145 to 146
[ ( (* the checked-in version is intraprocedural, but the lab asks to make it
interprocedural later on *)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outdated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outdated?

Deleted

Comment on lines 139 to 145
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 )


Copy link
Contributor

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?

Copy link
Contributor Author

@xi-liu-ds xi-liu-ds Dec 24, 2020

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

Comment on lines 61 to 65
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]
Copy link
Contributor

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.

Copy link
Contributor Author

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

@xi-liu-ds
Copy link
Contributor Author

I was able to figure out ocamlformat installation issue and ran make fmt successfully. It turns out that ocamlformat needs to be reinstalled first and then install nebuchadnezzar version.

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)
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Thanks.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a 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.

@facebook-github-bot
Copy link
Contributor

@xi-liu-ds has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@xi-liu-ds has updated the pull request. You must reimport the pull request before landing.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a 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
Copy link
Contributor Author

xi-liu-ds commented Jan 26, 2021

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!

@facebook-github-bot
Copy link
Contributor

@xi-liu-ds has updated the pull request. You must reimport the pull request before landing.

@jvillard
Copy link
Contributor

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.

@xi-liu-ds
Copy link
Contributor Author

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 make direct_tests.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a 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.

@facebook-github-bot
Copy link
Contributor

@xi-liu-ds has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@jvillard merged this pull request in 285ddb4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants