Skip to content

Commit

Permalink
Add a function to check whether a ValueRef is a constant
Browse files Browse the repository at this point in the history
  • Loading branch information
dotdash committed Jul 25, 2013
1 parent ba9c3eb commit 75a0862
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/librustc/middle/trans/common.rs
Expand Up @@ -850,6 +850,12 @@ pub fn const_get_elt(cx: &CrateContext, v: ValueRef, us: &[c_uint])
}
}

pub fn is_const(v: ValueRef) -> bool {
unsafe {
llvm::LLVMIsConstant(v) == True
}
}

pub fn const_to_int(v: ValueRef) -> c_longlong {
unsafe {
llvm::LLVMConstIntGetSExtValue(v)
Expand Down

0 comments on commit 75a0862

Please sign in to comment.