From cd49a0c72db39587c67cca84b35e89461eb1f7ee Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Wed, 3 Oct 2018 05:17:22 -0700 Subject: [PATCH] [cfg] store the same version of the attributes as the attributes table Summary: Before storing attributes to disk, we fix their location information if needed. Ideally we wouldn't be creating bogus attributes but sometimes the frontends are built in a way that makes it difficult to do otherwise, thus we have to live with this. However, what's aggravating is that attributes are also saved in the proc descs of these procedures but in their wrong version. This makes the two versions (inside the procedures sqlite table and inside the procdesc in the cfg of the source_files table) agree. Reviewed By: jeremydubreil Differential Revision: D10084708 fbshipit-source-id: 5bfd5da3a --- infer/src/IR/Cfg.ml | 3 ++- infer/src/IR/Procdesc.ml | 4 +++- infer/src/IR/Procdesc.mli | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/infer/src/IR/Cfg.ml b/infer/src/IR/Cfg.ml index 950a8f8c3..cd807dd24 100644 --- a/infer/src/IR/Cfg.ml +++ b/infer/src/IR/Cfg.ml @@ -75,7 +75,8 @@ let save_attributes source_file cfg = let loc' = if Location.equal loc Location.dummy then {loc with file= source_file} else loc in {attributes with loc= loc'; translation_unit= source_file} in - Attributes.store attributes' + Attributes.store attributes' ; + Procdesc.set_attributes pdesc attributes' in Typ.Procname.Hash.iter save_proc cfg diff --git a/infer/src/IR/Procdesc.ml b/infer/src/IR/Procdesc.ml index 36e2c99ff..8b1c96dc4 100644 --- a/infer/src/IR/Procdesc.ml +++ b/infer/src/IR/Procdesc.ml @@ -393,7 +393,7 @@ module IdMap = Node.IdMap (** procedure description *) type t = - { attributes: ProcAttributes.t (** attributes of the procedure *) + { mutable attributes: ProcAttributes.t (** attributes of the procedure *) ; mutable nodes: Node.t list (** list of nodes of this procedure *) ; mutable nodes_num: int (** number of nodes *) ; mutable start_node: Node.t (** start node of this procedure *) @@ -433,6 +433,8 @@ let signal_did_preanalysis pdesc = (pdesc.attributes).did_preanalysis <- true let get_attributes pdesc = pdesc.attributes +let set_attributes pdesc attributes = pdesc.attributes <- attributes + let get_exit_node pdesc = pdesc.exit_node (** Return name and type of formal parameters *) diff --git a/infer/src/IR/Procdesc.mli b/infer/src/IR/Procdesc.mli index 623c0e3cb..24ba67545 100644 --- a/infer/src/IR/Procdesc.mli +++ b/infer/src/IR/Procdesc.mli @@ -202,6 +202,8 @@ val get_access : t -> PredSymb.access val get_attributes : t -> ProcAttributes.t (** Get the attributes of the procedure. *) +val set_attributes : t -> ProcAttributes.t -> unit + val get_captured : t -> (Mangled.t * Typ.t) list (** Return name and type of block's captured variables *)