Documentation ¶
Overview ¶
Package preprocess hosts preprocessing logic for the input (e.g., CFGs etc.) to make it more amenable to analysis.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Preprocessor ¶
type Preprocessor struct {
// contains filtered or unexported fields
}
Preprocessor handles different preprocessing logic for different types of input.
func (*Preprocessor) CFG ¶
CFG performs several passes on the CFG of utility to our analysis and returns a shallow copy of the modified CFG, with the original CFG untouched.
Specifically, it performs the following modifications to the CFG:
Canonicalize conditionals: - replace `if !cond {T} {F}` with `if cond {F} {T}` (swap successors) - replace `if cond1 && cond2 {T} {F}` with `if cond1 {if cond2 {T} else {F}}{F}` (nesting) - replace `if cond1 || cond2 {T} {F}` with `if cond1 {T} else {if cond2 {T} else {F}}` (nesting)
Canonicalize nil comparisons: It also performs the following useful transformation: - replace `if x != nil {T} {F}` with `if x == nil {F} {T}` (swap successors) - replace `nil == x {T} {F}` with `if x == nil {T} {F}` (swap comparison order)
Canonicalize explicit boolean comparisons: - replace `if x == true {T} {F}` with `if x {T} {F}` - replace `if x == false {T} {F}` with `if !x {T} {F}`