From 077d2ae2f56b8f5c8a0dbcad05fb0fb323a97059 Mon Sep 17 00:00:00 2001 From: Sungkeun Cho Date: Thu, 22 Feb 2018 20:30:31 -0800 Subject: [PATCH] [infer] Disable sorting fields Summary: The struct fields in Cil have been sorted for long time, however the checkers do not seem to depend on the sortedness. Reviewed By: sblackshear Differential Revision: D7027858 fbshipit-source-id: 9e7ab96 --- infer/src/IR/Tenv.ml | 11 ----------- infer/src/IR/Tenv.mli | 2 -- infer/src/clang/cFrontend.ml | 1 - .../tests/codetoanalyze/cpp/bufferoverrun/issues.exp | 2 +- 4 files changed, 1 insertion(+), 15 deletions(-) diff --git a/infer/src/IR/Tenv.ml b/infer/src/IR/Tenv.ml index ea309b75f..a235fc04a 100644 --- a/infer/src/IR/Tenv.ml +++ b/infer/src/IR/Tenv.ml @@ -23,8 +23,6 @@ end) (** Type for type environment. *) type t = Typ.Struct.t TypenameHash.t -let iter f tenv = TypenameHash.iter f tenv - let pp fmt (tenv: t) = TypenameHash.iter (fun name typ -> @@ -62,15 +60,6 @@ let compare_fields (name1, _, _) (name2, _, _) = Typ.Fieldname.compare name1 nam let equal_fields f1 f2 = Int.equal (compare_fields f1 f2) 0 -let sort_fields fields = List.sort ~cmp:compare_fields fields - -let sort_fields_tenv tenv = - let sort_fields_struct name ({Typ.Struct.fields} as st) = - ignore (mk_struct tenv ~default:st ~fields:(sort_fields fields) name) - in - iter sort_fields_struct tenv - - (** Add a field to a given struct in the global type environment. *) let add_field tenv class_tn_name field = match lookup tenv class_tn_name with diff --git a/infer/src/IR/Tenv.mli b/infer/src/IR/Tenv.mli index cbef26909..5895d97a0 100644 --- a/infer/src/IR/Tenv.mli +++ b/infer/src/IR/Tenv.mli @@ -41,8 +41,6 @@ val mk_struct : val add_field : t -> Typ.Name.t -> Typ.Struct.field -> unit (** Add a field to a given struct in the global type environment. *) -val sort_fields_tenv : t -> unit - val pp : Format.formatter -> t -> unit [@@warning "-32"] (** print a type environment *) diff --git a/infer/src/clang/cFrontend.ml b/infer/src/clang/cFrontend.ml index 1789cc731..86efb428d 100644 --- a/infer/src/clang/cFrontend.ml +++ b/infer/src/clang/cFrontend.ml @@ -52,7 +52,6 @@ let do_source_file (translation_unit_context: CFrontend_config.translation_unit_ (* This could be moved in the cfg_infer module *) NullabilityPreanalysis.analysis cfg tenv ; Cfg.store source_file cfg ; - Tenv.sort_fields_tenv tenv ; Tenv.store source_file tenv ; if Config.debug_mode then Cfg.check_cfg_connectedness cfg ; if Config.debug_mode || Config.testing_mode || Config.frontend_tests diff --git a/infer/tests/codetoanalyze/cpp/bufferoverrun/issues.exp b/infer/tests/codetoanalyze/cpp/bufferoverrun/issues.exp index c39dedfa2..e614bae12 100644 --- a/infer/tests/codetoanalyze/cpp/bufferoverrun/issues.exp +++ b/infer/tests/codetoanalyze/cpp/bufferoverrun/issues.exp @@ -22,7 +22,7 @@ codetoanalyze/cpp/bufferoverrun/vector.cpp, assert_Good_FP, 6, BUFFER_OVERRUN_L3 codetoanalyze/cpp/bufferoverrun/vector.cpp, data_Bad, 4, BUFFER_OVERRUN_L1, [Call,Call,Assignment,Call,Call,ArrayDeclaration,Assignment,Assignment,Return,Assignment,Assignment,Return,Assignment,Assignment,ArrayAccess: Offset: [10, 10] Size: [5, 5]] codetoanalyze/cpp/bufferoverrun/vector.cpp, just_test_model_FP, 16, BUFFER_OVERRUN_L5, [Call,ArrayAccess: Offset: [-oo, +oo] Size: [0, +oo]] codetoanalyze/cpp/bufferoverrun/vector.cpp, just_test_model_FP, 18, BUFFER_OVERRUN_L3, [Call,Call,Call,Assignment,Call,Call,Call,Call,Call,ArrayDeclaration,Assignment,ArrayAccess: Offset: [1, 1] Size: [0, +oo]] -codetoanalyze/cpp/bufferoverrun/vector.cpp, out_of_bound_Bad, 2, BUFFER_OVERRUN_L2, [Call,Call,Call,ArrayDeclaration,Assignment,ArrayAccess: Offset: [u$12, u$13] Size: [u$12, u$13]] +codetoanalyze/cpp/bufferoverrun/vector.cpp, out_of_bound_Bad, 2, BUFFER_OVERRUN_L2, [Call,Call,Call,ArrayDeclaration,Assignment,ArrayAccess: Offset: [u$4, u$5] Size: [u$4, u$5]] codetoanalyze/cpp/bufferoverrun/vector.cpp, precise_subst_Bad, 3, BUFFER_OVERRUN_L1, [ArrayDeclaration,Call,Assignment,Call,Assignment,Call,Call,Assignment,Return,ArrayAccess: Offset: [-1, -1] Size: [10, 10] @ codetoanalyze/cpp/bufferoverrun/vector.cpp:206:3 by call `access_minus_one()` ] codetoanalyze/cpp/bufferoverrun/vector.cpp, precise_subst_Good_FP, 3, BUFFER_OVERRUN_L3, [ArrayDeclaration,Call,Assignment,Call,Assignment,Call,Call,Assignment,Return,ArrayAccess: Offset: [-1, 0] Size: [10, 10] @ codetoanalyze/cpp/bufferoverrun/vector.cpp:206:3 by call `access_minus_one()` ] codetoanalyze/cpp/bufferoverrun/vector.cpp, push_back_Bad, 3, BUFFER_OVERRUN_L1, [Call,Call,Assignment,Call,Assignment,Call,Call,ArrayDeclaration,Assignment,ArrayAccess: Offset: [1, 1] Size: [1, 1]]