Skip to content
Snippets Groups Projects
Commit 28b88b09 authored by Per Lindgren's avatar Per Lindgren
Browse files

klee_assert! as macro

allows multiple assert fails to be reported by klee
parent 21cd2966
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ extern crate cstr_core; ...@@ -7,7 +7,7 @@ extern crate cstr_core;
extern crate cty; extern crate cty;
// mod lang_items; // mod lang_items;
mod ll; pub mod ll;
use core::mem; use core::mem;
...@@ -42,7 +42,7 @@ pub fn k_mk_symbol<T>(t: &mut T, name: &CStr) { ...@@ -42,7 +42,7 @@ pub fn k_mk_symbol<T>(t: &mut T, name: &CStr) {
} }
} }
#[inline(never)] #[inline(always)]
pub fn k_abort() -> ! { pub fn k_abort() -> ! {
unsafe { unsafe {
ll::abort(); ll::abort();
...@@ -50,7 +50,7 @@ pub fn k_abort() -> ! { ...@@ -50,7 +50,7 @@ pub fn k_abort() -> ! {
} }
/// assume a condition involving symbolic variables /// assume a condition involving symbolic variables
#[inline(never)] #[inline(always)]
pub fn k_assume(cond: bool) { pub fn k_assume(cond: bool) {
unsafe { unsafe {
ll::klee_assume(cond); ll::klee_assume(cond);
...@@ -58,10 +58,12 @@ pub fn k_assume(cond: bool) { ...@@ -58,10 +58,12 @@ pub fn k_assume(cond: bool) {
} }
/// assert a condition involving symbolic variables /// assert a condition involving symbolic variables
#[inline(never)] #[inline(always)]
pub fn k_assert(e: bool) { pub fn k_assert(e: bool) {
if !e { if !e {
k_abort(); unsafe {
ll::abort();
}
} }
} }
...@@ -80,6 +82,21 @@ macro_rules! k_symbol { ...@@ -80,6 +82,21 @@ macro_rules! k_symbol {
} }
} }
/// assertion
#[macro_export]
macro_rules! k_assert {
($e: expr) => {
{
use klee::ll;
if !$e {
unsafe {
ll::abort();
}
}
}
}
}
#[macro_export] #[macro_export]
macro_rules! k_visit { macro_rules! k_visit {
()=> { ()=> {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment