[racerd] don't report races in third-party code

Reviewed By: jeremydubreil

Differential Revision: D7107581

fbshipit-source-id: 87cde65
master
Sam Blackshear 7 years ago committed by Facebook Github Bot
parent d74f189dfe
commit 89a6d7e20d

@ -435,6 +435,14 @@ module Name = struct
is_int
| None ->
false
let is_external_classname name_string =
let package, _ = split_classname name_string in
Option.exists ~f:Config.java_package_is_external package
let is_external t = is_external_classname (name t)
end
module Cpp = struct

@ -162,6 +162,12 @@ module Name : sig
val is_class : t -> bool
(** [is_class name] holds if [name] names a Java class *)
val is_external_classname : string -> bool
(** return true if the string is in the .inferconfig list of external classes *)
val is_external : t -> bool
(** return true if the typename is in the .inferconfig list of external classes *)
val split_classname : string -> string option * string
(** Given a package.class_name string, look for the latest dot and split the string
in two (package, class_name). *)

@ -155,9 +155,7 @@ let pretty_field_name proc_data field_name =
let is_outside_codebase proc_name field_name =
match proc_name with
| Typ.Procname.Java _ ->
let class_name = Typ.Fieldname.Java.get_class field_name in
let package, _ = Typ.Name.Java.split_classname class_name in
Option.exists ~f:Config.java_package_is_external package
Typ.Name.Java.is_external_classname (Typ.Fieldname.Java.get_class field_name)
| _ ->
false

@ -481,6 +481,8 @@ module Models = struct
( match pn with
| Typ.Procname.Java java_pname ->
Typ.Procname.Java.is_class_initializer java_pname
|| Typ.Name.Java.is_external (Typ.Procname.Java.get_class_type_name java_pname)
(* third party code may be hard to change, not useful to report races there *)
| _ ->
false )
&& not (FbThreadSafety.is_logging_method pn) && not (pdesc_is_assumed_thread_safe pdesc tenv)

@ -6,5 +6,8 @@
"language": "Java",
"source_contains": "_SHOULD_BE_SKIPPED_"
}
],
"external-java-packages" : [
"com.racerd.donotreport"
]
}

@ -0,0 +1,24 @@
/*
* Copyright (c) 2018 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.racerd.donotreport;
import com.facebook.infer.annotation.ThreadSafe;
@ThreadSafe
class DoNotReport {
int mFld;
// normally we would report this, but we won't because com.racerd.donotreport is blacklisted in
// .inferconfig
void obviousRaceBad(int i) {
mFld = i;
}
}
Loading…
Cancel
Save