-
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
Closed
Closed
Infer# integration #1361
Changes from 29 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
661ef65
integrate with infersharp
xi-liu-ds cd1e6fc
more changes to compatible with infersharp
xi-liu-ds 3fa4160
remove useless adds
xi-liu-ds a5c023b
resolve incompatibilities
xi-liu-ds d9b00ca
Merge remote-tracking branch 'upstream/master' into integration
xi-liu-ds 0e4489a
null dereference support for C#
xi-liu-ds 9374648
Merge branch 'master' of github.com:xi-liu-ds/infer into integration
xi-liu-ds b5a8d6d
generate specs files
xi-liu-ds 545c78b
Merge branch 'master' of https://github.com/xi-liu-ds/infer into inte…
xi-liu-ds cc87294
add resource leak support
xi-liu-ds 4f4acf6
Merge pull request #1 from xi-liu-ds/integration
xi-liu-ds 4e86aa8
Merge branch 'master' of https://github.com/xi-liu-ds/infer
xi-liu-ds 280a5fb
remove fallbacknode
xi-liu-ds ebf8e88
add get proc desc function for .net
xi-liu-ds f0b6e33
fix float on nan
xi-liu-ds 0ec94eb
Merge remote-tracking branch 'upstream/master'
xi-liu-ds 71914ae
seperate infer analyze json logics
xi-liu-ds a0e0c28
fix deprecated warnings
xi-liu-ds 01b1037
Merge branch 'master' into master
xi-liu-ds a67918c
resolve comments
xi-liu-ds 7047a71
Merge branch 'master' of https://github.com/xi-liu-ds/infer
xi-liu-ds 8848fdb
Merge remote-tracking branch 'upstream/master'
xi-liu-ds 6986656
fix build failure
xi-liu-ds f3b95de
add unit tests
xi-liu-ds db3ada8
add unit tests make file
xi-liu-ds 4a001b4
Merge pull request #2 from xi-liu-ds/xiaoyu/integration/unittests
xi-liu-ds b2f300a
Merge remote-tracking branch 'upstream/master'
xi-liu-ds 77270e2
format cleanup
xi-liu-ds 4270215
Merge branch 'master' of https://github.com/xi-liu-ds/infer
xi-liu-ds de588c5
remove BUILD_DOTNET_ANALYZERS condition
xi-liu-ds 6ca305a
focus on resource leaks and null deref
xi-liu-ds 0145560
remove unit test jsons files
xi-liu-ds d0945ba
xz unit tests
xi-liu-ds 56d910e
Merge pull request #3 from xi-liu-ds/xi-liu-ds/xzjsons
xi-liu-ds c35f6c1
Merge branch 'master' into master
xi-liu-ds File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
(* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*) | ||
|
||
open! IStd | ||
module F = Format | ||
module L = Logging | ||
|
||
(** invariant: if [namespace = Some str] then [not (String.equal str "")]. [classname] appears first | ||
so that the comparator fails earlier *) | ||
type t = {classname: string; namespace: string option} [@@deriving compare, equal, yojson_of] | ||
|
||
module Map = Caml.Map.Make (struct | ||
type nonrec t = t [@@deriving compare] | ||
end) | ||
|
||
module Set = Caml.Set.Make (struct | ||
type nonrec t = t [@@deriving compare] | ||
end) | ||
|
||
let make ~namespace ~classname = | ||
match namespace with Some "" -> {namespace= None; classname} | _ -> {namespace; classname} | ||
|
||
|
||
let from_string str = | ||
match String.rsplit2 str ~on:'.' with | ||
| None -> | ||
{classname= str; namespace= None} | ||
| Some ("", _) -> | ||
L.die InternalError "Empty namespace path in CSharp qualified classname.@." | ||
| Some (pkg, classname) -> | ||
{classname; namespace= Some pkg} | ||
|
||
|
||
let to_string = function | ||
| {classname; namespace= None} -> | ||
classname | ||
| {classname; namespace= Some pkg} -> | ||
String.concat ~sep:"." [pkg; classname] | ||
|
||
|
||
let pp fmt = function | ||
| {classname; namespace= None} -> | ||
F.pp_print_string fmt classname | ||
| {classname; namespace= Some pkg} -> | ||
F.fprintf fmt "%s.%s" pkg classname | ||
|
||
|
||
let namespace {namespace} = namespace | ||
|
||
let classname {classname} = classname | ||
|
||
let is_int s = | ||
try | ||
ignore (int_of_string s) ; | ||
true | ||
with Failure _ -> false | ||
|
||
|
||
let get_outer_class_name {namespace; classname} = | ||
String.rsplit2 classname ~on:'$' |> Option.map ~f:(fun (outer, _) -> {namespace; classname= outer}) | ||
|
||
|
||
(* | ||
Anonymous classes have two forms: | ||
- classic anonymous classes: suffixes in form of $<int>. | ||
- classes corresponding to lambda-expressions: they are manifested as $Lambda$. | ||
- two forms above nested inside each other. | ||
Also non-anonymous (user-defined) name can be nested as well (Class$NestedClass). | ||
In general case anonymous class name looks something like | ||
Class$NestedClass$1$17$5$Lambda$_1_2, and we need to return Class$NestedClass *) | ||
let get_user_defined_class_if_anonymous_inner {namespace; classname} = | ||
let is_anonymous_name = function | ||
| "Lambda" -> | ||
true | ||
| name when is_int name -> | ||
true | ||
| _ -> | ||
false | ||
in | ||
let pieces = String.split classname ~on:'$' in | ||
let first_anonymous_name = List.findi pieces ~f:(fun _index name -> is_anonymous_name name) in | ||
Option.bind first_anonymous_name ~f:(fun (index, _name) -> | ||
(* Everything before this index did not have anonymous prefixes. Deem it user defined. *) | ||
match List.take pieces index with | ||
| [] -> | ||
(* This is a weird situation - our class _starts_ with an anonymous name. | ||
This should not happen normally, but we can not rule this out completely since there is no physical limitations on | ||
the bytecode names. | ||
In this case, we return [None] because formally this is not an anonymous _inner_ class, but anonymous outermost class instead. | ||
TODO: redesign this API so this case is modelled directly | ||
*) | ||
None | ||
| list -> | ||
(* Assemble back all pieces together *) | ||
Some {namespace; classname= String.concat ~sep:"$" list} ) | ||
|
||
|
||
let is_anonymous_inner_class_name t = get_user_defined_class_if_anonymous_inner t |> is_some | ||
|
||
let is_external_via_config t = | ||
let namespace = namespace t in | ||
Option.exists ~f:Config.csharp_namespace_is_external namespace | ||
|
||
|
||
let pp_with_verbosity ~verbose fmt t = | ||
if verbose then pp fmt t else F.pp_print_string fmt (classname t) | ||
|
||
|
||
module Normalizer = HashNormalizer.Make (struct | ||
type nonrec t = t [@@deriving equal] | ||
|
||
let hash = Hashtbl.hash | ||
|
||
let normalize t = | ||
let classname = HashNormalizer.StringNormalizer.normalize t.classname in | ||
let namespace = | ||
IOption.map_changed t.namespace ~equal:phys_equal ~f:HashNormalizer.StringNormalizer.normalize | ||
in | ||
if phys_equal classname t.classname && phys_equal namespace t.namespace then t | ||
else {classname; namespace} | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
(* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*) | ||
|
||
open! IStd | ||
|
||
type t [@@deriving compare, equal, yojson_of] | ||
|
||
module Map : Caml.Map.S with type key = t | ||
|
||
module Set : Caml.Set.S with type elt = t | ||
|
||
val make : namespace:string option -> classname:string -> t | ||
|
||
val from_string : string -> t | ||
|
||
val to_string : t -> string | ||
(** [to_string (from_string "X.Y.Z") = "X.Y.Z"] *) | ||
|
||
val pp : Format.formatter -> t -> unit | ||
(** [pp] includes namespace if any *) | ||
|
||
val pp_with_verbosity : verbose:bool -> Format.formatter -> t -> unit | ||
(** if [verbose] then print namespace if present, otherwise only print class *) | ||
|
||
val namespace : t -> string option | ||
|
||
val classname : t -> string | ||
|
||
val is_external_via_config : t -> bool | ||
(** Considered external based on config flags. *) | ||
|
||
val get_outer_class_name : t -> t option | ||
(** If this is an inner class, return the closest outer, e.g. A$B for A$B$C. None if the class is | ||
outermost *) | ||
|
||
val is_anonymous_inner_class_name : t -> bool | ||
(** True if it is either "classic" anonymous csharp class: *) | ||
|
||
val get_user_defined_class_if_anonymous_inner : t -> t option | ||
(** If the current class is anonymous ([is_anonymous_inner_class_name] is true), return the | ||
corresponding user defined (not anonymous) class this anonymous class belongs to. | ||
|
||
In general case, BOTH anonymous classes and user-defined classes can be nested: | ||
SomeClass$NestedClass$1$17$5. In this example, we should return SomeClass$NestedClass. | ||
|
||
If this is not an anonymous class, returns [None]. *) | ||
|
||
module Normalizer : HashNormalizer.S with type t = t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 oninfer-analyzejson
. If you remove theifeq
or runmake BUILD_DOTNET_ANALYZERS=yes
you should be able to run these tests as part ofmake 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.