diff --git a/facebook-clang-plugins b/facebook-clang-plugins index 18ea5ae42..6fe051624 160000 --- a/facebook-clang-plugins +++ b/facebook-clang-plugins @@ -1 +1 @@ -Subproject commit 18ea5ae4205367ba3411210cb644ac983323818a +Subproject commit 6fe0516240c68e8a8aa123996ba54c6f9247f64a diff --git a/infer/src/clang/Capture.ml b/infer/src/clang/Capture.ml index b15823994..a3e429534 100644 --- a/infer/src/clang/Capture.ml +++ b/infer/src/clang/Capture.ml @@ -13,15 +13,13 @@ module L = Logging (** enable debug mode (to get more data saved to disk for future inspections) *) let debug_mode = Config.debug_mode || Config.frontend_stats -let buffer_len = 262143 - -(* This function reads the json file in fname, validates it, and encoded in the AST data structure - defined in Clang_ast_t. *) +(** This function reads the json file in fname, validates it, and encodes in the AST data structure + defined in Clang_ast_t. *) let validate_decl_from_file fname = - Ag_util.Biniou.from_file ~len:buffer_len Clang_ast_b.read_decl fname + Ag_util.Biniou.from_file ~len:CFrontend_config.biniou_buffer_size Clang_ast_b.read_decl fname let validate_decl_from_channel chan = - Ag_util.Biniou.from_channel ~len:buffer_len Clang_ast_b.read_decl chan + Ag_util.Biniou.from_channel ~len:CFrontend_config.biniou_buffer_size Clang_ast_b.read_decl chan let register_perf_stats_report source_file = let stats_dir = Filename.concat Config.results_dir Config.frontend_stats_dir_name in @@ -150,15 +148,14 @@ let cc1_capture clang_cmd = then ( L.(debug Capture Quiet) "@\n Skip compilation and analysis of source file %s@\n@\n" source_path ; () ) - else ( - ( match Config.clang_biniou_file with + else + match Config.clang_biniou_file with | Some fname -> run_and_validate_clang_frontend (`File fname) | None -> run_plugin_and_frontend source_path (fun chan_in -> run_and_validate_clang_frontend (`Pipe chan_in)) - clang_cmd ) ; - () ) + clang_cmd let capture clang_cmd = if ClangCommand.can_attach_ast_exporter clang_cmd then diff --git a/infer/src/clang/ClangCommand.ml b/infer/src/clang/ClangCommand.ml index 79cdaaf38..f3314a73e 100644 --- a/infer/src/clang/ClangCommand.ml +++ b/infer/src/clang/ClangCommand.ml @@ -147,6 +147,7 @@ let command_to_run cmd = let with_exec exec args = {args with exec} let with_plugin_args args = + let plugin_arg_flag = "-plugin-arg-" ^ plugin_name in let args_before_rev = [] |> (* -cc1 has to be the first argument or clang will think it runs in driver mode *) @@ -162,10 +163,12 @@ let with_plugin_args args = xcodebuild plus all the sub-steps happy. *) (if has_flag args "-fmodules" then "-plugin" else "-add-plugin") ; plugin_name - ; ("-plugin-arg-" ^ plugin_name) + ; plugin_arg_flag ; "-" - ; ("-plugin-arg-" ^ plugin_name) - ; "PREPEND_CURRENT_DIR=1" ] + ; plugin_arg_flag + ; "PREPEND_CURRENT_DIR=1" + ; plugin_arg_flag + ; ("MAX_STRING_SIZE=" ^ string_of_int CFrontend_config.biniou_buffer_size) ] in (* add -O0 option to avoid compiler obfuscation of AST *) let args_after_rev = diff --git a/infer/src/clang/cFrontend_config.ml b/infer/src/clang/cFrontend_config.ml index 3b27cd565..68b319b14 100644 --- a/infer/src/clang/cFrontend_config.ml +++ b/infer/src/clang/cFrontend_config.ml @@ -40,6 +40,10 @@ let atomic_att = "<\"Atomic\">" let autorelease = "autorelease" +let biniou_buffer_size = + (* the C++ standard suggests that implementation should support string literals up to this length *) + 65535 + let block = "block" let builtin_expect = "__builtin_expect" diff --git a/infer/src/clang/cFrontend_config.mli b/infer/src/clang/cFrontend_config.mli index fb424815c..7a0fe3885 100644 --- a/infer/src/clang/cFrontend_config.mli +++ b/infer/src/clang/cFrontend_config.mli @@ -43,6 +43,8 @@ val atomic_att : string val autorelease : string +val biniou_buffer_size : int + val block : string val builtin_expect : string diff --git a/infer/src/clang/cPredicates.ml b/infer/src/clang/cPredicates.ml index 3dd1afc8a..b58d18dd1 100644 --- a/infer/src/clang/cPredicates.ml +++ b/infer/src/clang/cPredicates.ml @@ -752,7 +752,7 @@ let has_value an al_exp = | Stmt IntegerLiteral (_, _, _, integer_literal_info) -> let value = integer_literal_info.Clang_ast_t.ili_value in ALVar.compare_str_with_alexp value al_exp - | Stmt StringLiteral (_, _, _, s) - -> ALVar.compare_str_with_alexp s al_exp + | Stmt StringLiteral (_, _, _, l) + -> ALVar.compare_str_with_alexp (String.concat ~sep:"" l) al_exp | _ -> false diff --git a/infer/src/clang/cTrans.ml b/infer/src/clang/cTrans.ml index 399bfdfb0..f9bd77877 100644 --- a/infer/src/clang/cTrans.ml +++ b/infer/src/clang/cTrans.ml @@ -3132,8 +3132,8 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s -> cast_exprs_trans trans_state stmt_info stmt_list expr_info cast_kind | IntegerLiteral (_, _, expr_info, integer_literal_info) -> integerLiteral_trans trans_state expr_info integer_literal_info - | StringLiteral (_, _, expr_info, str) - -> stringLiteral_trans trans_state expr_info str + | StringLiteral (_, _, expr_info, str_list) + -> stringLiteral_trans trans_state expr_info (String.concat ~sep:"" str_list) | GNUNullExpr (_, _, expr_info) -> gNUNullExpr_trans trans_state expr_info | CXXNullPtrLiteralExpr (_, _, expr_info) diff --git a/infer/src/clang/ctl_parser_types.ml b/infer/src/clang/ctl_parser_types.ml index 74f33aa36..b9bfad245 100644 --- a/infer/src/clang/ctl_parser_types.ml +++ b/infer/src/clang/ctl_parser_types.ml @@ -69,8 +69,8 @@ let rec ast_node_name an = match decl_ref.dr_name with Some name -> name.ni_name | None -> "" in ast_node_name (Stmt stmt) ^ "." ^ property_str - | Stmt StringLiteral (_, _, _, s) - -> s + | Stmt StringLiteral (_, _, _, l) + -> String.concat ~sep:"" l | Stmt ObjCStringLiteral (_, [stmt], _) -> "@" ^ ast_node_name (Stmt stmt) | Stmt ObjCBoxedExpr (_, [stmt], _, objc_boxed_expr_info)