Auto merge of #29171 - nrc:servo-dxr, r=@arielb1

This commit is contained in:
bors 2015-10-21 00:55:49 +00:00
commit 4826f9625b
9 changed files with 24 additions and 27 deletions

View File

@ -102,12 +102,12 @@ pub const INITIAL_DISCRIMINANT_VALUE: Disr = 0;
/// The complete set of all analyses described in this module. This is
/// produced by the driver and fed to trans and later passes.
pub struct CrateAnalysis {
pub struct CrateAnalysis<'a> {
pub export_map: ExportMap,
pub exported_items: middle::privacy::ExportedItems,
pub public_items: middle::privacy::PublicItems,
pub reachable: NodeSet,
pub name: String,
pub name: &'a str,
pub glob_map: Option<GlobMap>,
}

View File

@ -143,7 +143,7 @@ pub fn compile_input(sess: Session,
phase_3_run_analysis_passes(&sess,
ast_map,
&arenas,
id,
&id,
control.make_glob_map,
|tcx, analysis| {
@ -155,7 +155,8 @@ pub fn compile_input(sess: Session,
tcx.map.krate(),
&analysis,
tcx,
&lcx);
&lcx,
&id);
(control.after_analysis.callback)(state);
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 hir_crate: Option<&'a hir::Crate>,
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 lcx: Option<&'a LoweringContext<'a>>,
pub trans: Option<&'a trans::CrateTranslation>,
@ -358,7 +359,8 @@ impl<'a, 'ast, 'tcx> CompileState<'a, 'ast, 'tcx> {
hir_crate: &'a hir::Crate,
analysis: &'a ty::CrateAnalysis,
tcx: &'a ty::ctxt<'tcx>,
lcx: &'a LoweringContext<'a>)
lcx: &'a LoweringContext<'a>,
crate_name: &'a str)
-> CompileState<'a, 'ast, 'tcx> {
CompileState {
analysis: Some(analysis),
@ -366,6 +368,7 @@ impl<'a, 'ast, 'tcx> CompileState<'a, 'ast, 'tcx> {
krate: Some(krate),
hir_crate: Some(hir_crate),
lcx: Some(lcx),
crate_name: Some(crate_name),
.. 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,
ast_map: front::map::Map<'tcx>,
arenas: &'tcx ty::CtxtArenas<'tcx>,
name: String,
name: &str,
make_glob_map: resolve::MakeGlobMap,
f: F)
-> R

View File

@ -399,6 +399,7 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
state.lcx.unwrap(),
state.krate.unwrap(),
state.analysis.unwrap(),
state.crate_name.unwrap(),
state.out_dir));
};
control.make_glob_map = resolve::MakeGlobMap::Yes;

View File

@ -158,7 +158,7 @@ impl PpSourceMode {
sess: &'tcx Session,
ast_map: &hir_map::Map<'tcx>,
arenas: &'tcx ty::CtxtArenas<'tcx>,
id: String,
id: &str,
payload: B,
f: F) -> A where
F: FnOnce(&HirPrinterSupport, B, &hir::Crate) -> A,
@ -713,7 +713,7 @@ pub fn pretty_print_input(sess: Session,
(PpmHir(s), None) => {
let out: &mut Write = &mut out;
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);
let sess = annotation.sess();
pprust_hir::print_crate(sess.codemap(),
@ -732,7 +732,7 @@ pub fn pretty_print_input(sess: Session,
s.call_with_pp_support_hir(&sess,
&ast_map.unwrap(),
&arenas,
id,
&id,
(out,uii),
|annotation, (out,uii), _| {
debug!("pretty printing source code {:?}", s);
@ -780,7 +780,7 @@ pub fn pretty_print_input(sess: Session,
driver::phase_3_run_analysis_passes(&sess,
ast_map,
&arenas,
id,
&id,
resolve::MakeGlobMap::No,
|tcx, _| {
print_flowgraph(variants, tcx, code, mode, out)

View File

@ -184,9 +184,9 @@ pub fn find_crate_name(sess: Option<&Session>,
}
pub fn build_link_meta(sess: &Session, krate: &hir::Crate,
name: String) -> LinkMeta {
name: &str) -> LinkMeta {
let r = LinkMeta {
crate_name: name,
crate_name: name.to_owned(),
crate_hash: Svh::calculate(&sess.opts.cg.metadata, krate),
};
info!("{:?}", r);

View File

@ -66,7 +66,7 @@ pub struct DumpCsvVisitor<'l, 'tcx: 'l> {
save_ctxt: SaveContext<'l, 'tcx>,
sess: &'l Session,
tcx: &'l ty::ctxt<'tcx>,
analysis: &'l ty::CrateAnalysis,
analysis: &'l ty::CrateAnalysis<'l>,
span: SpanUtils<'l>,
fmt: FmtStrs<'l, 'tcx>,
@ -77,7 +77,7 @@ pub struct DumpCsvVisitor<'l, 'tcx: 'l> {
impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
pub fn new(tcx: &'l ty::ctxt<'tcx>,
lcx: &'l LoweringContext<'l>,
analysis: &'l ty::CrateAnalysis,
analysis: &'l ty::CrateAnalysis<'l>,
output_file: Box<File>)
-> DumpCsvVisitor<'l, 'tcx> {
let span_utils = SpanUtils::new(&tcx.sess);

View File

@ -20,7 +20,6 @@ use rustc_front;
use rustc::front::map::NodeItem;
use rustc_front::{hir, lowering};
use syntax::attr;
use syntax::ast::{self, NodeId};
use syntax::ast_util;
use syntax::codemap::*;
@ -714,19 +713,13 @@ pub fn process_crate<'l, 'tcx>(tcx: &'l ty::ctxt<'tcx>,
lcx: &'l lowering::LoweringContext<'l>,
krate: &ast::Crate,
analysis: &ty::CrateAnalysis,
cratename: &str,
odir: Option<&Path>) {
if generated_code(krate.span) {
return;
}
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);
@ -751,7 +744,7 @@ pub fn process_crate<'l, 'tcx>(tcx: &'l ty::ctxt<'tcx>,
}
// Create output file.
let mut out_name = cratename.clone();
let mut out_name = cratename.to_owned();
out_name.push_str(".csv");
root_path.push(&out_name);
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);
visitor.dump_crate_info(&cratename, krate);
visitor.dump_crate_info(cratename, krate);
visit::walk_crate(&mut visitor, krate);
}

View File

@ -143,7 +143,7 @@ pub fn run_core(search_paths: SearchPaths, cfgs: Vec<String>, externs: Externs,
driver::phase_3_run_analysis_passes(&sess,
hir_map,
&arenas,
name,
&name,
resolve::MakeGlobMap::No,
|tcx, analysis| {
let ty::CrateAnalysis { exported_items, public_items, .. } = analysis;

View File

@ -229,7 +229,7 @@ fn compile_program(input: &str, sysroot: PathBuf)
let ast_map = driver::make_map(&sess, &mut hir_forest);
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);