diff --git a/facebook-clang-plugins b/facebook-clang-plugins index 74635a68e..f31f7c9c2 160000 --- a/facebook-clang-plugins +++ b/facebook-clang-plugins @@ -1 +1 @@ -Subproject commit 74635a68ec1fee857cf1d3c3bfa7503f3a41491e +Subproject commit f31f7c9c28d8fb9b59c0dacc74a24e4bfe90a904 diff --git a/infer/src/clang/CType_decl.ml b/infer/src/clang/CType_decl.ml index 91880e843..68323a030 100644 --- a/infer/src/clang/CType_decl.ml +++ b/infer/src/clang/CType_decl.ml @@ -510,7 +510,7 @@ and get_template_info tenv (fdi: Clang_ast_t.function_decl_info) = Typ.NoTemplate -and mk_c_function ?tenv ~is_cpp name function_decl_info_opt = +and mk_c_function ?tenv name function_decl_info_opt = let file = match function_decl_info_opt with | Some (decl_info, function_decl_info) -> ( @@ -531,12 +531,12 @@ and mk_c_function ?tenv ~is_cpp name function_decl_info_opt = | None -> "" in - let mangled_opt = + let mangled_opt, is_cpp = match function_decl_info_opt with | Some (_, function_decl_info) -> - function_decl_info.Clang_ast_t.fdi_mangled_name + (function_decl_info.Clang_ast_t.fdi_mangled_name, function_decl_info.Clang_ast_t.fdi_is_cpp) | _ -> - None + (None, false) in let mangled_name = match mangled_opt with Some m when is_cpp -> m | _ -> "" in let template_info = @@ -606,13 +606,12 @@ and objc_block_procname outer_proc_opt = (* TODO: get the parameters from BuildMethodSignature.get_parameters and pass it to the method names *) -and from_decl ?tenv ~is_cpp ?outer_proc meth_decl = +and from_decl ?tenv ?outer_proc meth_decl = let open Clang_ast_t in match meth_decl with | FunctionDecl (decl_info, name_info, _, fdi) -> let name = CAst_utils.get_qualified_name name_info in - let function_info = Some (decl_info, fdi) in - mk_c_function ~is_cpp ?tenv name function_info + mk_c_function ?tenv name (Some (decl_info, fdi)) | CXXMethodDecl (decl_info, name_info, _, fdi, mdi) | CXXConstructorDecl (decl_info, name_info, _, fdi, mdi) | CXXConversionDecl (decl_info, name_info, _, fdi, mdi) @@ -641,7 +640,7 @@ and get_struct_methods struct_decl tenv = | CXXDestructorDecl _ | ObjCMethodDecl _ | BlockDecl _ -> - Some (from_decl ~is_cpp:true ~tenv decl) + Some (from_decl ~tenv decl) | _ -> None ) @@ -700,9 +699,9 @@ module CProcname = struct let from_decl = from_decl module NoAstDecl = struct - let c_function_of_string ~is_cpp tenv name = + let c_function_of_string tenv name = let qual_name = QualifiedCppName.of_qual_string name in - mk_c_function ~is_cpp ~tenv qual_name None + mk_c_function ~tenv qual_name None let cpp_method_of_string tenv class_name method_name = @@ -713,7 +712,7 @@ module CProcname = struct mk_objc_method class_name method_name method_kind end - let from_decl_for_linters ~is_cpp method_decl = + let from_decl_for_linters method_decl = let open Clang_ast_t in match method_decl with | ObjCMethodDecl (decl_info, name_info, mdi) -> @@ -726,7 +725,7 @@ module CProcname = struct in objc_method_procname decl_info method_name mdi | _ -> - from_decl ~is_cpp method_decl + from_decl method_decl end let get_type_from_expr_info ei tenv = diff --git a/infer/src/clang/CType_decl.mli b/infer/src/clang/CType_decl.mli index 87e7fb305..9c891eaa2 100644 --- a/infer/src/clang/CType_decl.mli +++ b/infer/src/clang/CType_decl.mli @@ -10,12 +10,11 @@ open! IStd module CProcname : sig - val from_decl : - ?tenv:Tenv.t -> is_cpp:bool -> ?outer_proc:Typ.Procname.t -> Clang_ast_t.decl -> Typ.Procname.t + val from_decl : ?tenv:Tenv.t -> ?outer_proc:Typ.Procname.t -> Clang_ast_t.decl -> Typ.Procname.t (** Given decl, return its procname. This function should be used for all procedures present in original AST *) - val from_decl_for_linters : is_cpp:bool -> Clang_ast_t.decl -> Typ.Procname.t + val from_decl_for_linters : Clang_ast_t.decl -> Typ.Procname.t (** This is used for bug hashing for linters. In ObjC the method names contain the parameter names, thus if people add new parameters, any bug about the method will be considered different which means reporting on unchanged code. So, in the ObjC method case, we create the method name only based on the @@ -23,7 +22,7 @@ module CProcname : sig (** WARNING: functions from this module should not be used if full decl is available in AST *) module NoAstDecl : sig - val c_function_of_string : is_cpp:bool -> Tenv.t -> string -> Typ.Procname.t + val c_function_of_string : Tenv.t -> string -> Typ.Procname.t val cpp_method_of_string : Tenv.t -> Typ.Name.t -> string -> Typ.Procname.t diff --git a/infer/src/clang/cFrontend_decl.ml b/infer/src/clang/cFrontend_decl.ml index ea83e9209..fceec67dc 100644 --- a/infer/src/clang/cFrontend_decl.ml +++ b/infer/src/clang/cFrontend_decl.ml @@ -112,7 +112,7 @@ module CFrontend_decl_funct (T : CModule_type.CTranslation) : CModule_type.CFron | Some (_, block_return_type, procname, _) -> (procname, Some block_return_type) | _ -> - (CType_decl.CProcname.from_decl ~is_cpp ~tenv func_decl, None) + (CType_decl.CProcname.from_decl ~tenv func_decl, None) in let ms, body_opt, extra_instrs = CType_decl.method_signature_body_of_decl ~is_cpp tenv func_decl ?block_return_type procname @@ -137,7 +137,7 @@ module CFrontend_decl_funct (T : CModule_type.CTranslation) : CModule_type.CFron let is_cpp = CGeneral_utils.is_cpp_translation trans_unit_ctx in try let ms, body_opt, extra_instrs = - let procname = CType_decl.CProcname.from_decl ~is_cpp ~tenv meth_decl in + let procname = CType_decl.CProcname.from_decl ~tenv meth_decl in CType_decl.method_signature_body_of_decl ~is_cpp tenv meth_decl procname in match body_opt with diff --git a/infer/src/clang/cFrontend_errors.ml b/infer/src/clang/cFrontend_errors.ml index daa2d870c..d0d9f81a4 100644 --- a/infer/src/clang/cFrontend_errors.ml +++ b/infer/src/clang/cFrontend_errors.ml @@ -436,12 +436,12 @@ let expand_checkers macro_map path_map checkers = (** Add a frontend warning with a description desc at location loc to the errlog of a proc desc *) -let log_frontend_issue ~is_cpp method_decl_opt (node: Ctl_parser_types.ast_node) +let log_frontend_issue method_decl_opt (node: Ctl_parser_types.ast_node) (issue_desc: CIssue.issue_desc) linters_def_file = let procname = match method_decl_opt with | Some method_decl -> - CType_decl.CProcname.from_decl_for_linters ~is_cpp method_decl + CType_decl.CProcname.from_decl_for_linters method_decl | None -> Typ.Procname.Linters_dummy_method in @@ -471,12 +471,7 @@ let fill_issue_desc_info_and_log context an (issue_desc: CIssue.issue_desc) lint let description = process_message issue_desc.description in let suggestion = Option.map ~f:process_message issue_desc.suggestion in let issue_desc' = {issue_desc with description; loc; suggestion} in - let is_cpp = - CGeneral_utils.is_cpp_translation context.CLintersContext.translation_unit_context - in - try - log_frontend_issue ~is_cpp context.CLintersContext.current_method an issue_desc' - linters_def_file + try log_frontend_issue context.CLintersContext.current_method an issue_desc' linters_def_file with CFrontend_config.IncorrectAssumption e -> let trans_unit_ctx = context.CLintersContext.translation_unit_context in ClangLogging.log_caught_exception trans_unit_ctx "IncorrectAssumption" e.position diff --git a/infer/src/clang/cMethod_trans.ml b/infer/src/clang/cMethod_trans.ml index 88d02517e..4a120de84 100644 --- a/infer/src/clang/cMethod_trans.ml +++ b/infer/src/clang/cMethod_trans.ml @@ -27,7 +27,7 @@ let method_signature_of_pointer trans_unit_ctx tenv pointer = try match CAst_utils.get_decl pointer with | Some meth_decl -> - let procname = CType_decl.CProcname.from_decl ~is_cpp ~tenv meth_decl in + let procname = CType_decl.CProcname.from_decl ~tenv meth_decl in let ms = CType_decl.method_signature_of_decl ~is_cpp tenv meth_decl procname in Some ms | None -> @@ -333,8 +333,7 @@ let create_procdesc_with_pointer context pointer class_name_opt name = ( CType_decl.CProcname.NoAstDecl.cpp_method_of_string context.tenv class_name name , ProcAttributes.CPP_INSTANCE ) | None -> - let is_cpp = CGeneral_utils.is_cpp_translation context.translation_unit_context in - ( CType_decl.CProcname.NoAstDecl.c_function_of_string ~is_cpp context.tenv name + ( CType_decl.CProcname.NoAstDecl.c_function_of_string context.tenv name , ProcAttributes.C_FUNCTION ) in create_external_procdesc context.cfg callee_name method_kind None ; diff --git a/infer/src/clang/cTrans.ml b/infer/src/clang/cTrans.ml index 117ac5d0f..0c1101020 100644 --- a/infer/src/clang/cTrans.ml +++ b/infer/src/clang/cTrans.ml @@ -2637,13 +2637,10 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s and blockExpr_trans trans_state stmt_info expr_info decl = let context = trans_state.context in let outer_proc = Procdesc.get_proc_name context.CContext.procdesc in - let is_cpp = CGeneral_utils.is_cpp_translation context.translation_unit_context in match decl with | Clang_ast_t.BlockDecl (_, block_decl_info) -> let open CContext in - let block_pname = - CType_decl.CProcname.from_decl decl ~tenv:context.tenv ~is_cpp ~outer_proc - in + let block_pname = CType_decl.CProcname.from_decl decl ~tenv:context.tenv ~outer_proc in let captured_pvars = CVar_decl.captured_vars_from_block_info context stmt_info.Clang_ast_t.si_source_range block_decl_info.Clang_ast_t.bdi_captured_variables