about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBjörn Steinbrink <bsteinbr@gmail.com>2013-07-25 10:51:45 +0200
committerBjörn Steinbrink <bsteinbr@gmail.com>2013-07-25 12:06:57 +0200
commit75a08622e8754dbc43ccd2f08031227527645d39 (patch)
tree6a7fca7c9d441ea8b604f7e84d281f5d9adafcb2
parentba9c3ebc02716252cf46944e4dd3a866cc51947c (diff)
downloadrust-75a08622e8754dbc43ccd2f08031227527645d39.tar.gz
rust-75a08622e8754dbc43ccd2f08031227527645d39.zip
Add a function to check whether a ValueRef is a constant
-rw-r--r--src/librustc/middle/trans/common.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs
index 713939a5d83..4099f642637 100644
--- a/src/librustc/middle/trans/common.rs
+++ b/src/librustc/middle/trans/common.rs
@@ -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)