Replace '/' in anonymous type names

Summary: public anonymous types have file:line in its name.
Since file is relative path, type name can have '/' in its name.
This is very fragile since we might create file wiht typename in its name (for example for methods).
Replacing '/' with '_' should make frontend more resilient to failure.
Translation of anonymous structs is still pretty fragile (due to relative path in its name),
but at least it doesn't crash frontend

Reviewed By: dulmarod

Differential Revision: D2559936

fb-gh-sync-id: 647fd7f
master
Andrzej Kotulski 9 years ago committed by facebook-github-bot-7
parent 1f973cfc12
commit 87dfcdeb99

@ -69,7 +69,8 @@ let add_predefined_types tenv =
let create_csu opt_type = let create_csu opt_type =
match opt_type with match opt_type with
| `Type s -> | `Type s ->
(let buf = Str.split (Str.regexp "[ \t]+") s in (let no_slash = Str.global_replace (Str.regexp "/") "_" s in
let buf = Str.split (Str.regexp "[ \t]+") no_slash in
match buf with match buf with
| "struct":: l ->Sil.Struct, General_utils.string_from_list l | "struct":: l ->Sil.Struct, General_utils.string_from_list l
| "class":: l -> Sil.Class, General_utils.string_from_list l | "class":: l -> Sil.Class, General_utils.string_from_list l

@ -1,5 +1,5 @@
digraph iCFG { digraph iCFG {
7 [label="7: BinaryOperatorStmt: Assign \n n$3=*&#GB$x:struct (anonymous at infer/tests/codetoanalyze/c/frontend/nestedoperators/union.c:12:1) * [line 27]\n *n$3.a:int =1 [line 27]\n REMOVE_TEMPS(n$3); [line 27]\n " shape="box"] 7 [label="7: BinaryOperatorStmt: Assign \n n$3=*&#GB$x:struct (anonymous at infer_tests_codetoanalyze_c_frontend_nestedoperators_union.c:12:1) * [line 27]\n *n$3.a:int =1 [line 27]\n REMOVE_TEMPS(n$3); [line 27]\n " shape="box"]
7 -> 6 ; 7 -> 6 ;
@ -11,7 +11,7 @@ digraph iCFG {
5 -> 4 ; 5 -> 4 ;
4 [label="4: BinaryOperatorStmt: Assign \n n$0=*&#GB$x:struct (anonymous at infer/tests/codetoanalyze/c/frontend/nestedoperators/union.c:12:1) * [line 31]\n n$1=*n$0.b:int [line 31]\n *&#GB$y.g.w:int =n$1 [line 31]\n REMOVE_TEMPS(n$0,n$1); [line 31]\n " shape="box"] 4 [label="4: BinaryOperatorStmt: Assign \n n$0=*&#GB$x:struct (anonymous at infer_tests_codetoanalyze_c_frontend_nestedoperators_union.c:12:1) * [line 31]\n n$1=*n$0.b:int [line 31]\n *&#GB$y.g.w:int =n$1 [line 31]\n REMOVE_TEMPS(n$0,n$1); [line 31]\n " shape="box"]
4 -> 3 ; 4 -> 3 ;

Loading…
Cancel
Save