CodeQL library for Rust
codeql/rust-all 0.2.5-dev (changelog, source)
Search

Member predicate Ssa::Definition::hasAdjacentReads

Holds if read1 and read2 are adjacent reads of this SSA definition. That is, read2 can be reached from read1 without passing through another read.

Example:

fn phi(b : bool) {
     let mut x = 1;             // defines x_0
     println!("{}", x);         // reads x_0 (read1)
     println!("{}", x + 1);     // reads x_0 (read2)

     if b {
         x = 2;                 // defines x_1
         println!("{}", x);     // reads x_1 (read1)
         println!("{}", x + 1); // reads x_1 (read2)
     } else {
         x = 3;                 // defines x_2
         println!("{}", x);     // reads x_2 (read1)
         println!("{}", x + 1); // reads x_2 (read2)
     }
     println!("{}", x);
}
predicate hasAdjacentReads(Expr read1, Expr read2)