]> git.lizzy.rs Git - rust.git/commitdiff
Add a --no-analysis command line switch
authorSiegeLord <slabode@aim.com>
Thu, 26 Dec 2013 22:39:36 +0000 (17:39 -0500)
committerSiegeLord <slabode@aim.com>
Tue, 31 Dec 2013 20:28:08 +0000 (15:28 -0500)
src/librustc/driver/driver.rs
src/librustc/driver/session.rs

index c4f2b409247bb79a112d00e18ef53f713c10b0c4..b0fa22f817288f7612b057ab1d08f09ce2db043e 100644 (file)
@@ -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>", "FILENAME"),
   optopt("", "opt-level",
index e3167dee0680986b634d974eca7f6968cfbd6fdf..63ccc91cd556d7d1222aa17134e5c2964444c4a0 100644 (file)
@@ -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),