Struct cwe_checker_lib::intermediate_representation::Blk
source · pub struct Blk {
pub defs: Vec<Term<Def>>,
pub jmps: Vec<Term<Jmp>>,
pub indirect_jmp_targets: Vec<Tid>,
}
Expand description
A basic block is a sequence of Def
instructions followed by up to two Jmp
instructions.
The Def
instructions represent side-effectful operations that are executed in order when the block is entered.
Def
instructions do not affect the control flow of a program.
The Jmp
instructions represent control flow affecting operations.
There can only be zero, one or two Jmp
s:
- Zero
Jmp
s indicate that the next execution to be executed could not be discerned. This should only happen on disassembler errors or on dead ends in the control flow graph that were deliberately inserted by the user. - If there is exactly one
Jmp
, it is required to be an unconditional jump. - For two jumps, the first one has to be a conditional jump, where the second unconditional jump is only taken if the condition of the first jump evaluates to false.
If one of the Jmp
instructions is an indirect jump,
then the indirect_jmp_targets
is a list of possible jump target addresses for that jump.
The list may not be complete and the entries are not guaranteed to be correct.
Basic blocks are single entry, single exit, i.e. a basic block is only entered at the beginning and is only exited by the jump instructions at the end of the block. If a new control flow edge is discovered that would jump to the middle of a basic block, the block structure needs to be updated accordingly.
Fields§
§defs: Vec<Term<Def>>
The Def
instructions of the basic block in order of execution.
jmps: Vec<Term<Jmp>>
The Jmp
instructions of the basic block
indirect_jmp_targets: Vec<Tid>
If the basic block contains an indirect jump, this field contains possible jump target addresses for the jump.
Note that possible targets of indirect calls are not contained,
since the Project
normalization passes assume
that only intraprocedural jump targets are contained in this field.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Blk
impl<'de> Deserialize<'de> for Blk
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Blk
impl StructuralEq for Blk
impl StructuralPartialEq for Blk
Auto Trait Implementations§
impl RefUnwindSafe for Blk
impl Send for Blk
impl Sync for Blk
impl Unpin for Blk
impl UnwindSafe for Blk
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.