Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
41 changes: 41 additions & 0 deletions src/analyses/branchSet.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
(** Helper analysis to be path-sensitive in set of taken branches. *)

open GoblintCil
open Analyses

module Spec =
struct
include Analyses.IdentitySpec

module Branch = Printable.ProdSimple(BoolDomain.Bool)(CilType.Location)
module BranchSet = SetDomain.Make(Branch)

module D = BranchSet
include Analyses.ValueContexts(D)
module P = IdentityP (D)


let enter man (lval: lval option) (f:fundec) (args:exp list) : (D.t * D.t) list =
[man.local,man.local]

let combine_env man lval fexp f args fc au f_ask =
au

let combine_assign man (lval:lval option) fexp (f:fundec) (args:exp list) fc (au:D.t) (f_ask: Queries.ask) : D.t =
man.local


let branch man (exp:exp) (tv:bool) : D.t =
let loc = Node.location man.node in
BranchSet.add (tv, loc) man.local


let name () = "branchSet"

let startstate v = D.empty ()
let threadenter man ~multiple lval f args = [D.empty ()]
let exitstate v = D.empty ()
end

let _ =
MCP.register_analysis (module Spec : MCPSpec)
2 changes: 1 addition & 1 deletion src/config/options.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@
"description": "List of path-sensitive analyses",
"type": "array",
"items": { "type": "string" },
"default": [ "mutex", "malloc_null", "uninit", "expsplit","activeSetjmp","memLeak" ]
"default": [ "mutex", "malloc_null", "uninit", "expsplit", "activeSetjmp", "memLeak", "branchSet"]
},
"ctx_insens": {
"title": "ana.ctx_insens",
Expand Down
1 change: 1 addition & 0 deletions src/goblint_lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ module PthreadSignals = PthreadSignals
module PthreadBarriers = PthreadBarriers
module ExtractPthread = ExtractPthread
module PthreadOnce = PthreadOnce
module BranchSet = BranchSet

(** {2 Longjmp}

Expand Down
25 changes: 25 additions & 0 deletions tests/regression/88-branchset/01-set.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//PARAM: --enable ana.int.interval --set ana.activated[+] branchSet
#include <stdio.h>
#include <stdlib.h>
#include <goblint.h>

int main () {
int a;
int b;

int top;
int top2;

if(top) {
a = 5; b = 5;
} else {
a = 10; b = 10;
}

if(top2) {
a = -5; b = 8;
}

__goblint_check(top2 || a == b);
return 0;
}
Loading