From cbe8c61fed3ccff0a34a9ff79105ad5b7a7de5b3 Mon Sep 17 00:00:00 2001 From: SiegeLord Date: Thu, 26 Dec 2013 17:39:36 -0500 Subject: [PATCH] Add a --no-analysis command line switch --- src/librustc/driver/driver.rs | 15 +++++++++++++++ src/librustc/driver/session.rs | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index c4f2b409247bb..b0fa22f817288 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -417,6 +417,14 @@ pub fn stop_after_phase_1(sess: Session) -> bool { return false; } +pub fn stop_after_phase_2(sess: Session) -> bool { + if sess.opts.no_analysis { + debug!("invoked with --no-analysis, returning early from compile_input"); + return true; + } + return false; +} + pub fn stop_after_phase_5(sess: Session) -> bool { if sess.opts.output_type != link::output_type_exe { debug!("not building executable, returning early from compile_input"); @@ -482,6 +490,8 @@ pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &input, write_out_deps(sess, input, outputs, &expanded_crate); + if stop_after_phase_2(sess) { return; } + let analysis = phase_3_run_analysis_passes(sess, &expanded_crate); if stop_after_phase_3(sess) { return; } let trans = phase_4_translate_to_llvm(sess, expanded_crate, @@ -697,6 +707,7 @@ pub fn build_session_options(binary: @str, let parse_only = matches.opt_present("parse-only"); let no_trans = matches.opt_present("no-trans"); + let no_analysis = matches.opt_present("no-analysis"); let lint_levels = [lint::allow, lint::warn, lint::deny, lint::forbid]; @@ -850,6 +861,7 @@ pub fn build_session_options(binary: @str, test: test, parse_only: parse_only, no_trans: no_trans, + no_analysis: no_analysis, debugging_opts: debugging_opts, android_cross_path: android_cross_path, write_dependency_info: write_dependency_info, @@ -943,6 +955,9 @@ pub fn optgroups() -> ~[getopts::groups::OptGroup] { optflag("", "ls", "List the symbols defined by a library crate"), optflag("", "no-trans", "Run all passes except translation; no output"), + optflag("", "no-analysis", + "Parse and expand the output, but run no analysis or produce \ + output"), optflag("O", "", "Equivalent to --opt-level=2"), optopt("o", "", "Write output to ", "FILENAME"), optopt("", "opt-level", diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index e3167dee06809..63ccc91cd556d 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -167,6 +167,7 @@ pub struct options { test: bool, parse_only: bool, no_trans: bool, + no_analysis: bool, debugging_opts: uint, android_cross_path: Option<~str>, /// Whether to write dependency files. It's (enabled, optional filename). @@ -398,6 +399,7 @@ pub fn basic_options() -> @options { test: false, parse_only: false, no_trans: false, + no_analysis: false, debugging_opts: 0u, android_cross_path: None, write_dependency_info: (false, None),