123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051(* Yoann Padioleau
*
* Copyright (C) 2014 Facebook
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation, with the
* special exception on linking described in file license.txt.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file
* license.txt for more details.
*)openCommonmoduleE=Entity_codemoduleG=Graph_code(*****************************************************************************)(* Prelude *)(*****************************************************************************)letpropagate_users_of_functions_globals_types_to_prototype_extern_typedefsg=letpred=G.mk_eff_use_predging|>G.iter_nodes(funn->letn_def_opt=matchnwith|s,E.Prototype->Some(s,E.Function)|s,E.GlobalExtern->Some(s,E.Global)(* todo: actually should look at env.typedefs because it's not
* necessaraly T_Xxxx -> S_Xxxx
*)|s,E.Typewhens=~"T__\\(.*\\)$"->Some("S__"^(Common.matched1s),E.Type)|_->Noneinn_def_opt|>Common.do_option(funn_def->letn_decl=ninifG.has_noden_defgthenbegin(* let's create a link between the def and the decl *)g|>G.add_edge(n_def,n_decl)G.Use;(* and now the users *)letusers=predn_definusers|>List.iter(funuser->g|>G.add_edge(user,n_decl)G.Use)end))