Adapt Infer to the new changes introduced by the upgrade to Clang 4.0

Reviewed By: akotulski

Differential Revision: D3757013

fbshipit-source-id: 6abe6b1
master
Martino Luca 9 years ago committed by Facebook Github Bot 6
parent a6bf43a570
commit 80c82c0cae

@ -1 +1 @@
Subproject commit 0a3172fa8d00279b6bb98bedb12bd6cade4c4424
Subproject commit e265f1c643f4cc3db1c252ed9c04c97b62f7474e

@ -13,7 +13,7 @@ CLANG_COMPILER="${SCRIPT_DIR}/../../../facebook-clang-plugins/clang/install/bin/
# path to infer's clang internal headers.
CLANG_INCLUDE_TO_REPLACE="${FCP_CLANG_INCLUDE_TO_REPLACE}"
CLANG_LIB_INCLUDE="${SCRIPT_DIR}/../../../facebook-clang-plugins/clang/install/lib/clang/3.8.0/include"
CLANG_LIB_INCLUDE="${SCRIPT_DIR}/../../../facebook-clang-plugins/clang/install/lib/clang/4.0.0/include"
if [ "${0%++}" != "$0" ]; then XX="++"; else XX=""; fi

@ -77,6 +77,13 @@ struct __dirstream {
};
#endif
// this condition checks whether to use C++ const-overloads of C functions
// for example strchr.
#if defined(__CORRECT_ISO_CPP_STRING_H_PROTO) || \
defined(_LIBCPP_PREFERRED_OVERLOAD)
#define INFER_USE_CPP_CONST_OVERLOAD
#endif
// modelling of errno
// errno expands to different function calls on mac or other systems
// the function call returns the address of a global variable called "errno"
@ -131,7 +138,7 @@ char* strcat(char* s1, const char* s2) {
// The string s must be allocated
// nondeterministically return 0 or a pointer inside the buffer
#ifndef __CORRECT_ISO_CPP_STRING_H_PROTO
#ifndef INFER_USE_CPP_CONST_OVERLOAD
char* strchr(const char* s, int c) {
#else
// This overload is commented out on purpose.
@ -160,7 +167,7 @@ char* strchr(char* s, int c) throw() {
}
// modelled like strchr
#ifndef __CORRECT_ISO_CPP_STRING_H_PROTO
#ifndef INFER_USE_CPP_CONST_OVERLOAD
char* strrchr(const char* s, int c) { return strchr(s, c); }
#else
// This overload is commented out on purpose. Look at strchr() for more info.
@ -242,7 +249,7 @@ char* strncpy(char* s1, const char* s2, size_t n) {
return s1;
}
#ifndef __CORRECT_ISO_CPP_STRING_H_PROTO
#ifndef INFER_USE_CPP_CONST_OVERLOAD
char* strpbrk(const char* s1, const char* s2) {
#else
// This overload is commented out on purpose. Look at strchr() for more info.
@ -279,7 +286,7 @@ size_t strspn(const char* s1, const char* s2) {
return res;
}
#ifndef __CORRECT_ISO_CPP_STRING_H_PROTO
#ifndef INFER_USE_CPP_CONST_OVERLOAD
char* strstr(const char* s1, const char* s2) {
#else
// This overload is commented out on purpose. Look at strchr() for more info.
@ -343,7 +350,7 @@ char* strupr(char* s) {
// the array s must be allocated
// n should not be greater than the size of s
// nondeterministically return 0 or a pointer within the first n elements of s
#ifndef __CORRECT_ISO_CPP_STRING_H_PROTO
#ifndef INFER_USE_CPP_CONST_OVERLOAD
void* memchr(const void* s, int c, size_t n) {
#else
// This overload is commented out on purpose. Look at strchr() for more info.

@ -566,7 +566,8 @@ let translate_block_enumerate block_name stmt_info stmt_list ei =
let unary_op = Clang_ast_t.UnaryOperator (fresh_stmt_info stmt_info, [stop_cast], ei, { Clang_ast_t.uoi_kind = `Deref; uoi_is_postfix = true }) in
let cond = create_implicit_cast_expr (fresh_stmt_info stmt_info) [unary_op] bool_tp `LValueToRValue in
let break_stmt = Clang_ast_t.BreakStmt (fresh_stmt_info stmt_info, []) in
Clang_ast_t.IfStmt (fresh_stmt_info stmt_info, [dummy_stmt (); cond; break_stmt; dummy_stmt ()]) in
Clang_ast_t.IfStmt
(fresh_stmt_info stmt_info, [dummy_stmt(); dummy_stmt (); cond; break_stmt; dummy_stmt ()]) in
let translate params array_cast_decl_ref_exp block_decl block_tp =
match params with

@ -135,7 +135,7 @@ let run_frontend_checkers_on_stmt context cfg cg instr =
invoke_set_of_checkers call_captured_vars_checker context cfg cg key
captured_vars_checker_list;
context
| IfStmt (stmt_info, _ :: cond :: _) ->
| IfStmt (stmt_info, _ :: _ :: cond :: _) ->
let call_checker = checker_for_if_stmt stmt_info [cond] in
let key = Ast_utils.generate_key_stmt cond in
invoke_set_of_checkers call_checker context cfg cg key if_stmt_checker_list;

@ -1327,7 +1327,7 @@ struct
let prune_nodes' = if branch then prune_nodes_t else prune_nodes_f in
IList.iter (fun n -> Cfg.Node.set_succs_exn context.cfg n nodes_branch []) prune_nodes' in
(match stmt_list with
| [decl_stmt; cond; stmt1; stmt2] ->
| [_; decl_stmt; cond; stmt1; stmt2] ->
(* set the flat to inform that we are translating a condition of a if *)
let continuation' = mk_cond_continuation trans_state.continuation in
let trans_state'' = { trans_state with
@ -1353,7 +1353,7 @@ struct
let sil_loc = CLocation.get_sil_location stmt_info context in
let open Clang_ast_t in
match switch_stmt_list with
| [decl_stmt; cond; CompoundStmt(stmt_info, stmt_list)] ->
| [_; decl_stmt; cond; CompoundStmt(stmt_info, stmt_list)] ->
let trans_state_pri = PriorityNode.try_claim_priority_node trans_state stmt_info in
let trans_state' ={ trans_state_pri with succ_nodes = []} in
let res_trans_cond_tmp = instruction trans_state' cond in
@ -1598,11 +1598,12 @@ struct
and cxxForRangeStmt_trans trans_state stmt_info stmt_list =
let open Clang_ast_t in
match stmt_list with
| [iterator_decl; initial_cond; exit_cond; increment; assign_current_index; loop_body] ->
| [iterator_decl; begin_stmt; end_stmt; exit_cond; increment; assign_current_index; loop_body] ->
let loop_body' = CompoundStmt (stmt_info, [assign_current_index; loop_body]) in
let null_stmt = NullStmt (stmt_info, []) in
let beginend_stmt = CompoundStmt (stmt_info, [begin_stmt; end_stmt]) in
let for_loop =
ForStmt (stmt_info, [initial_cond; null_stmt; exit_cond; increment; loop_body']) in
ForStmt (stmt_info, [beginend_stmt; null_stmt; exit_cond; increment; loop_body']) in
instruction trans_state (CompoundStmt (stmt_info, [iterator_decl; for_loop]))
| _ -> assert false

Loading…
Cancel
Save