Skip to content

Commit cbe8c61

Browse files
committed
Add a --no-analysis command line switch
1 parent a7a9e48 commit cbe8c61

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/librustc/driver/driver.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,14 @@ pub fn stop_after_phase_1(sess: Session) -> bool {
417417
return false;
418418
}
419419

420+
pub fn stop_after_phase_2(sess: Session) -> bool {
421+
if sess.opts.no_analysis {
422+
debug!("invoked with --no-analysis, returning early from compile_input");
423+
return true;
424+
}
425+
return false;
426+
}
427+
420428
pub fn stop_after_phase_5(sess: Session) -> bool {
421429
if sess.opts.output_type != link::output_type_exe {
422430
debug!("not building executable, returning early from compile_input");
@@ -482,6 +490,8 @@ pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &input,
482490

483491
write_out_deps(sess, input, outputs, &expanded_crate);
484492

493+
if stop_after_phase_2(sess) { return; }
494+
485495
let analysis = phase_3_run_analysis_passes(sess, &expanded_crate);
486496
if stop_after_phase_3(sess) { return; }
487497
let trans = phase_4_translate_to_llvm(sess, expanded_crate,
@@ -697,6 +707,7 @@ pub fn build_session_options(binary: @str,
697707

698708
let parse_only = matches.opt_present("parse-only");
699709
let no_trans = matches.opt_present("no-trans");
710+
let no_analysis = matches.opt_present("no-analysis");
700711

701712
let lint_levels = [lint::allow, lint::warn,
702713
lint::deny, lint::forbid];
@@ -850,6 +861,7 @@ pub fn build_session_options(binary: @str,
850861
test: test,
851862
parse_only: parse_only,
852863
no_trans: no_trans,
864+
no_analysis: no_analysis,
853865
debugging_opts: debugging_opts,
854866
android_cross_path: android_cross_path,
855867
write_dependency_info: write_dependency_info,
@@ -943,6 +955,9 @@ pub fn optgroups() -> ~[getopts::groups::OptGroup] {
943955
optflag("", "ls", "List the symbols defined by a library crate"),
944956
optflag("", "no-trans",
945957
"Run all passes except translation; no output"),
958+
optflag("", "no-analysis",
959+
"Parse and expand the output, but run no analysis or produce \
960+
output"),
946961
optflag("O", "", "Equivalent to --opt-level=2"),
947962
optopt("o", "", "Write output to <filename>", "FILENAME"),
948963
optopt("", "opt-level",

src/librustc/driver/session.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ pub struct options {
167167
test: bool,
168168
parse_only: bool,
169169
no_trans: bool,
170+
no_analysis: bool,
170171
debugging_opts: uint,
171172
android_cross_path: Option<~str>,
172173
/// Whether to write dependency files. It's (enabled, optional filename).
@@ -398,6 +399,7 @@ pub fn basic_options() -> @options {
398399
test: false,
399400
parse_only: false,
400401
no_trans: false,
402+
no_analysis: false,
401403
debugging_opts: 0u,
402404
android_cross_path: None,
403405
write_dependency_info: (false, None),

0 commit comments

Comments
 (0)