diff --git a/infer/src/IR/Pvar.ml b/infer/src/IR/Pvar.ml index 0bd883675..572e26c11 100644 --- a/infer/src/IR/Pvar.ml +++ b/infer/src/IR/Pvar.ml @@ -14,7 +14,7 @@ open! IStd module L = Logging module F = Format -type translation_unit = TUFile of SourceFile.t | TUExtern [@@deriving compare] +type translation_unit = SourceFile.t option [@@deriving compare] (** Kind of global variables *) type pvar_kind = @@ -55,12 +55,7 @@ let compare_modulo_this x y = let equal = [%compare.equal : t] -let pp_translation_unit fmt = function - | TUFile fname -> - SourceFile.pp fmt fname - | TUExtern -> - Format.fprintf fmt "EXTERN" - +let pp_translation_unit fmt = function None -> () | Some fname -> SourceFile.pp fmt fname let pp_ f pv = let name = pv.pv_name in @@ -210,7 +205,7 @@ let mk_callee (name: Mangled.t) (proc_name: Typ.Procname.t) : t = (** create a global variable with the given name *) let mk_global ?(is_constexpr= false) ?(is_pod= true) ?(is_static_local= false) - ?(is_static_global= false) (name: Mangled.t) translation_unit : t = + ?(is_static_global= false) ?translation_unit (name: Mangled.t) : t = { pv_hash= name_hash name ; pv_name= name ; pv_kind= Global_var (translation_unit, is_constexpr, is_pod, is_static_local, is_static_global) @@ -255,14 +250,14 @@ let get_initializer_pname {pv_name; pv_kind} = let name = Config.clang_initializer_prefix ^ Mangled.to_string_full pv_name in if is_static_global then match translation with - | TUFile file -> + | Some file -> let mangled = SourceFile.to_string file |> Utils.string_crc_hex32 in Typ.Procname.C (Typ.Procname.c (QualifiedCppName.of_qual_string name) mangled Typ.NoTemplate ~is_generic_model:false) |> Option.return - | TUExtern -> + | None -> None else Some (Typ.Procname.from_string_c_fun name) | _ -> diff --git a/infer/src/IR/Pvar.mli b/infer/src/IR/Pvar.mli index 5d4d8d368..150426dc5 100644 --- a/infer/src/IR/Pvar.mli +++ b/infer/src/IR/Pvar.mli @@ -13,7 +13,7 @@ open! IStd module F = Format -type translation_unit = TUFile of SourceFile.t | TUExtern [@@deriving compare] +type translation_unit = SourceFile.t option [@@deriving compare] (** Type for program variables. There are 4 kinds of variables: 1) local variables, used for local variables and formal parameters @@ -93,7 +93,7 @@ val mk_callee : Mangled.t -> Typ.Procname.t -> t val mk_global : ?is_constexpr:bool -> ?is_pod:bool -> ?is_static_local:bool -> ?is_static_global:bool - -> Mangled.t -> translation_unit -> t + -> ?translation_unit:SourceFile.t -> Mangled.t -> t (** create a global variable with the given name *) val mk_tmp : string -> Typ.Procname.t -> t diff --git a/infer/src/IR/Sil.ml b/infer/src/IR/Sil.ml index 2e3765ef5..e0e85c3dc 100644 --- a/infer/src/IR/Sil.ml +++ b/infer/src/IR/Sil.ml @@ -2035,4 +2035,4 @@ let hpara_dll_instantiate (para: hpara_dll) cell blink flink elist = (ids_evars, List.map ~f:(hpred_sub subst) para.body_dll) -let custom_error = Pvar.mk_global (Mangled.from_string "INFER_CUSTOM_ERROR") Pvar.TUExtern +let custom_error = Pvar.mk_global (Mangled.from_string "INFER_CUSTOM_ERROR") diff --git a/infer/src/checkers/Siof.ml b/infer/src/checkers/Siof.ml index f01c9bd96..133159a0d 100644 --- a/infer/src/checkers/Siof.ml +++ b/infer/src/checkers/Siof.ml @@ -179,9 +179,9 @@ module Analyzer = AbstractInterpreter.Make (ProcCfg.Normal) (TransferFunctions) let is_foreign tu_opt v = match (Pvar.get_translation_unit v, tu_opt) with - | TUFile v_tu, Some current_tu -> + | Some v_tu, Some current_tu -> not (SourceFile.equal current_tu v_tu) - | TUExtern, Some _ -> + | None, Some _ -> true | _, None -> L.(die InternalError) "cannot be called with translation unit set to None" @@ -245,11 +245,10 @@ let checker {Callbacks.proc_desc; tenv; summary; get_procs_in_file} : Specs.summ let magic_iostream_marker = (* always [Some _] because we create a global variable with [mk_global] *) Option.value_exn - ( Pvar.mk_global + ( Pvar.mk_global ~translation_unit:tu (Mangled.from_string (* infer's C++ headers define this global variable in *) "__infer_translation_unit_init_streams") - (TUFile tu) |> Pvar.get_initializer_pname ) in get_procs_in_file pname |> List.exists ~f:(Typ.Procname.equal magic_iostream_marker) diff --git a/infer/src/checkers/accessTree.ml b/infer/src/checkers/accessTree.ml index 372086a81..3511d6c52 100644 --- a/infer/src/checkers/accessTree.ml +++ b/infer/src/checkers/accessTree.ml @@ -440,7 +440,6 @@ module PathSet (Config : Config) = struct let mem access_path tree = match get_node access_path tree with None -> false | Some (is_mem, _) -> is_mem - (* print as a set of paths rather than a map of paths to bools *) let pp fmt tree = let collect_path acc access_path (is_mem, _) = if is_mem then access_path :: acc else acc in diff --git a/infer/src/clang/cGeneral_utils.ml b/infer/src/clang/cGeneral_utils.ml index 2790d0c4e..85005a133 100644 --- a/infer/src/clang/cGeneral_utils.ml +++ b/infer/src/clang/cGeneral_utils.ml @@ -130,14 +130,14 @@ let mk_sil_global_var {CFrontend_config.source_file} ?(mk_name= fun _ x -> x) na let translation_unit = match Clang_ast_t.(var_decl_info.vdi_is_extern, var_decl_info.vdi_init_expr) with | true, None -> - Pvar.TUExtern + None | _, None when var_decl_info.Clang_ast_t.vdi_is_static_data_member -> (* non-const static data member get extern scope unless they are defined out of line here (in which case vdi_init_expr will not be None) *) - Pvar.TUExtern + None | true, Some _ (* "extern" variables with initialisation code are not extern at all, but compilers accept this *) | false, _ -> - Pvar.TUFile source_file + Some source_file in let is_constexpr = var_decl_info.Clang_ast_t.vdi_is_const_expr in let is_pod = @@ -162,7 +162,7 @@ let mk_sil_global_var {CFrontend_config.source_file} ?(mk_name= fun _ x -> x) na in Pvar.mk_global ~is_constexpr ~is_pod ~is_static_local:var_decl_info.Clang_ast_t.vdi_is_static_local ~is_static_global - (mk_name name_string simple_name) translation_unit + ?translation_unit (mk_name name_string simple_name) let mk_sil_var trans_unit_ctx named_decl_info decl_info_qual_type_opt procname outer_procname = diff --git a/infer/src/java/jTrans.ml b/infer/src/java/jTrans.ml index f888fa012..15710c2fa 100644 --- a/infer/src/java/jTrans.ml +++ b/infer/src/java/jTrans.ml @@ -437,7 +437,6 @@ let create_sil_deref exp typ loc = let rec expression (context: JContext.t) pc expr = let program = context.program in let loc = get_location context.source_file context.impl pc in - let file = loc.Location.file in let tenv = JContext.get_tenv context in let type_of_expr = JTransType.expr_type context expr in let trans_var pvar = @@ -538,7 +537,7 @@ let rec expression (context: JContext.t) pc expr = | JBir.StaticField (cn, fs) -> let class_exp = let classname = Mangled.from_string (JBasics.cn_name cn) in - let var_name = Pvar.mk_global classname (Pvar.TUFile file) in + let var_name = Pvar.mk_global classname in Exp.Lvar var_name in let instrs, sil_expr = ([], class_exp) in @@ -760,7 +759,6 @@ let instruction (context: JContext.t) pc instr : translation = let ret_var = Pvar.get_ret_pvar proc_name in let ret_type = Procdesc.get_ret_type context.procdesc in let loc = get_location context.source_file context.impl pc in - let file = loc.Location.file in let match_never_null = Inferconfig.never_return_null_matcher in let create_node node_kind sil_instrs = Procdesc.create_node context.procdesc loc node_kind sil_instrs @@ -830,7 +828,7 @@ let instruction (context: JContext.t) pc instr : translation = | JBir.AffectStaticField (cn, fs, e_rhs) -> let class_exp = let classname = Mangled.from_string (JBasics.cn_name cn) in - let var_name = Pvar.mk_global classname (Pvar.TUFile file) in + let var_name = Pvar.mk_global classname in Exp.Lvar var_name in let stml1, sil_expr_lhs = ([], class_exp) in diff --git a/infer/tests/build_systems/ant/issues.exp b/infer/tests/build_systems/ant/issues.exp index e0a127af3..c9c41c3f7 100644 --- a/infer/tests/build_systems/ant/issues.exp +++ b/infer/tests/build_systems/ant/issues.exp @@ -87,7 +87,7 @@ codetoanalyze/java/infer/GuardedByExample.java, void GuardedByExample.reassignCo codetoanalyze/java/infer/GuardedByExample.java, void GuardedByExample.synchronizedMethodReadBad(), 1, THREAD_SAFETY_VIOLATION, [,access to `&this.codetoanalyze.java.infer.GuardedByExample.f`,,access to `&this.codetoanalyze.java.infer.GuardedByExample.f`] codetoanalyze/java/infer/GuardedByExample.java, void GuardedByExample.synchronizedMethodReadBad(), 1, UNSAFE_GUARDED_BY_ACCESS, [start of procedure synchronizedMethodReadBad()] codetoanalyze/java/infer/GuardedByExample.java, void GuardedByExample.synchronizedMethodWriteBad(), 1, UNSAFE_GUARDED_BY_ACCESS, [start of procedure synchronizedMethodWriteBad()] -codetoanalyze/java/infer/GuardedByExample.java, void GuardedByExample.synchronizedOnThisBad(), 1, THREAD_SAFETY_VIOLATION, [,access to `&#GB$codetoanalyze.java.infer.GuardedByExample.codetoanalyze.java.infer.GuardedByExample.sGuardedByClass`,,access to `&#GB$codetoanalyze.java.infer.GuardedByExample.codetoanalyze.java.infer.GuardedByExample.sGuardedByClass`] +codetoanalyze/java/infer/GuardedByExample.java, void GuardedByExample.synchronizedOnThisBad(), 1, THREAD_SAFETY_VIOLATION, [,access to `&#GB<>$codetoanalyze.java.infer.GuardedByExample.codetoanalyze.java.infer.GuardedByExample.sGuardedByClass`,,access to `&#GB<>$codetoanalyze.java.infer.GuardedByExample.codetoanalyze.java.infer.GuardedByExample.sGuardedByClass`] codetoanalyze/java/infer/GuardedByExample.java, void GuardedByExample.synchronizedOnThisBad(), 1, UNSAFE_GUARDED_BY_ACCESS, [start of procedure synchronizedOnThisBad()] codetoanalyze/java/infer/GuardedByExample.java, void GuardedByExample.writeFAfterBlockBad(), 3, THREAD_SAFETY_VIOLATION, [access to `&this.codetoanalyze.java.infer.GuardedByExample.f`] codetoanalyze/java/infer/GuardedByExample.java, void GuardedByExample.writeFAfterBlockBad(), 3, UNSAFE_GUARDED_BY_ACCESS, [start of procedure writeFAfterBlockBad()] diff --git a/infer/tests/codetoanalyze/cpp/shared/namespace/global_variable.cpp.dot b/infer/tests/codetoanalyze/cpp/shared/namespace/global_variable.cpp.dot index 6c03757f9..744235307 100644 --- a/infer/tests/codetoanalyze/cpp/shared/namespace/global_variable.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/shared/namespace/global_variable.cpp.dot @@ -26,15 +26,15 @@ digraph iCFG { "div0_static_field#12231470699631142739.dca5ebae856e9b404facab8151fb6246_2" [label="2: Exit div0_static_field \n " color=yellow style=filled] -"div0_static_field#12231470699631142739.dca5ebae856e9b404facab8151fb6246_3" [label="3: Return Stmt \n n$0=*&#GB$f1::A::v:int [line 37, column 15]\n n$1=*&#GB$B::v:int [line 37, column 26]\n *&return:int=(1 / ((n$0 + n$1) + 1)) [line 37, column 3]\n " shape="box"] +"div0_static_field#12231470699631142739.dca5ebae856e9b404facab8151fb6246_3" [label="3: Return Stmt \n n$0=*&#GB<>$f1::A::v:int [line 37, column 15]\n n$1=*&#GB<>$B::v:int [line 37, column 26]\n *&return:int=(1 / ((n$0 + n$1) + 1)) [line 37, column 3]\n " shape="box"] "div0_static_field#12231470699631142739.dca5ebae856e9b404facab8151fb6246_3" -> "div0_static_field#12231470699631142739.dca5ebae856e9b404facab8151fb6246_2" ; -"div0_static_field#12231470699631142739.dca5ebae856e9b404facab8151fb6246_4" [label="4: BinaryOperatorStmt: Assign \n *&#GB$f1::A::v:int=-2 [line 36, column 3]\n " shape="box"] +"div0_static_field#12231470699631142739.dca5ebae856e9b404facab8151fb6246_4" [label="4: BinaryOperatorStmt: Assign \n *&#GB<>$f1::A::v:int=-2 [line 36, column 3]\n " shape="box"] "div0_static_field#12231470699631142739.dca5ebae856e9b404facab8151fb6246_4" -> "div0_static_field#12231470699631142739.dca5ebae856e9b404facab8151fb6246_3" ; -"div0_static_field#12231470699631142739.dca5ebae856e9b404facab8151fb6246_5" [label="5: BinaryOperatorStmt: Assign \n *&#GB$B::v:int=1 [line 35, column 3]\n " shape="box"] +"div0_static_field#12231470699631142739.dca5ebae856e9b404facab8151fb6246_5" [label="5: BinaryOperatorStmt: Assign \n *&#GB<>$B::v:int=1 [line 35, column 3]\n " shape="box"] "div0_static_field#12231470699631142739.dca5ebae856e9b404facab8151fb6246_5" -> "div0_static_field#12231470699631142739.dca5ebae856e9b404facab8151fb6246_4" ; @@ -45,15 +45,15 @@ digraph iCFG { "div0_static_field_member_access#8775359855042425857.b606a4de40e2ad34cbe0f38ab2d7e485_2" [label="2: Exit div0_static_field_member_access \n " color=yellow style=filled] -"div0_static_field_member_access#8775359855042425857.b606a4de40e2ad34cbe0f38ab2d7e485_3" [label="3: Return Stmt \n n$0=*&#GB$f1::A::v:int [line 43, column 15]\n n$1=*&#GB$B::v:int [line 43, column 26]\n *&return:int=(1 / ((n$0 + n$1) + 1)) [line 43, column 3]\n " shape="box"] +"div0_static_field_member_access#8775359855042425857.b606a4de40e2ad34cbe0f38ab2d7e485_3" [label="3: Return Stmt \n n$0=*&#GB<>$f1::A::v:int [line 43, column 15]\n n$1=*&#GB<>$B::v:int [line 43, column 26]\n *&return:int=(1 / ((n$0 + n$1) + 1)) [line 43, column 3]\n " shape="box"] "div0_static_field_member_access#8775359855042425857.b606a4de40e2ad34cbe0f38ab2d7e485_3" -> "div0_static_field_member_access#8775359855042425857.b606a4de40e2ad34cbe0f38ab2d7e485_2" ; -"div0_static_field_member_access#8775359855042425857.b606a4de40e2ad34cbe0f38ab2d7e485_4" [label="4: BinaryOperatorStmt: Assign \n *&#GB$B::v:int=-2 [line 42, column 3]\n " shape="box"] +"div0_static_field_member_access#8775359855042425857.b606a4de40e2ad34cbe0f38ab2d7e485_4" [label="4: BinaryOperatorStmt: Assign \n *&#GB<>$B::v:int=-2 [line 42, column 3]\n " shape="box"] "div0_static_field_member_access#8775359855042425857.b606a4de40e2ad34cbe0f38ab2d7e485_4" -> "div0_static_field_member_access#8775359855042425857.b606a4de40e2ad34cbe0f38ab2d7e485_3" ; -"div0_static_field_member_access#8775359855042425857.b606a4de40e2ad34cbe0f38ab2d7e485_5" [label="5: BinaryOperatorStmt: Assign \n *&#GB$f1::A::v:int=1 [line 41, column 3]\n " shape="box"] +"div0_static_field_member_access#8775359855042425857.b606a4de40e2ad34cbe0f38ab2d7e485_5" [label="5: BinaryOperatorStmt: Assign \n *&#GB<>$f1::A::v:int=1 [line 41, column 3]\n " shape="box"] "div0_static_field_member_access#8775359855042425857.b606a4de40e2ad34cbe0f38ab2d7e485_5" -> "div0_static_field_member_access#8775359855042425857.b606a4de40e2ad34cbe0f38ab2d7e485_4" ; diff --git a/infer/tests/codetoanalyze/cpp/siof/issues.exp b/infer/tests/codetoanalyze/cpp/siof/issues.exp index 06eb13c71..98b7298cf 100644 --- a/infer/tests/codetoanalyze/cpp/siof/issues.exp +++ b/infer/tests/codetoanalyze/cpp/siof/issues.exp @@ -1,11 +1,11 @@ -codetoanalyze/cpp/siof/siof/duplicate_reports.cpp, __infer_globals_initializer_many_paths_to_siof_bad, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of many_paths_to_siof_bad,call to X_X,call to access_rick,access to rick|EXTERN] -codetoanalyze/cpp/siof/siof/duplicate_reports.cpp, __infer_globals_initializer_many_paths_to_siof_bad, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of many_paths_to_siof_bad,call to X_X,call to nested_access,access to dangerous|EXTERN] +codetoanalyze/cpp/siof/siof/duplicate_reports.cpp, __infer_globals_initializer_many_paths_to_siof_bad, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of many_paths_to_siof_bad,call to X_X,call to access_rick,access to rick|] +codetoanalyze/cpp/siof/siof/duplicate_reports.cpp, __infer_globals_initializer_many_paths_to_siof_bad, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of many_paths_to_siof_bad,call to X_X,call to nested_access,access to dangerous|] codetoanalyze/cpp/siof/siof/siof.cpp, __infer_globals_initializer_X::static_pod_accesses_non_pod_bad, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of X::static_pod_accesses_non_pod_bad,call to access_to_non_pod,access to global_object2|codetoanalyze/cpp/siof/siof/siof_different_tu.cpp] codetoanalyze/cpp/siof/siof/siof.cpp, __infer_globals_initializer_X::static_pod_accesses_non_pod_bad, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of X::static_pod_accesses_non_pod_bad,call to access_to_non_pod,access to some_other_global_object2|codetoanalyze/cpp/siof/siof/siof_different_tu.cpp] codetoanalyze/cpp/siof/siof/siof.cpp, __infer_globals_initializer_another_global_object2_bad, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_global_object2_bad,call to access_to_non_pod,access to global_object2|codetoanalyze/cpp/siof/siof/siof_different_tu.cpp] codetoanalyze/cpp/siof/siof/siof.cpp, __infer_globals_initializer_another_global_object2_bad, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_global_object2_bad,call to access_to_non_pod,access to some_other_global_object2|codetoanalyze/cpp/siof/siof/siof_different_tu.cpp] codetoanalyze/cpp/siof/siof/siof.cpp, __infer_globals_initializer_another_global_object3_bad, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_global_object3_bad,call to access_to_templated_non_pod,access to global_object3|codetoanalyze/cpp/siof/siof/siof_different_tu.cpp] -codetoanalyze/cpp/siof/siof/siof.cpp, __infer_globals_initializer_another_global_object_bad, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_global_object_bad,call to SomeOtherNonPODObject_SomeOtherNonPODObject,access to extern_global_object|EXTERN] +codetoanalyze/cpp/siof/siof/siof.cpp, __infer_globals_initializer_another_global_object_bad, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_global_object_bad,call to SomeOtherNonPODObject_SomeOtherNonPODObject,access to extern_global_object|] codetoanalyze/cpp/siof/siof/siof.cpp, __infer_globals_initializer_initWithGlobal_bad, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of initWithGlobal_bad,call to getGlobalNonPOD,access to global_object2|codetoanalyze/cpp/siof/siof/siof_different_tu.cpp] codetoanalyze/cpp/siof/siof/siof.cpp, __infer_globals_initializer_initWithGlobal_bad, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of initWithGlobal_bad,call to getGlobalNonPOD,access to some_other_global_object2|codetoanalyze/cpp/siof/siof/siof_different_tu.cpp] codetoanalyze/cpp/siof/siof/siof.cpp, __infer_globals_initializer_pod_accesses_non_pod_bad, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of pod_accesses_non_pod_bad,call to access_to_non_pod,access to global_object2|codetoanalyze/cpp/siof/siof/siof_different_tu.cpp] @@ -13,5 +13,5 @@ codetoanalyze/cpp/siof/siof/siof.cpp, __infer_globals_initializer_pod_accesses_n codetoanalyze/cpp/siof/siof/siof_templated.cpp, __infer_globals_initializer_another_templated_global_object2_bad, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_templated_global_object2_bad,call to access_to_non_pod,access to global_object2|codetoanalyze/cpp/siof/siof/siof_different_tu.cpp] codetoanalyze/cpp/siof/siof/siof_templated.cpp, __infer_globals_initializer_another_templated_global_object2_bad, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_templated_global_object2_bad,call to access_to_non_pod,access to some_other_global_object2|codetoanalyze/cpp/siof/siof/siof_different_tu.cpp] codetoanalyze/cpp/siof/siof/siof_templated.cpp, __infer_globals_initializer_another_templated_global_object3_bad, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_templated_global_object3_bad,call to access_to_templated_non_pod,access to global_object3|codetoanalyze/cpp/siof/siof/siof_different_tu.cpp] -codetoanalyze/cpp/siof/siof/siof_templated.cpp, __infer_globals_initializer_another_templated_global_object_bad, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_templated_global_object_bad,call to SomeOtherTemplatedNonPODObject<_Bool>_SomeOtherTemplatedNonPODObject,access to extern_global_object|EXTERN] -codetoanalyze/cpp/siof/siof/std_ios_base_init.cpp, __infer_globals_initializer_global_std_cerr_access_bad, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of global_std_cerr_access_bad,call to return_4_SIOF,call to printing_SIOF,access to std::cerr|EXTERN] +codetoanalyze/cpp/siof/siof/siof_templated.cpp, __infer_globals_initializer_another_templated_global_object_bad, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of another_templated_global_object_bad,call to SomeOtherTemplatedNonPODObject<_Bool>_SomeOtherTemplatedNonPODObject,access to extern_global_object|] +codetoanalyze/cpp/siof/siof/std_ios_base_init.cpp, __infer_globals_initializer_global_std_cerr_access_bad, 0, STATIC_INITIALIZATION_ORDER_FIASCO, [initialization of global_std_cerr_access_bad,call to return_4_SIOF,call to printing_SIOF,access to std::cerr|] diff --git a/infer/tests/codetoanalyze/java/quandary/issues.exp b/infer/tests/codetoanalyze/java/quandary/issues.exp index d713a6e5c..adda4cf61 100644 --- a/infer/tests/codetoanalyze/java/quandary/issues.exp +++ b/infer/tests/codetoanalyze/java/quandary/issues.exp @@ -126,7 +126,7 @@ codetoanalyze/java/quandary/Interprocedural.java, void Interprocedural.returnSou codetoanalyze/java/quandary/Interprocedural.java, void Interprocedural.returnSourceDirectViaVarBad(), 2, QUANDARY_TAINT_ERROR, [Return from Object InferTaint.inferSecretSource() with tainted data &return*,Return from Object Interprocedural.returnSourceDirect(),Call to void InferTaint.inferSensitiveSink(Object) with tainted index 0] codetoanalyze/java/quandary/Interprocedural.java, void Interprocedural.returnSourceIndirectBad(), 1, QUANDARY_TAINT_ERROR, [Return from Object InferTaint.inferSecretSource() with tainted data &return*,Return from Object Interprocedural.returnSourceDirect() with tainted data &return*,Return from Object Interprocedural.returnSourceIndirect(),Call to void InferTaint.inferSensitiveSink(Object) with tainted index 0] codetoanalyze/java/quandary/Interprocedural.java, void Interprocedural.returnSourceViaFieldBad(), 1, QUANDARY_TAINT_ERROR, [Return from Object InferTaint.inferSecretSource() with tainted data &return.codetoanalyze.java.quandary.Interprocedural$Obj.f*,Return from Interprocedural$Obj Interprocedural.returnSourceViaField(),Call to void InferTaint.inferSensitiveSink(Object) with tainted index 0] -codetoanalyze/java/quandary/Interprocedural.java, void Interprocedural.returnSourceViaGlobalBad(), 2, QUANDARY_TAINT_ERROR, [Return from Object InferTaint.inferSecretSource() with tainted data &#GB$codetoanalyze.java.quandary.Interprocedural.codetoanalyze.java.quandary.Interprocedural.sGlobal*,Return from void Interprocedural.returnSourceViaGlobal(),Call to void InferTaint.inferSensitiveSink(Object) with tainted index 0] +codetoanalyze/java/quandary/Interprocedural.java, void Interprocedural.returnSourceViaGlobalBad(), 2, QUANDARY_TAINT_ERROR, [Return from Object InferTaint.inferSecretSource() with tainted data &#GB<>$codetoanalyze.java.quandary.Interprocedural.codetoanalyze.java.quandary.Interprocedural.sGlobal*,Return from void Interprocedural.returnSourceViaGlobal(),Call to void InferTaint.inferSensitiveSink(Object) with tainted index 0] codetoanalyze/java/quandary/Interprocedural.java, void Interprocedural.returnSourceViaParameter1Bad(Interprocedural$Obj), 2, QUANDARY_TAINT_ERROR, [Return from Object InferTaint.inferSecretSource() with tainted data @val$0.codetoanalyze.java.quandary.Interprocedural$Obj.f*,Return from void Interprocedural.returnSourceViaParameter1(Interprocedural$Obj),Call to void InferTaint.inferSensitiveSink(Object) with tainted index 0] codetoanalyze/java/quandary/Interprocedural.java, void Interprocedural.returnSourceViaParameter2Bad(Interprocedural$Obj,Interprocedural$Obj), 3, QUANDARY_TAINT_ERROR, [Return from Object InferTaint.inferSecretSource(),Call to void InferTaint.inferSensitiveSink(Object) with tainted index 0] codetoanalyze/java/quandary/Interprocedural.java, void Interprocedural.setGlobalThenCallSinkBad(), 2, QUANDARY_TAINT_ERROR, [Return from Object InferTaint.inferSecretSource(),Call to void Interprocedural.callSinkOnGlobal() with tainted index 0,Call to void InferTaint.inferSensitiveSink(Object) with tainted index 0] diff --git a/infer/tests/codetoanalyze/java/racerd/issues.exp b/infer/tests/codetoanalyze/java/racerd/issues.exp index 25b4ef506..0472c0036 100644 --- a/infer/tests/codetoanalyze/java/racerd/issues.exp +++ b/infer/tests/codetoanalyze/java/racerd/issues.exp @@ -19,12 +19,12 @@ codetoanalyze/java/racerd/Builders.java, Builders$Obj Builders.buildThenMutateBa codetoanalyze/java/racerd/Builders.java, Builders$Obj Builders.buildThenMutateBad(Builders$Obj), 3, THREAD_SAFETY_VIOLATION, [access to `&input.codetoanalyze.java.checkers.Builders$Obj.g`] codetoanalyze/java/racerd/Builders.java, Builders$Obj Builders.mutateBad(Builders$Obj), 1, THREAD_SAFETY_VIOLATION, [access to `&o.codetoanalyze.java.checkers.Builders$Obj.g`] codetoanalyze/java/racerd/Builders.java, void TopLevelBuilder.setG(String), 1, THREAD_SAFETY_VIOLATION, [access to `&this.codetoanalyze.java.checkers.TopLevelBuilder.g`] -codetoanalyze/java/racerd/Constructors.java, Constructors Constructors.FP_singleton2Ok(), 6, THREAD_SAFETY_VIOLATION, [,access to `&#GB$Constructors.Constructors.sSingleton1`,,access to `&#GB$Constructors.Constructors.sSingleton1`] -codetoanalyze/java/racerd/Constructors.java, Constructors Constructors.singleton1Bad(), 2, THREAD_SAFETY_VIOLATION, [call to Constructors.(Object),access to `&#GB$Constructors.Constructors.staticField`] -codetoanalyze/java/racerd/Constructors.java, Constructors Constructors.singleton2Bad(), 1, THREAD_SAFETY_VIOLATION, [,access to `&#GB$Constructors.Constructors.sSingleton2`,,access to `&#GB$Constructors.Constructors.sSingleton2`] -codetoanalyze/java/racerd/Constructors.java, Constructors Constructors.singleton2Bad(), 2, THREAD_SAFETY_VIOLATION, [access to `&#GB$Constructors.Constructors.sSingleton2`] -codetoanalyze/java/racerd/Constructors.java, Constructors Constructors.singleton2Bad(), 4, THREAD_SAFETY_VIOLATION, [,access to `&#GB$Constructors.Constructors.sSingleton2`,,access to `&#GB$Constructors.Constructors.sSingleton2`] -codetoanalyze/java/racerd/Constructors.java, Constructors.(), 1, THREAD_SAFETY_VIOLATION, [access to `&#GB$Constructors.Constructors.staticField`] +codetoanalyze/java/racerd/Constructors.java, Constructors Constructors.FP_singleton2Ok(), 6, THREAD_SAFETY_VIOLATION, [,access to `&#GB<>$Constructors.Constructors.sSingleton1`,,access to `&#GB<>$Constructors.Constructors.sSingleton1`] +codetoanalyze/java/racerd/Constructors.java, Constructors Constructors.singleton1Bad(), 2, THREAD_SAFETY_VIOLATION, [call to Constructors.(Object),access to `&#GB<>$Constructors.Constructors.staticField`] +codetoanalyze/java/racerd/Constructors.java, Constructors Constructors.singleton2Bad(), 1, THREAD_SAFETY_VIOLATION, [,access to `&#GB<>$Constructors.Constructors.sSingleton2`,,access to `&#GB<>$Constructors.Constructors.sSingleton2`] +codetoanalyze/java/racerd/Constructors.java, Constructors Constructors.singleton2Bad(), 2, THREAD_SAFETY_VIOLATION, [access to `&#GB<>$Constructors.Constructors.sSingleton2`] +codetoanalyze/java/racerd/Constructors.java, Constructors Constructors.singleton2Bad(), 4, THREAD_SAFETY_VIOLATION, [,access to `&#GB<>$Constructors.Constructors.sSingleton2`,,access to `&#GB<>$Constructors.Constructors.sSingleton2`] +codetoanalyze/java/racerd/Constructors.java, Constructors.(), 1, THREAD_SAFETY_VIOLATION, [access to `&#GB<>$Constructors.Constructors.staticField`] codetoanalyze/java/racerd/Constructors.java, Constructors.(Constructors), 1, THREAD_SAFETY_VIOLATION, [access to `&o.Constructors.field`] codetoanalyze/java/racerd/Containers.java, boolean Containers.listReadBad(String), 1, THREAD_SAFETY_VIOLATION, [,Read of container `&this.codetoanalyze.java.checkers.Containers.mList` via call to `contains`,,Write to container `&this.codetoanalyze.java.checkers.Containers.mList` via call to `set`] codetoanalyze/java/racerd/Containers.java, int Containers.readSimpleArrayMap(), 1, THREAD_SAFETY_VIOLATION, [,Read of container `&this.codetoanalyze.java.checkers.Containers.si_map` via call to `get`,,Write to container `&this.codetoanalyze.java.checkers.Containers.si_map` via call to `put`] @@ -46,7 +46,7 @@ codetoanalyze/java/racerd/Containers.java, void Containers.mapPutBad(String,Stri codetoanalyze/java/racerd/Containers.java, void Containers.mapRemoveBad(String), 1, THREAD_SAFETY_VIOLATION, [Write to container `&this.codetoanalyze.java.checkers.Containers.mMap` via call to `remove`] codetoanalyze/java/racerd/Containers.java, void Containers.mapSubclassWriteBad(HashMap,String), 1, THREAD_SAFETY_VIOLATION, [Write to container `&m` via call to `remove`] codetoanalyze/java/racerd/Containers.java, void Containers.poolBad(), 5, THREAD_SAFETY_VIOLATION, [Write to container `&this.codetoanalyze.java.checkers.Containers.simplePool` via call to `release`] -codetoanalyze/java/racerd/DeepOwnership.java, void DeepOwnership.globalNotOwnedBad(), 1, THREAD_SAFETY_VIOLATION, [access to `&#GB$DeepOwnership.DeepOwnership.global.DeepOwnership.next`] +codetoanalyze/java/racerd/DeepOwnership.java, void DeepOwnership.globalNotOwnedBad(), 1, THREAD_SAFETY_VIOLATION, [access to `&#GB<>$DeepOwnership.DeepOwnership.global.DeepOwnership.next`] codetoanalyze/java/racerd/DeepOwnership.java, void DeepOwnership.reassignBaseToGlobalBad(), 3, THREAD_SAFETY_VIOLATION, [access to `&x.DeepOwnership.next`] codetoanalyze/java/racerd/Dispatch.java, void Dispatch.callUnannotatedInterfaceBad(UnannotatedInterface), 1, INTERFACE_NOT_THREAD_SAFE, [Call to un-annotated interface method void UnannotatedInterface.foo()] codetoanalyze/java/racerd/Dispatch.java, void Dispatch.callUnannotatedInterfaceIndirectBad(NotThreadSafe,UnannotatedInterface), 1, INTERFACE_NOT_THREAD_SAFE, [call to void NotThreadSafe.notThreadSafeOk(UnannotatedInterface),Call to un-annotated interface method void UnannotatedInterface.foo()] @@ -64,7 +64,7 @@ codetoanalyze/java/racerd/Locks.java, void Locks.negatedReentrantLockTryLockBad( codetoanalyze/java/racerd/Locks.java, void Locks.tryLockNoCheckBad(), 2, THREAD_SAFETY_VIOLATION, [access to `&this.codetoanalyze.java.checkers.Locks.f`] codetoanalyze/java/racerd/Locks.java, void Locks.tryLockWrongBranchBad(), 3, THREAD_SAFETY_VIOLATION, [access to `&this.codetoanalyze.java.checkers.Locks.f`] codetoanalyze/java/racerd/Ownership.java, Ownership.(Obj,Object), 1, THREAD_SAFETY_VIOLATION, [access to `&obj.codetoanalyze.java.checkers.Obj.f`] -codetoanalyze/java/racerd/Ownership.java, int Ownership.readGlobalBad(), 1, THREAD_SAFETY_VIOLATION, [,access to `&#GB$codetoanalyze.java.checkers.Ownership.codetoanalyze.java.checkers.Ownership.global`,,access to `&#GB$codetoanalyze.java.checkers.Ownership.codetoanalyze.java.checkers.Ownership.global`] +codetoanalyze/java/racerd/Ownership.java, int Ownership.readGlobalBad(), 1, THREAD_SAFETY_VIOLATION, [,access to `&#GB<>$codetoanalyze.java.checkers.Ownership.codetoanalyze.java.checkers.Ownership.global`,,access to `&#GB<>$codetoanalyze.java.checkers.Ownership.codetoanalyze.java.checkers.Ownership.global`] codetoanalyze/java/racerd/Ownership.java, void Ownership.cantOwnThisBad(), 1, THREAD_SAFETY_VIOLATION, [call to void Ownership.setField(Obj),access to `&this.codetoanalyze.java.checkers.Ownership.field`] codetoanalyze/java/racerd/Ownership.java, void Ownership.castThenCallBad(), 2, THREAD_SAFETY_VIOLATION, [call to void Ownership.castThenCall(Obj),call to void Subclass.doWrite(),access to `&this.codetoanalyze.java.checkers.Obj.f`] codetoanalyze/java/racerd/Ownership.java, void Ownership.castThenReturnBad(), 2, THREAD_SAFETY_VIOLATION, [access to `n$5.codetoanalyze.java.checkers.Obj.f`]