]> git.lizzy.rs Git - rust.git/commitdiff
save-analsysis: add save-analysis-api CLI flag
authorNick Cameron <ncameron@mozilla.com>
Mon, 29 Aug 2016 00:24:55 +0000 (12:24 +1200)
committerNick Cameron <ncameron@mozilla.com>
Thu, 1 Sep 2016 02:55:27 +0000 (14:55 +1200)
src/librustc/session/config.rs
src/librustc_driver/lib.rs
src/librustc_save_analysis/lib.rs

index 562dce6a1b129d9403f7552b24a9c9b08718725b..8eb80472d6e09fc93ee4e15aa5a9fdf0a276f49c 100644 (file)
@@ -848,9 +848,13 @@ fn parse_panic_strategy(slot: &mut PanicStrategy, v: Option<&str>) -> bool {
     ls: bool = (false, parse_bool, [UNTRACKED],
         "list the symbols defined by a library crate"),
     save_analysis: bool = (false, parse_bool, [UNTRACKED],
-        "write syntax and type analysis (in JSON format) information in addition to normal output"),
+        "write syntax and type analysis (in JSON format) information, \
+         addition to normal output"),
     save_analysis_csv: bool = (false, parse_bool, [UNTRACKED],
-        "write syntax and type analysis (in CSV format) information in addition to normal output"),
+        "write syntax and type analysis (in CSV format) information, in addition to normal output"),
+    save_analysis_api: bool = (false, parse_bool, [UNTRACKED],
+        "write syntax and type analysis information for opaque libraries (in JSON format), \
+         in addition to normal output"),
     print_move_fragments: bool = (false, parse_bool, [UNTRACKED],
         "print out move-fragment data for every fn"),
     flowgraph_print_loans: bool = (false, parse_bool, [UNTRACKED],
@@ -2359,6 +2363,8 @@ fn test_debugging_options_tracking_hash() {
         assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
         opts.debugging_opts.save_analysis_csv = true;
         assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
+        opts.debugging_opts.save_analysis_api = true;
+        assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
         opts.debugging_opts.print_move_fragments = true;
         assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
         opts.debugging_opts.flowgraph_print_loans = true;
index efadf1ff488dfbee24919b4a0504c3246129d893..95f8aa620a91a55b0227f1dd0be15d90c41e311e 100644 (file)
@@ -555,7 +555,8 @@ fn build_controller(&mut self,
 
 fn save_analysis(sess: &Session) -> bool {
     sess.opts.debugging_opts.save_analysis ||
-    sess.opts.debugging_opts.save_analysis_csv
+    sess.opts.debugging_opts.save_analysis_csv ||
+    sess.opts.debugging_opts.save_analysis_api
 }
 
 fn save_analysis_format(sess: &Session) -> save::Format {
@@ -563,6 +564,8 @@ fn save_analysis_format(sess: &Session) -> save::Format {
         save::Format::Json
     } else if sess.opts.debugging_opts.save_analysis_csv {
         save::Format::Csv
+    } else if sess.opts.debugging_opts.save_analysis_api {
+        save::Format::JsonApi
     } else {
         unreachable!();
     }
index db535e22f194d1a9bd5e23401d2f8918cacbc3e9..77273bd3f2ed27f9a02049c425079a5c4761b7a2 100644 (file)
@@ -727,13 +727,14 @@ fn visit_pat(&mut self, p: &ast::Pat) {
 pub enum Format {
     Csv,
     Json,
+    JsonApi,
 }
 
 impl Format {
     fn extension(&self) -> &'static str {
         match *self {
             Format::Csv => ".csv",
-            Format::Json => ".json",
+            Format::Json | Format::JsonApi => ".json",
         }
     }
 }
@@ -803,6 +804,7 @@ macro_rules! dump {
     match format {
         Format::Csv => dump!(CsvDumper::new(output)),
         Format::Json => dump!(JsonDumper::new(output)),
+        Format::JsonApi => /* TODO */ dump!(JsonDumper::new(output)),
     }
 }