Auto merge of #29171 - nrc:servo-dxr, r=@arielb1
This commit is contained in:
commit
4826f9625b
@ -102,12 +102,12 @@ pub const INITIAL_DISCRIMINANT_VALUE: Disr = 0;
|
|||||||
|
|
||||||
/// The complete set of all analyses described in this module. This is
|
/// The complete set of all analyses described in this module. This is
|
||||||
/// produced by the driver and fed to trans and later passes.
|
/// produced by the driver and fed to trans and later passes.
|
||||||
pub struct CrateAnalysis {
|
pub struct CrateAnalysis<'a> {
|
||||||
pub export_map: ExportMap,
|
pub export_map: ExportMap,
|
||||||
pub exported_items: middle::privacy::ExportedItems,
|
pub exported_items: middle::privacy::ExportedItems,
|
||||||
pub public_items: middle::privacy::PublicItems,
|
pub public_items: middle::privacy::PublicItems,
|
||||||
pub reachable: NodeSet,
|
pub reachable: NodeSet,
|
||||||
pub name: String,
|
pub name: &'a str,
|
||||||
pub glob_map: Option<GlobMap>,
|
pub glob_map: Option<GlobMap>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ pub fn compile_input(sess: Session,
|
|||||||
phase_3_run_analysis_passes(&sess,
|
phase_3_run_analysis_passes(&sess,
|
||||||
ast_map,
|
ast_map,
|
||||||
&arenas,
|
&arenas,
|
||||||
id,
|
&id,
|
||||||
control.make_glob_map,
|
control.make_glob_map,
|
||||||
|tcx, analysis| {
|
|tcx, analysis| {
|
||||||
|
|
||||||
@ -155,7 +155,8 @@ pub fn compile_input(sess: Session,
|
|||||||
tcx.map.krate(),
|
tcx.map.krate(),
|
||||||
&analysis,
|
&analysis,
|
||||||
tcx,
|
tcx,
|
||||||
&lcx);
|
&lcx,
|
||||||
|
&id);
|
||||||
(control.after_analysis.callback)(state);
|
(control.after_analysis.callback)(state);
|
||||||
|
|
||||||
tcx.sess.abort_if_errors();
|
tcx.sess.abort_if_errors();
|
||||||
@ -279,7 +280,7 @@ pub struct CompileState<'a, 'ast: 'a, 'tcx: 'a> {
|
|||||||
pub expanded_crate: Option<&'a ast::Crate>,
|
pub expanded_crate: Option<&'a ast::Crate>,
|
||||||
pub hir_crate: Option<&'a hir::Crate>,
|
pub hir_crate: Option<&'a hir::Crate>,
|
||||||
pub ast_map: Option<&'a hir_map::Map<'ast>>,
|
pub ast_map: Option<&'a hir_map::Map<'ast>>,
|
||||||
pub analysis: Option<&'a ty::CrateAnalysis>,
|
pub analysis: Option<&'a ty::CrateAnalysis<'a>>,
|
||||||
pub tcx: Option<&'a ty::ctxt<'tcx>>,
|
pub tcx: Option<&'a ty::ctxt<'tcx>>,
|
||||||
pub lcx: Option<&'a LoweringContext<'a>>,
|
pub lcx: Option<&'a LoweringContext<'a>>,
|
||||||
pub trans: Option<&'a trans::CrateTranslation>,
|
pub trans: Option<&'a trans::CrateTranslation>,
|
||||||
@ -358,7 +359,8 @@ impl<'a, 'ast, 'tcx> CompileState<'a, 'ast, 'tcx> {
|
|||||||
hir_crate: &'a hir::Crate,
|
hir_crate: &'a hir::Crate,
|
||||||
analysis: &'a ty::CrateAnalysis,
|
analysis: &'a ty::CrateAnalysis,
|
||||||
tcx: &'a ty::ctxt<'tcx>,
|
tcx: &'a ty::ctxt<'tcx>,
|
||||||
lcx: &'a LoweringContext<'a>)
|
lcx: &'a LoweringContext<'a>,
|
||||||
|
crate_name: &'a str)
|
||||||
-> CompileState<'a, 'ast, 'tcx> {
|
-> CompileState<'a, 'ast, 'tcx> {
|
||||||
CompileState {
|
CompileState {
|
||||||
analysis: Some(analysis),
|
analysis: Some(analysis),
|
||||||
@ -366,6 +368,7 @@ impl<'a, 'ast, 'tcx> CompileState<'a, 'ast, 'tcx> {
|
|||||||
krate: Some(krate),
|
krate: Some(krate),
|
||||||
hir_crate: Some(hir_crate),
|
hir_crate: Some(hir_crate),
|
||||||
lcx: Some(lcx),
|
lcx: Some(lcx),
|
||||||
|
crate_name: Some(crate_name),
|
||||||
.. CompileState::empty(input, session, out_dir)
|
.. CompileState::empty(input, session, out_dir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -661,7 +664,7 @@ pub fn make_map<'ast>(sess: &Session,
|
|||||||
pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
|
pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
|
||||||
ast_map: front::map::Map<'tcx>,
|
ast_map: front::map::Map<'tcx>,
|
||||||
arenas: &'tcx ty::CtxtArenas<'tcx>,
|
arenas: &'tcx ty::CtxtArenas<'tcx>,
|
||||||
name: String,
|
name: &str,
|
||||||
make_glob_map: resolve::MakeGlobMap,
|
make_glob_map: resolve::MakeGlobMap,
|
||||||
f: F)
|
f: F)
|
||||||
-> R
|
-> R
|
||||||
|
@ -399,6 +399,7 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
|
|||||||
state.lcx.unwrap(),
|
state.lcx.unwrap(),
|
||||||
state.krate.unwrap(),
|
state.krate.unwrap(),
|
||||||
state.analysis.unwrap(),
|
state.analysis.unwrap(),
|
||||||
|
state.crate_name.unwrap(),
|
||||||
state.out_dir));
|
state.out_dir));
|
||||||
};
|
};
|
||||||
control.make_glob_map = resolve::MakeGlobMap::Yes;
|
control.make_glob_map = resolve::MakeGlobMap::Yes;
|
||||||
|
@ -158,7 +158,7 @@ impl PpSourceMode {
|
|||||||
sess: &'tcx Session,
|
sess: &'tcx Session,
|
||||||
ast_map: &hir_map::Map<'tcx>,
|
ast_map: &hir_map::Map<'tcx>,
|
||||||
arenas: &'tcx ty::CtxtArenas<'tcx>,
|
arenas: &'tcx ty::CtxtArenas<'tcx>,
|
||||||
id: String,
|
id: &str,
|
||||||
payload: B,
|
payload: B,
|
||||||
f: F) -> A where
|
f: F) -> A where
|
||||||
F: FnOnce(&HirPrinterSupport, B, &hir::Crate) -> A,
|
F: FnOnce(&HirPrinterSupport, B, &hir::Crate) -> A,
|
||||||
@ -713,7 +713,7 @@ pub fn pretty_print_input(sess: Session,
|
|||||||
(PpmHir(s), None) => {
|
(PpmHir(s), None) => {
|
||||||
let out: &mut Write = &mut out;
|
let out: &mut Write = &mut out;
|
||||||
s.call_with_pp_support_hir(
|
s.call_with_pp_support_hir(
|
||||||
&sess, &ast_map.unwrap(), &arenas, id, box out, |annotation, out, krate| {
|
&sess, &ast_map.unwrap(), &arenas, &id, box out, |annotation, out, krate| {
|
||||||
debug!("pretty printing source code {:?}", s);
|
debug!("pretty printing source code {:?}", s);
|
||||||
let sess = annotation.sess();
|
let sess = annotation.sess();
|
||||||
pprust_hir::print_crate(sess.codemap(),
|
pprust_hir::print_crate(sess.codemap(),
|
||||||
@ -732,7 +732,7 @@ pub fn pretty_print_input(sess: Session,
|
|||||||
s.call_with_pp_support_hir(&sess,
|
s.call_with_pp_support_hir(&sess,
|
||||||
&ast_map.unwrap(),
|
&ast_map.unwrap(),
|
||||||
&arenas,
|
&arenas,
|
||||||
id,
|
&id,
|
||||||
(out,uii),
|
(out,uii),
|
||||||
|annotation, (out,uii), _| {
|
|annotation, (out,uii), _| {
|
||||||
debug!("pretty printing source code {:?}", s);
|
debug!("pretty printing source code {:?}", s);
|
||||||
@ -780,7 +780,7 @@ pub fn pretty_print_input(sess: Session,
|
|||||||
driver::phase_3_run_analysis_passes(&sess,
|
driver::phase_3_run_analysis_passes(&sess,
|
||||||
ast_map,
|
ast_map,
|
||||||
&arenas,
|
&arenas,
|
||||||
id,
|
&id,
|
||||||
resolve::MakeGlobMap::No,
|
resolve::MakeGlobMap::No,
|
||||||
|tcx, _| {
|
|tcx, _| {
|
||||||
print_flowgraph(variants, tcx, code, mode, out)
|
print_flowgraph(variants, tcx, code, mode, out)
|
||||||
|
@ -184,9 +184,9 @@ pub fn find_crate_name(sess: Option<&Session>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_link_meta(sess: &Session, krate: &hir::Crate,
|
pub fn build_link_meta(sess: &Session, krate: &hir::Crate,
|
||||||
name: String) -> LinkMeta {
|
name: &str) -> LinkMeta {
|
||||||
let r = LinkMeta {
|
let r = LinkMeta {
|
||||||
crate_name: name,
|
crate_name: name.to_owned(),
|
||||||
crate_hash: Svh::calculate(&sess.opts.cg.metadata, krate),
|
crate_hash: Svh::calculate(&sess.opts.cg.metadata, krate),
|
||||||
};
|
};
|
||||||
info!("{:?}", r);
|
info!("{:?}", r);
|
||||||
|
@ -66,7 +66,7 @@ pub struct DumpCsvVisitor<'l, 'tcx: 'l> {
|
|||||||
save_ctxt: SaveContext<'l, 'tcx>,
|
save_ctxt: SaveContext<'l, 'tcx>,
|
||||||
sess: &'l Session,
|
sess: &'l Session,
|
||||||
tcx: &'l ty::ctxt<'tcx>,
|
tcx: &'l ty::ctxt<'tcx>,
|
||||||
analysis: &'l ty::CrateAnalysis,
|
analysis: &'l ty::CrateAnalysis<'l>,
|
||||||
|
|
||||||
span: SpanUtils<'l>,
|
span: SpanUtils<'l>,
|
||||||
fmt: FmtStrs<'l, 'tcx>,
|
fmt: FmtStrs<'l, 'tcx>,
|
||||||
@ -77,7 +77,7 @@ pub struct DumpCsvVisitor<'l, 'tcx: 'l> {
|
|||||||
impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
|
impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
|
||||||
pub fn new(tcx: &'l ty::ctxt<'tcx>,
|
pub fn new(tcx: &'l ty::ctxt<'tcx>,
|
||||||
lcx: &'l LoweringContext<'l>,
|
lcx: &'l LoweringContext<'l>,
|
||||||
analysis: &'l ty::CrateAnalysis,
|
analysis: &'l ty::CrateAnalysis<'l>,
|
||||||
output_file: Box<File>)
|
output_file: Box<File>)
|
||||||
-> DumpCsvVisitor<'l, 'tcx> {
|
-> DumpCsvVisitor<'l, 'tcx> {
|
||||||
let span_utils = SpanUtils::new(&tcx.sess);
|
let span_utils = SpanUtils::new(&tcx.sess);
|
||||||
|
@ -20,7 +20,6 @@ use rustc_front;
|
|||||||
use rustc::front::map::NodeItem;
|
use rustc::front::map::NodeItem;
|
||||||
use rustc_front::{hir, lowering};
|
use rustc_front::{hir, lowering};
|
||||||
|
|
||||||
use syntax::attr;
|
|
||||||
use syntax::ast::{self, NodeId};
|
use syntax::ast::{self, NodeId};
|
||||||
use syntax::ast_util;
|
use syntax::ast_util;
|
||||||
use syntax::codemap::*;
|
use syntax::codemap::*;
|
||||||
@ -714,19 +713,13 @@ pub fn process_crate<'l, 'tcx>(tcx: &'l ty::ctxt<'tcx>,
|
|||||||
lcx: &'l lowering::LoweringContext<'l>,
|
lcx: &'l lowering::LoweringContext<'l>,
|
||||||
krate: &ast::Crate,
|
krate: &ast::Crate,
|
||||||
analysis: &ty::CrateAnalysis,
|
analysis: &ty::CrateAnalysis,
|
||||||
|
cratename: &str,
|
||||||
odir: Option<&Path>) {
|
odir: Option<&Path>) {
|
||||||
if generated_code(krate.span) {
|
if generated_code(krate.span) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert!(analysis.glob_map.is_some());
|
assert!(analysis.glob_map.is_some());
|
||||||
let cratename = match attr::find_crate_name(&krate.attrs) {
|
|
||||||
Some(name) => name.to_string(),
|
|
||||||
None => {
|
|
||||||
info!("Could not find crate name, using 'unknown_crate'");
|
|
||||||
String::from("unknown_crate")
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
info!("Dumping crate {}", cratename);
|
info!("Dumping crate {}", cratename);
|
||||||
|
|
||||||
@ -751,7 +744,7 @@ pub fn process_crate<'l, 'tcx>(tcx: &'l ty::ctxt<'tcx>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create output file.
|
// Create output file.
|
||||||
let mut out_name = cratename.clone();
|
let mut out_name = cratename.to_owned();
|
||||||
out_name.push_str(".csv");
|
out_name.push_str(".csv");
|
||||||
root_path.push(&out_name);
|
root_path.push(&out_name);
|
||||||
let output_file = match File::create(&root_path) {
|
let output_file = match File::create(&root_path) {
|
||||||
@ -765,7 +758,7 @@ pub fn process_crate<'l, 'tcx>(tcx: &'l ty::ctxt<'tcx>,
|
|||||||
|
|
||||||
let mut visitor = dump_csv::DumpCsvVisitor::new(tcx, lcx, analysis, output_file);
|
let mut visitor = dump_csv::DumpCsvVisitor::new(tcx, lcx, analysis, output_file);
|
||||||
|
|
||||||
visitor.dump_crate_info(&cratename, krate);
|
visitor.dump_crate_info(cratename, krate);
|
||||||
visit::walk_crate(&mut visitor, krate);
|
visit::walk_crate(&mut visitor, krate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ pub fn run_core(search_paths: SearchPaths, cfgs: Vec<String>, externs: Externs,
|
|||||||
driver::phase_3_run_analysis_passes(&sess,
|
driver::phase_3_run_analysis_passes(&sess,
|
||||||
hir_map,
|
hir_map,
|
||||||
&arenas,
|
&arenas,
|
||||||
name,
|
&name,
|
||||||
resolve::MakeGlobMap::No,
|
resolve::MakeGlobMap::No,
|
||||||
|tcx, analysis| {
|
|tcx, analysis| {
|
||||||
let ty::CrateAnalysis { exported_items, public_items, .. } = analysis;
|
let ty::CrateAnalysis { exported_items, public_items, .. } = analysis;
|
||||||
|
@ -229,7 +229,7 @@ fn compile_program(input: &str, sysroot: PathBuf)
|
|||||||
let ast_map = driver::make_map(&sess, &mut hir_forest);
|
let ast_map = driver::make_map(&sess, &mut hir_forest);
|
||||||
|
|
||||||
driver::phase_3_run_analysis_passes(
|
driver::phase_3_run_analysis_passes(
|
||||||
&sess, ast_map, &arenas, id, MakeGlobMap::No, |tcx, analysis| {
|
&sess, ast_map, &arenas, &id, MakeGlobMap::No, |tcx, analysis| {
|
||||||
|
|
||||||
let trans = driver::phase_4_translate_to_llvm(tcx, analysis);
|
let trans = driver::phase_4_translate_to_llvm(tcx, analysis);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user