Skip to content

Commit

Permalink
[clang] correct sizeof info
Browse files Browse the repository at this point in the history
Summary:
Bumps facebook-clang-plugins to a version that outputs sizeof() info in bytes and not bits.

update-submodule: facebook-clang-plugins

Reviewed By: akotulski

Differential Revision: D5526747

fbshipit-source-id: 6019542
  • Loading branch information
jvillard authored and facebook-github-bot committed Jul 31, 2017
1 parent 0793e0f commit fe01f47
Show file tree
Hide file tree
Showing 45 changed files with 142 additions and 138 deletions.
2 changes: 1 addition & 1 deletion facebook-clang-plugins
7 changes: 6 additions & 1 deletion infer/src/IR/Exp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,12 @@ let rec pp_ pe pp_t f e =
| Sizeof {typ; nbytes; dynamic_length; subtype}
-> let pp_len f l = Option.iter ~f:(F.fprintf f "[%a]" pp_exp) l in
let pp_size f size = Option.iter ~f:(Int.pp f) size in
F.fprintf f "sizeof(%a%a%a%a)" pp_t typ pp_size nbytes pp_len dynamic_length Subtype.pp
let pp_if b pp label f v = if b then F.fprintf f ";%s=%a" label pp v in
let pp_if_some pp_opt label f opt = pp_if (Option.is_some opt) pp_opt label f opt in
let subt_s = F.asprintf "%a" Subtype.pp subtype in
F.fprintf f "sizeof(t=%a%a%a%a)" pp_t typ (pp_if_some pp_size "nbytes") nbytes
(pp_if_some pp_len "len") dynamic_length
(pp_if (not (String.equal "" subt_s)) Subtype.pp "sub_t")
subtype

let pp_printenv pe pp_typ f e = pp_ pe (pp_typ pe) f e
Expand Down
1 change: 0 additions & 1 deletion infer/tests/codetoanalyze/c/bufferoverrun/issues.exp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ codetoanalyze/c/bufferoverrun/prune_constant.c, prune_constant_true_Ok, 3, CONDI
codetoanalyze/c/bufferoverrun/prune_constant.c, prune_constant_value_Ok, 3, CONDITION_ALWAYS_FALSE, []
codetoanalyze/c/bufferoverrun/sizeof.c, eval_sizeof_bad, 1, CONDITION_ALWAYS_TRUE, []
codetoanalyze/c/bufferoverrun/sizeof.c, eval_sizeof_bad, 4, BUFFER_OVERRUN, [ArrayDeclaration,ArrayAccess: Offset: [1, 1] Size: [0, 0]]
codetoanalyze/c/bufferoverrun/sizeof.c, sizeof_char_good_FP, 2, BUFFER_OVERRUN, [ArrayDeclaration,ArrayAccess: Offset: [79, 79] Size: [10, 10]]
codetoanalyze/c/bufferoverrun/sizeof.c, static_stride_bad, 7, BUFFER_OVERRUN, [ArrayDeclaration,ArrayAccess: Offset: [1, 1] Size: [0, 0]]
codetoanalyze/c/bufferoverrun/trivial.c, trivial, 2, BUFFER_OVERRUN, [ArrayDeclaration,ArrayAccess: Offset: [10, 10] Size: [10, 10]]
codetoanalyze/c/bufferoverrun/unreachable.c, FP_exit_at_end_of_proc_good, 2, UNREACHABLE_CODE, []
Expand Down
2 changes: 1 addition & 1 deletion infer/tests/codetoanalyze/c/bufferoverrun/sizeof.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void static_stride_bad() {
}
}

void sizeof_char_good_FP(int i) {
void sizeof_char_good(int i) {
char b[10];
b[sizeof(b) - 1] = 123;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* @generated */
digraph iCFG {
"init_const_array.b1cf412cdbd1beaf15a9f6a3789043b9_1" [label="1: Start init_const_array\nFormals: \nLocals: a:int[3*32][2*96] z:int \n DECLARE_LOCALS(&return,&a,&z); [line 10]\n " color=yellow style=filled]
"init_const_array.b1cf412cdbd1beaf15a9f6a3789043b9_1" [label="1: Start init_const_array\nFormals: \nLocals: a:int[3*4][2*12] z:int \n DECLARE_LOCALS(&return,&a,&z); [line 10]\n " color=yellow style=filled]


"init_const_array.b1cf412cdbd1beaf15a9f6a3789043b9_1" -> "init_const_array.b1cf412cdbd1beaf15a9f6a3789043b9_3" ;
Expand All @@ -11,14 +11,14 @@ digraph iCFG {


"init_const_array.b1cf412cdbd1beaf15a9f6a3789043b9_3" -> "init_const_array.b1cf412cdbd1beaf15a9f6a3789043b9_2" ;
"init_variable_array.8cdc6857adcb1fd04fb6555d8ce3e4c1_1" [label="1: Start init_variable_array\nFormals: len:int\nLocals: a:int[_*32] x:int \n DECLARE_LOCALS(&return,&a,&x); [line 15]\n " color=yellow style=filled]
"init_variable_array.8cdc6857adcb1fd04fb6555d8ce3e4c1_1" [label="1: Start init_variable_array\nFormals: len:int\nLocals: a:int[_*4] x:int \n DECLARE_LOCALS(&return,&a,&x); [line 15]\n " color=yellow style=filled]


"init_variable_array.8cdc6857adcb1fd04fb6555d8ce3e4c1_1" -> "init_variable_array.8cdc6857adcb1fd04fb6555d8ce3e4c1_4" ;
"init_variable_array.8cdc6857adcb1fd04fb6555d8ce3e4c1_2" [label="2: Exit init_variable_array \n " color=yellow style=filled]


"init_variable_array.8cdc6857adcb1fd04fb6555d8ce3e4c1_3" [label="3: Fallback node \n n$0=*&len:int [line 17]\n n$1=*&x:int [line 17]\n _fun___set_array_length(&a:int[_*32],((n$0 + n$1) + 1):int) [line 17]\n " shape="box"]
"init_variable_array.8cdc6857adcb1fd04fb6555d8ce3e4c1_3" [label="3: Fallback node \n n$0=*&len:int [line 17]\n n$1=*&x:int [line 17]\n _fun___set_array_length(&a:int[_*4],((n$0 + n$1) + 1):int) [line 17]\n " shape="box"]


"init_variable_array.8cdc6857adcb1fd04fb6555d8ce3e4c1_3" -> "init_variable_array.8cdc6857adcb1fd04fb6555d8ce3e4c1_2" ;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* @generated */
digraph iCFG {
"vaarg_foo.73af1e8d32c2d09f7488c5fea173b853_1" [label="1: Start vaarg_foo\nFormals: x:int\nLocals: val:int i:int valist:void[1*192] \n DECLARE_LOCALS(&return,&val,&i,&valist); [line 12]\n " color=yellow style=filled]
"vaarg_foo.73af1e8d32c2d09f7488c5fea173b853_1" [label="1: Start vaarg_foo\nFormals: x:int\nLocals: val:int i:int valist:void[1*24] \n DECLARE_LOCALS(&return,&val,&i,&valist); [line 12]\n " color=yellow style=filled]


"vaarg_foo.73af1e8d32c2d09f7488c5fea173b853_1" -> "vaarg_foo.73af1e8d32c2d09f7488c5fea173b853_12" ;
Expand Down
4 changes: 2 additions & 2 deletions infer/tests/codetoanalyze/cpp/frontend/builtin/new.cpp.dot
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ digraph iCFG {


"test#_Z4testv.1b928d988491fdd2fa78fcb048d46e8c_3" -> "test#_Z4testv.1b928d988491fdd2fa78fcb048d46e8c_2" ;
"test#_Z4testv.1b928d988491fdd2fa78fcb048d46e8c_4" [label="4: CXXNewExpr \n n$1=_fun___new(sizeof(int):unsigned long) [line 13]\n " shape="box"]
"test#_Z4testv.1b928d988491fdd2fa78fcb048d46e8c_4" [label="4: CXXNewExpr \n n$1=_fun___new(sizeof(t=int):unsigned long) [line 13]\n " shape="box"]


"test#_Z4testv.1b928d988491fdd2fa78fcb048d46e8c_4" -> "test#_Z4testv.1b928d988491fdd2fa78fcb048d46e8c_3" ;
"test#_Z4testv.1b928d988491fdd2fa78fcb048d46e8c_5" [label="5: DeclStmt \n n$2=_fun___new(sizeof(int):unsigned long) [line 12]\n *&i:int*=n$2 [line 12]\n " shape="box"]
"test#_Z4testv.1b928d988491fdd2fa78fcb048d46e8c_5" [label="5: DeclStmt \n n$2=_fun___new(sizeof(t=int):unsigned long) [line 12]\n *&i:int*=n$2 [line 12]\n " shape="box"]


"test#_Z4testv.1b928d988491fdd2fa78fcb048d46e8c_5" -> "test#_Z4testv.1b928d988491fdd2fa78fcb048d46e8c_4" ;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* @generated */
digraph iCFG {
"array_of_person#_Z15array_of_personv.7c553fa3272204bd300dabdf4e138df7_1" [label="1: Start array_of_person\nFormals: \nLocals: arr:Person[10*32] 0$?%__sil_tmpSIL_materialize_temp__n$1:Person 0$?%__sil_tmpSIL_materialize_temp__n$2:Person 0$?%__sil_tmpSIL_materialize_temp__n$3:Person \n DECLARE_LOCALS(&return,&arr,&0$?%__sil_tmpSIL_materialize_temp__n$1,&0$?%__sil_tmpSIL_materialize_temp__n$2,&0$?%__sil_tmpSIL_materialize_temp__n$3); [line 17]\n " color=yellow style=filled]
"array_of_person#_Z15array_of_personv.7c553fa3272204bd300dabdf4e138df7_1" [label="1: Start array_of_person\nFormals: \nLocals: arr:Person[10*4] 0$?%__sil_tmpSIL_materialize_temp__n$1:Person 0$?%__sil_tmpSIL_materialize_temp__n$2:Person 0$?%__sil_tmpSIL_materialize_temp__n$3:Person \n DECLARE_LOCALS(&return,&arr,&0$?%__sil_tmpSIL_materialize_temp__n$1,&0$?%__sil_tmpSIL_materialize_temp__n$2,&0$?%__sil_tmpSIL_materialize_temp__n$3); [line 17]\n " color=yellow style=filled]


"array_of_person#_Z15array_of_personv.7c553fa3272204bd300dabdf4e138df7_1" -> "array_of_person#_Z15array_of_personv.7c553fa3272204bd300dabdf4e138df7_4" ;
Expand All @@ -15,7 +15,7 @@ digraph iCFG {


"array_of_person#_Z15array_of_personv.7c553fa3272204bd300dabdf4e138df7_4" -> "array_of_person#_Z15array_of_personv.7c553fa3272204bd300dabdf4e138df7_3" ;
"matrix_of_person#_Z16matrix_of_personv.39f4dcf0df55c7259a99fabe8ccde35d_1" [label="1: Start matrix_of_person\nFormals: \nLocals: arr:Person[2*32][2*64] 0$?%__sil_tmpSIL_materialize_temp__n$1:Person 0$?%__sil_tmpSIL_materialize_temp__n$2:Person 0$?%__sil_tmpSIL_materialize_temp__n$3:Person 0$?%__sil_tmpSIL_materialize_temp__n$4:Person \n DECLARE_LOCALS(&return,&arr,&0$?%__sil_tmpSIL_materialize_temp__n$1,&0$?%__sil_tmpSIL_materialize_temp__n$2,&0$?%__sil_tmpSIL_materialize_temp__n$3,&0$?%__sil_tmpSIL_materialize_temp__n$4); [line 22]\n " color=yellow style=filled]
"matrix_of_person#_Z16matrix_of_personv.39f4dcf0df55c7259a99fabe8ccde35d_1" [label="1: Start matrix_of_person\nFormals: \nLocals: arr:Person[2*4][2*8] 0$?%__sil_tmpSIL_materialize_temp__n$1:Person 0$?%__sil_tmpSIL_materialize_temp__n$2:Person 0$?%__sil_tmpSIL_materialize_temp__n$3:Person 0$?%__sil_tmpSIL_materialize_temp__n$4:Person \n DECLARE_LOCALS(&return,&arr,&0$?%__sil_tmpSIL_materialize_temp__n$1,&0$?%__sil_tmpSIL_materialize_temp__n$2,&0$?%__sil_tmpSIL_materialize_temp__n$3,&0$?%__sil_tmpSIL_materialize_temp__n$4); [line 22]\n " color=yellow style=filled]


"matrix_of_person#_Z16matrix_of_personv.39f4dcf0df55c7259a99fabe8ccde35d_1" -> "matrix_of_person#_Z16matrix_of_personv.39f4dcf0df55c7259a99fabe8ccde35d_4" ;
Expand All @@ -30,7 +30,7 @@ digraph iCFG {


"matrix_of_person#_Z16matrix_of_personv.39f4dcf0df55c7259a99fabe8ccde35d_4" -> "matrix_of_person#_Z16matrix_of_personv.39f4dcf0df55c7259a99fabe8ccde35d_3" ;
"initialization_c_style#_Z22initialization_c_stylev.6b9bfbb6779ee90799bffc017bfd501e_1" [label="1: Start initialization_c_style\nFormals: \nLocals: z2:Z z:Z[2*64] \n DECLARE_LOCALS(&return,&z2,&z); [line 32]\n " color=yellow style=filled]
"initialization_c_style#_Z22initialization_c_stylev.6b9bfbb6779ee90799bffc017bfd501e_1" [label="1: Start initialization_c_style\nFormals: \nLocals: z2:Z z:Z[2*8] \n DECLARE_LOCALS(&return,&z2,&z); [line 32]\n " color=yellow style=filled]


"initialization_c_style#_Z22initialization_c_stylev.6b9bfbb6779ee90799bffc017bfd501e_1" -> "initialization_c_style#_Z22initialization_c_stylev.6b9bfbb6779ee90799bffc017bfd501e_4" ;
Expand All @@ -45,7 +45,7 @@ digraph iCFG {


"initialization_c_style#_Z22initialization_c_stylev.6b9bfbb6779ee90799bffc017bfd501e_4" -> "initialization_c_style#_Z22initialization_c_stylev.6b9bfbb6779ee90799bffc017bfd501e_3" ;
"initialization_mixed_styles_not_handled_correctly#_Z49initialization_mixed_styles_not_handled_correc.e1de50291cecd2ac4e0ba29b88e060a6_1" [label="1: Start initialization_mixed_styles_not_handled_correctly\nFormals: \nLocals: z2:Z z:Z[2*64] old:Z \n DECLARE_LOCALS(&return,&z2,&z,&old); [line 39]\n " color=yellow style=filled]
"initialization_mixed_styles_not_handled_correctly#_Z49initialization_mixed_styles_not_handled_correc.e1de50291cecd2ac4e0ba29b88e060a6_1" [label="1: Start initialization_mixed_styles_not_handled_correctly\nFormals: \nLocals: z2:Z z:Z[2*8] old:Z \n DECLARE_LOCALS(&return,&z2,&z,&old); [line 39]\n " color=yellow style=filled]


"initialization_mixed_styles_not_handled_correctly#_Z49initialization_mixed_styles_not_handled_correc.e1de50291cecd2ac4e0ba29b88e060a6_1" -> "initialization_mixed_styles_not_handled_correctly#_Z49initialization_mixed_styles_not_handled_correc.e1de50291cecd2ac4e0ba29b88e060a6_5" ;
Expand Down
Loading

0 comments on commit fe01f47

Please sign in to comment.