Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/util/cilfacade.ml
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ let varinfo_roles: varinfo_role VarinfoH.t ResettableLazy.t =
VarinfoH.replace h fd.svar Function; (* function itself can be used as a variable (function pointer) *)
List.iter (fun vi -> VarinfoH.replace h vi (Formal fd)) fd.sformals;
List.iter (fun vi -> VarinfoH.replace h vi (Local fd)) fd.slocals
| GVarDecl (vi, _) when Cil.isFunctionType vi.vtype ->
VarinfoH.replace h vi Function
| GVar (vi, _, _)
| GVarDecl (vi, _) ->
VarinfoH.replace h vi Global
Expand Down
39 changes: 39 additions & 0 deletions src/util/server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,45 @@ let () =
| None -> Response.Error.(raise (make ~code:RequestFailed ~message:"not analyzed" ()))
end);

register (module struct
let name = "cil/varinfos"
type params = unit [@@deriving of_yojson]
type varinfo_data = {
vid: int;
name: string;
original_name: string option;
role: string;
function_: CilType.Fundec.t option [@key "function"] [@default None];
} [@@deriving to_yojson]
type response = varinfo_data list [@@deriving to_yojson]
let process () serv =
Cilfacade.VarinfoH.fold (fun vi role acc ->
let role_str = match role with
| Cilfacade.Formal _ -> "formal"
| Local _ -> "local"
| Function -> "function"
| Global -> "global"
in
let function_ = match role with
| Cilfacade.Formal fd
| Local fd ->
Some fd
| Function
| Global ->
None
in
let data = {
vid = vi.vid;
name = vi.vname;
original_name = Cilfacade.find_original_name vi;
role = role_str;
function_;
}
in
data :: acc
) (ResettableLazy.force Cilfacade.varinfo_roles) []
end);

register (module struct
let name = "cfg"
type params = { fname: string } [@@deriving of_yojson]
Expand Down