diff --git a/facebook-clang-plugins b/facebook-clang-plugins index 45a30fed6..bf80f9131 160000 --- a/facebook-clang-plugins +++ b/facebook-clang-plugins @@ -1 +1 @@ -Subproject commit 45a30fed67fb7b7697aacace1d93f17655105c54 +Subproject commit bf80f91312d92617eebddb8331f971682acdb9ee diff --git a/infer/src/IR/Pvar.ml b/infer/src/IR/Pvar.ml index 50958607e..9c6ca87e9 100644 --- a/infer/src/IR/Pvar.ml +++ b/infer/src/IR/Pvar.ml @@ -25,6 +25,7 @@ type pvar_kind = | Global_var of { translation_unit: translation_unit ; is_constexpr: bool (* is it compile constant? *) + ; is_ice: bool (* is it integral constant expression? *) ; is_pod: bool ; is_static_local: bool ; is_static_global: bool } (** global variable *) @@ -77,9 +78,10 @@ let pp_ f pv = F.fprintf f "%a|abducedRetvar" Mangled.pp name | Abduced_ref_param (_, index, _) -> F.fprintf f "%a|abducedRefParam%d" Mangled.pp name index - | Global_var {translation_unit; is_constexpr; is_pod} -> - F.fprintf f "#GB<%a%s%s>$%a" pp_translation_unit translation_unit + | Global_var {translation_unit; is_constexpr; is_ice; is_pod} -> + F.fprintf f "#GB<%a%s%s%s>$%a" pp_translation_unit translation_unit (if is_constexpr then "|const" else "") + (if is_ice then "|ice" else "") (if not is_pod then "|!pod" else "") Mangled.pp name | Seed_var -> @@ -215,11 +217,12 @@ 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) +let mk_global ?(is_constexpr = false) ?(is_ice = false) ?(is_pod = true) ?(is_static_local = false) ?(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} + ; pv_kind= + Global_var {translation_unit; is_constexpr; is_ice; is_pod; is_static_local; is_static_global} } diff --git a/infer/src/IR/Pvar.mli b/infer/src/IR/Pvar.mli index d25c61718..452a3c679 100644 --- a/infer/src/IR/Pvar.mli +++ b/infer/src/IR/Pvar.mli @@ -94,6 +94,7 @@ val mk_callee : Mangled.t -> Typ.Procname.t -> t val mk_global : ?is_constexpr:bool + -> ?is_ice:bool -> ?is_pod:bool -> ?is_static_local:bool -> ?is_static_global:bool diff --git a/infer/src/clang/cGeneral_utils.ml b/infer/src/clang/cGeneral_utils.ml index cd6d2acef..7aaa88ca0 100644 --- a/infer/src/clang/cGeneral_utils.ml +++ b/infer/src/clang/cGeneral_utils.ml @@ -121,6 +121,7 @@ let mk_sil_global_var {CFrontend_config.source_file} ?(mk_name = fun _ x -> x) d Some source_file in let is_constexpr = var_decl_info.Clang_ast_t.vdi_is_const_expr in + let is_ice = var_decl_info.Clang_ast_t.vdi_is_init_ice in let is_pod = CAst_utils.get_desugared_type qt.Clang_ast_t.qt_type_ptr |> Option.bind ~f:(function @@ -142,7 +143,7 @@ let mk_sil_global_var {CFrontend_config.source_file} ?(mk_name = fun _ x -> x) d && (not var_decl_info.Clang_ast_t.vdi_is_static_data_member) && match var_decl_info.Clang_ast_t.vdi_storage_class with Some "static" -> true | _ -> false in - Pvar.mk_global ~is_constexpr ~is_pod + Pvar.mk_global ~is_constexpr ~is_ice ~is_pod ~is_static_local:var_decl_info.Clang_ast_t.vdi_is_static_local ~is_static_global ?translation_unit (mk_name name_string simple_name) diff --git a/infer/tests/codetoanalyze/cpp/frontend/globals/global_const1.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/globals/global_const1.cpp.dot index d4e888eab..965502594 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/globals/global_const1.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/globals/global_const1.cpp.dot @@ -18,7 +18,7 @@ digraph cfg { "__infer_globals_initializer_v#708fabe5dc8ff523caaa5f44184921e8.588095fa475e4a9e8c83f50f26a48ea9_2" [label="2: Exit __infer_globals_initializer_v \n " color=yellow style=filled] -"__infer_globals_initializer_v#708fabe5dc8ff523caaa5f44184921e8.588095fa475e4a9e8c83f50f26a48ea9_3" [label="3: DeclStmt \n *&#GB$v:int=2 [line 15, column 1]\n " shape="box"] +"__infer_globals_initializer_v#708fabe5dc8ff523caaa5f44184921e8.588095fa475e4a9e8c83f50f26a48ea9_3" [label="3: DeclStmt \n *&#GB$v:int=2 [line 15, column 1]\n " shape="box"] "__infer_globals_initializer_v#708fabe5dc8ff523caaa5f44184921e8.588095fa475e4a9e8c83f50f26a48ea9_3" -> "__infer_globals_initializer_v#708fabe5dc8ff523caaa5f44184921e8.588095fa475e4a9e8c83f50f26a48ea9_2" ; @@ -40,11 +40,11 @@ digraph cfg { "test2#3587805488049044947.69e45cfdc4e36a6f741ce3985858724b_2" [label="2: Exit test2 \n " color=yellow style=filled] -"test2#3587805488049044947.69e45cfdc4e36a6f741ce3985858724b_3" [label="3: Return Stmt \n n$0=*&#GB$v:int [line 19, column 10]\n *&return:int=n$0 [line 19, column 3]\n " shape="box"] +"test2#3587805488049044947.69e45cfdc4e36a6f741ce3985858724b_3" [label="3: Return Stmt \n n$0=*&#GB$v:int [line 19, column 10]\n *&return:int=n$0 [line 19, column 3]\n " shape="box"] "test2#3587805488049044947.69e45cfdc4e36a6f741ce3985858724b_3" -> "test2#3587805488049044947.69e45cfdc4e36a6f741ce3985858724b_2" ; -"test2#3587805488049044947.69e45cfdc4e36a6f741ce3985858724b_4" [label="4: DeclStmt \n n$2=*&#GB$v:int [line 18, column 15]\n *&local:int=n$2 [line 18, column 3]\n " shape="box"] +"test2#3587805488049044947.69e45cfdc4e36a6f741ce3985858724b_4" [label="4: DeclStmt \n n$2=*&#GB$v:int [line 18, column 15]\n *&local:int=n$2 [line 18, column 3]\n " shape="box"] "test2#3587805488049044947.69e45cfdc4e36a6f741ce3985858724b_4" -> "test2#3587805488049044947.69e45cfdc4e36a6f741ce3985858724b_3" ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/globals/global_const2.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/globals/global_const2.cpp.dot index 6828e976d..05d65e61e 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/globals/global_const2.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/globals/global_const2.cpp.dot @@ -28,7 +28,7 @@ digraph cfg { "__infer_globals_initializer_global.bdc08c089842ce08b974b22a75daf78e_7" -> "__infer_globals_initializer_global.bdc08c089842ce08b974b22a75daf78e_3" ; -"__infer_globals_initializer_global.bdc08c089842ce08b974b22a75daf78e_8" [label="8: DeclStmt \n n$1=*&0$?%__sil_tmpSIL_temp_conditional___n$0:int [line 8, column 20]\n *&#GB$global:int=n$1 [line 8, column 1]\n " shape="box"] +"__infer_globals_initializer_global.bdc08c089842ce08b974b22a75daf78e_8" [label="8: DeclStmt \n n$1=*&0$?%__sil_tmpSIL_temp_conditional___n$0:int [line 8, column 20]\n *&#GB$global:int=n$1 [line 8, column 1]\n " shape="box"] "__infer_globals_initializer_global.bdc08c089842ce08b974b22a75daf78e_8" -> "__infer_globals_initializer_global.bdc08c089842ce08b974b22a75daf78e_2" ; @@ -39,7 +39,7 @@ digraph cfg { "test#18241244337164948030.afc14f193ad97442f67ac7183be789bc_2" [label="2: Exit test \n " color=yellow style=filled] -"test#18241244337164948030.afc14f193ad97442f67ac7183be789bc_3" [label="3: Return Stmt \n n$0=*&#GB$global:int [line 9, column 21]\n *&return:int=n$0 [line 9, column 14]\n " shape="box"] +"test#18241244337164948030.afc14f193ad97442f67ac7183be789bc_3" [label="3: Return Stmt \n n$0=*&#GB$global:int [line 9, column 21]\n *&return:int=n$0 [line 9, column 14]\n " shape="box"] "test#18241244337164948030.afc14f193ad97442f67ac7183be789bc_3" -> "test#18241244337164948030.afc14f193ad97442f67ac7183be789bc_2" ; diff --git a/infer/tests/codetoanalyze/cpp/shared/methods/byvals.cpp.dot b/infer/tests/codetoanalyze/cpp/shared/methods/byvals.cpp.dot index 3e5332858..058965b39 100644 --- a/infer/tests/codetoanalyze/cpp/shared/methods/byvals.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/shared/methods/byvals.cpp.dot @@ -51,7 +51,7 @@ digraph cfg { "dummy_struct#__infer_globals_initializer_pass_by_val.24fe54080733cebf362d2b34e691bb44_2" [label="2: Exit __infer_globals_initializer_pass_by_val::dummy_struct \n " color=yellow style=filled] -"dummy_struct#__infer_globals_initializer_pass_by_val.24fe54080733cebf362d2b34e691bb44_3" [label="3: DeclStmt \n *&#GB$pass_by_val::dummy_struct.x:int=0 [line 15, column 25]\n *&#GB$pass_by_val::dummy_struct.y:int*=null [line 15, column 25]\n " shape="box"] +"dummy_struct#__infer_globals_initializer_pass_by_val.24fe54080733cebf362d2b34e691bb44_3" [label="3: DeclStmt \n *&#GB$pass_by_val::dummy_struct.x:int=0 [line 15, column 25]\n *&#GB$pass_by_val::dummy_struct.y:int*=null [line 15, column 25]\n " shape="box"] "dummy_struct#__infer_globals_initializer_pass_by_val.24fe54080733cebf362d2b34e691bb44_3" -> "dummy_struct#__infer_globals_initializer_pass_by_val.24fe54080733cebf362d2b34e691bb44_2" ; diff --git a/infer/tests/codetoanalyze/cpp/shared/namespace/namespace.cpp.dot b/infer/tests/codetoanalyze/cpp/shared/namespace/namespace.cpp.dot index 461b603ef..5b4baeea2 100644 --- a/infer/tests/codetoanalyze/cpp/shared/namespace/namespace.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/shared/namespace/namespace.cpp.dot @@ -11,7 +11,7 @@ digraph cfg { "main.fad58de7366495db4650cfefac2fcd61_3" -> "main.fad58de7366495db4650cfefac2fcd61_2" ; -"main.fad58de7366495db4650cfefac2fcd61_4" [label="4: BinaryOperatorStmt: Assign \n n$1=*&#GB$bar::pi:double [line 55, column 7]\n *&j:double=n$1 [line 55, column 3]\n " shape="box"] +"main.fad58de7366495db4650cfefac2fcd61_4" [label="4: BinaryOperatorStmt: Assign \n n$1=*&#GB$bar::pi:double [line 55, column 7]\n *&j:double=n$1 [line 55, column 3]\n " shape="box"] "main.fad58de7366495db4650cfefac2fcd61_4" -> "main.fad58de7366495db4650cfefac2fcd61_3" ; @@ -54,7 +54,7 @@ digraph cfg { "pi#__infer_globals_initializer_bar.1155d696836634e07d40a8f71831e209_2" [label="2: Exit __infer_globals_initializer_bar::pi \n " color=yellow style=filled] -"pi#__infer_globals_initializer_bar.1155d696836634e07d40a8f71831e209_3" [label="3: DeclStmt \n *&#GB$bar::pi:double=3.1416 [line 27, column 1]\n " shape="box"] +"pi#__infer_globals_initializer_bar.1155d696836634e07d40a8f71831e209_3" [label="3: DeclStmt \n *&#GB$bar::pi:double=3.1416 [line 27, column 1]\n " shape="box"] "pi#__infer_globals_initializer_bar.1155d696836634e07d40a8f71831e209_3" -> "pi#__infer_globals_initializer_bar.1155d696836634e07d40a8f71831e209_2" ; @@ -76,7 +76,7 @@ digraph cfg { "value#bar#16302148298864778751.e55afab5e7523c08687d7e6558d5dad5_2" [label="2: Exit bar::value \n " color=yellow style=filled] -"value#bar#16302148298864778751.e55afab5e7523c08687d7e6558d5dad5_3" [label="3: Return Stmt \n n$0=*&#GB$bar::pi:double [line 28, column 29]\n *&return:double=(2 * n$0) [line 28, column 18]\n " shape="box"] +"value#bar#16302148298864778751.e55afab5e7523c08687d7e6558d5dad5_3" [label="3: Return Stmt \n n$0=*&#GB$bar::pi:double [line 28, column 29]\n *&return:double=(2 * n$0) [line 28, column 18]\n " shape="box"] "value#bar#16302148298864778751.e55afab5e7523c08687d7e6558d5dad5_3" -> "value#bar#16302148298864778751.e55afab5e7523c08687d7e6558d5dad5_2" ; diff --git a/infer/tests/codetoanalyze/objcpp/frontend/global_const/global_const.mm.dot b/infer/tests/codetoanalyze/objcpp/frontend/global_const/global_const.mm.dot index 274923001..97175c5f1 100644 --- a/infer/tests/codetoanalyze/objcpp/frontend/global_const/global_const.mm.dot +++ b/infer/tests/codetoanalyze/objcpp/frontend/global_const/global_const.mm.dot @@ -7,7 +7,7 @@ digraph cfg { "__infer_globals_initializer___someFields#305cac08d8197bd145f7f55cc8a06d16.794b83eea8b5794c71808060b1f3b5c7_2" [label="2: Exit __infer_globals_initializer___someFields \n " color=yellow style=filled] -"__infer_globals_initializer___someFields#305cac08d8197bd145f7f55cc8a06d16.794b83eea8b5794c71808060b1f3b5c7_3" [label="3: DeclStmt \n *&#GB$__someFields.field1:float=1 [line 14, column 36]\n *&#GB$__someFields.field2:float=2 [line 14, column 36]\n *&#GB$__someFields.field3:float=3 [line 14, column 36]\n " shape="box"] +"__infer_globals_initializer___someFields#305cac08d8197bd145f7f55cc8a06d16.794b83eea8b5794c71808060b1f3b5c7_3" [label="3: DeclStmt \n *&#GB$__someFields.field1:float=1 [line 14, column 36]\n *&#GB$__someFields.field2:float=2 [line 14, column 36]\n *&#GB$__someFields.field3:float=3 [line 14, column 36]\n " shape="box"] "__infer_globals_initializer___someFields#305cac08d8197bd145f7f55cc8a06d16.794b83eea8b5794c71808060b1f3b5c7_3" -> "__infer_globals_initializer___someFields#305cac08d8197bd145f7f55cc8a06d16.794b83eea8b5794c71808060b1f3b5c7_2" ; @@ -18,7 +18,7 @@ digraph cfg { "fields(class Fields)#3037629886785813687.ade89225d198ce505301d5cdffda48f1_2" [label="2: Exit fields \n " color=yellow style=filled] -"fields(class Fields)#3037629886785813687.ade89225d198ce505301d5cdffda48f1_3" [label="3: Return Stmt \n n$0=*&__return_param:Fields* [line 20, column 19]\n n$1=_fun_Fields_(n$0:Fields*,&#GB$__someFields:Fields const &) [line 20, column 26]\n " shape="box"] +"fields(class Fields)#3037629886785813687.ade89225d198ce505301d5cdffda48f1_3" [label="3: Return Stmt \n n$0=*&__return_param:Fields* [line 20, column 19]\n n$1=_fun_Fields_(n$0:Fields*,&#GB$__someFields:Fields const &) [line 20, column 26]\n " shape="box"] "fields(class Fields)#3037629886785813687.ade89225d198ce505301d5cdffda48f1_3" -> "fields(class Fields)#3037629886785813687.ade89225d198ce505301d5cdffda48f1_2" ;