Add a runtime flag to enable/disable claims en masse
Now, if the environment variable CHECK_CLAIMS is set, then all claims turn into checks. Otherwise, claims are no-ops.
This commit is contained in:
@@ -6061,12 +6061,23 @@ fn trans_expr_out(&@block_ctxt cx, &@ast::expr e, out_method output) ->
|
|||||||
ret trans_check_expr(cx, a, "Predicate");
|
ret trans_check_expr(cx, a, "Predicate");
|
||||||
}
|
}
|
||||||
case (ast::expr_check(ast::unchecked, ?a)) {
|
case (ast::expr_check(ast::unchecked, ?a)) {
|
||||||
if (cx.fcx.lcx.ccx.sess.get_opts().check_claims) {
|
/* Claims are turned on and off by a global variable
|
||||||
ret trans_check_expr(cx, a, "Claim");
|
that the RTS sets. This case generates code to
|
||||||
}
|
check the value of that variable, doing nothing
|
||||||
else {
|
if it's set to false and acting like a check
|
||||||
ret rslt(cx, C_nil());
|
otherwise. */
|
||||||
}
|
auto c = get_extern_const(cx.fcx.lcx.ccx.externs,
|
||||||
|
cx.fcx.lcx.ccx.llmod,
|
||||||
|
"check_claims", T_bool());
|
||||||
|
auto cond = cx.build.Load(c);
|
||||||
|
|
||||||
|
auto then_cx = new_scope_block_ctxt(cx, "claim_then");
|
||||||
|
auto check_res = trans_check_expr(then_cx, a, "Claim");
|
||||||
|
auto else_cx = new_scope_block_ctxt(cx, "else");
|
||||||
|
auto els = rslt(else_cx, C_nil());
|
||||||
|
|
||||||
|
cx.build.CondBr(cond, then_cx.llbb, else_cx.llbb);
|
||||||
|
ret rslt(join_branches(cx, [check_res, els]), C_nil());
|
||||||
}
|
}
|
||||||
case (ast::expr_break) { ret trans_break(e.span, cx); }
|
case (ast::expr_break) { ret trans_break(e.span, cx); }
|
||||||
case (ast::expr_cont) { ret trans_cont(e.span, cx); }
|
case (ast::expr_cont) { ret trans_cont(e.span, cx); }
|
||||||
|
|||||||
@@ -91,10 +91,16 @@ int get_num_threads()
|
|||||||
* initialize the kernel, create the root domain and run it.
|
* initialize the kernel, create the root domain and run it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
int check_claims = 0;
|
||||||
|
|
||||||
|
void enable_claims(void* ck) { check_claims = (ck != 0); }
|
||||||
|
|
||||||
extern "C" CDECL int
|
extern "C" CDECL int
|
||||||
rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
|
rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
|
||||||
|
|
||||||
update_log_settings(crate_map, getenv("RUST_LOG"));
|
update_log_settings(crate_map, getenv("RUST_LOG"));
|
||||||
|
enable_claims(getenv("CHECK_CLAIMS"));
|
||||||
|
|
||||||
rust_srv *srv = new rust_srv();
|
rust_srv *srv = new rust_srv();
|
||||||
rust_kernel *kernel = new rust_kernel(srv);
|
rust_kernel *kernel = new rust_kernel(srv);
|
||||||
kernel->start();
|
kernel->start();
|
||||||
|
|||||||
@@ -20,6 +20,10 @@
|
|||||||
#define FASTCALL
|
#define FASTCALL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Controls whether claims are turned into checks */
|
||||||
|
/* Variable name must be kept consistent with trans.rs */
|
||||||
|
extern "C" int check_claims;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Local Variables:
|
* Local Variables:
|
||||||
* fill-column: 78;
|
* fill-column: 78;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
align_of
|
align_of
|
||||||
|
check_claims
|
||||||
debug_box
|
debug_box
|
||||||
debug_fn
|
debug_fn
|
||||||
debug_obj
|
debug_obj
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// xfail-stage0
|
// xfail-stage0
|
||||||
|
// xfail-stage1
|
||||||
// error-pattern:quux
|
// error-pattern:quux
|
||||||
use std;
|
use std;
|
||||||
import std::str::*;
|
import std::str::*;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// xfail-stage0
|
// xfail-stage0
|
||||||
|
// xfail-stage1
|
||||||
// tests that the pred in a claim isn't actually eval'd
|
// tests that the pred in a claim isn't actually eval'd
|
||||||
use std;
|
use std;
|
||||||
import std::str::*;
|
import std::str::*;
|
||||||
|
|||||||
Reference in New Issue
Block a user