Skip to content

Commit 75a0862

Browse files
committed
Add a function to check whether a ValueRef is a constant
1 parent ba9c3eb commit 75a0862

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/librustc/middle/trans/common.rs

+6
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,12 @@ pub fn const_get_elt(cx: &CrateContext, v: ValueRef, us: &[c_uint])
850850
}
851851
}
852852

853+
pub fn is_const(v: ValueRef) -> bool {
854+
unsafe {
855+
llvm::LLVMIsConstant(v) == True
856+
}
857+
}
858+
853859
pub fn const_to_int(v: ValueRef) -> c_longlong {
854860
unsafe {
855861
llvm::LLVMConstIntGetSExtValue(v)

0 commit comments

Comments
 (0)