about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2019-03-30 15:45:09 +0100
committerbjorn3 <bjorn3@users.noreply.github.com>2019-04-20 13:21:40 +0200
commitd4e7b083ceae25f15f1639cb432d466656aecd77 (patch)
treeac5726d882b1196c7ea01d6eeca0331ca643844b
parentdd4566f5118c20889ca778565ba14a065a368dc6 (diff)
downloadrust-d4e7b083ceae25f15f1639cb432d466656aecd77.tar.gz
rust-d4e7b083ceae25f15f1639cb432d466656aecd77.zip
Move cg_llvm/debuginfo/type_names.rs to cg_ssa
-rw-r--r--src/librustc_codegen_llvm/debuginfo/metadata.rs16
-rw-r--r--src/librustc_codegen_llvm/debuginfo/mod.rs5
-rw-r--r--src/librustc_codegen_ssa/debuginfo/mod.rs (renamed from src/librustc_codegen_ssa/debuginfo.rs)2
-rw-r--r--src/librustc_codegen_ssa/debuginfo/type_names.rs (renamed from src/librustc_codegen_llvm/debuginfo/type_names.rs)63
4 files changed, 41 insertions, 45 deletions
diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs
index 6560ed0a8e6..31348b99c5a 100644
--- a/src/librustc_codegen_llvm/debuginfo/metadata.rs
+++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs
@@ -376,7 +376,7 @@ fn vec_slice_metadata(
 
     return_if_metadata_created_in_meantime!(cx, unique_type_id);
 
-    let slice_type_name = compute_debuginfo_type_name(cx, slice_ptr_type, true);
+    let slice_type_name = compute_debuginfo_type_name(cx.tcx, slice_ptr_type, true);
 
     let (pointer_size, pointer_align) = cx.size_and_align_of(data_ptr_type);
     let (usize_size, usize_align) = cx.size_and_align_of(cx.tcx.types.usize);
@@ -479,7 +479,7 @@ fn trait_pointer_metadata(
 
     let trait_object_type = trait_object_type.unwrap_or(trait_type);
     let trait_type_name =
-        compute_debuginfo_type_name(cx, trait_object_type, false);
+        compute_debuginfo_type_name(cx.tcx, trait_object_type, false);
 
     let file_metadata = unknown_file_metadata(cx);
 
@@ -866,7 +866,7 @@ fn foreign_type_metadata(
 ) -> &'ll DIType {
     debug!("foreign_type_metadata: {:?}", t);
 
-    let name = compute_debuginfo_type_name(cx, t, false);
+    let name = compute_debuginfo_type_name(cx.tcx, t, false);
     create_struct_stub(cx, t, &name, unique_type_id, NO_SCOPE_METADATA)
 }
 
@@ -876,7 +876,7 @@ fn pointer_type_metadata(
     pointee_type_metadata: &'ll DIType,
 ) -> &'ll DIType {
     let (pointer_size, pointer_align) = cx.size_and_align_of(pointer_type);
-    let name = compute_debuginfo_type_name(cx, pointer_type, false);
+    let name = compute_debuginfo_type_name(cx.tcx, pointer_type, false);
     let name = SmallCStr::new(&name);
     unsafe {
         llvm::LLVMRustDIBuilderCreatePointerType(
@@ -1072,7 +1072,7 @@ fn prepare_struct_metadata(
     unique_type_id: UniqueTypeId,
     span: Span,
 ) -> RecursiveTypeDescription<'ll, 'tcx> {
-    let struct_name = compute_debuginfo_type_name(cx, struct_type, false);
+    let struct_name = compute_debuginfo_type_name(cx.tcx, struct_type, false);
 
     let (struct_def_id, variant) = match struct_type.sty {
         ty::Adt(def, _) => (def.did, def.non_enum_variant()),
@@ -1138,7 +1138,7 @@ fn prepare_tuple_metadata(
     unique_type_id: UniqueTypeId,
     span: Span,
 ) -> RecursiveTypeDescription<'ll, 'tcx> {
-    let tuple_name = compute_debuginfo_type_name(cx, tuple_type, false);
+    let tuple_name = compute_debuginfo_type_name(cx.tcx, tuple_type, false);
 
     let struct_stub = create_struct_stub(cx,
                                          tuple_type,
@@ -1194,7 +1194,7 @@ fn prepare_union_metadata(
     unique_type_id: UniqueTypeId,
     span: Span,
 ) -> RecursiveTypeDescription<'ll, 'tcx> {
-    let union_name = compute_debuginfo_type_name(cx, union_type, false);
+    let union_name = compute_debuginfo_type_name(cx.tcx, union_type, false);
 
     let (union_def_id, variant) = match union_type.sty {
         ty::Adt(def, _) => (def.did, def.non_enum_variant()),
@@ -1607,7 +1607,7 @@ fn prepare_enum_metadata(
     unique_type_id: UniqueTypeId,
     span: Span,
 ) -> RecursiveTypeDescription<'ll, 'tcx> {
-    let enum_name = compute_debuginfo_type_name(cx, enum_type, false);
+    let enum_name = compute_debuginfo_type_name(cx.tcx, enum_type, false);
 
     let containing_scope = get_namespace_for_item(cx, enum_def_id);
     // FIXME: This should emit actual file metadata for the enum, but we
diff --git a/src/librustc_codegen_llvm/debuginfo/mod.rs b/src/librustc_codegen_llvm/debuginfo/mod.rs
index 57e4ac07d5e..ae498673c1d 100644
--- a/src/librustc_codegen_llvm/debuginfo/mod.rs
+++ b/src/librustc_codegen_llvm/debuginfo/mod.rs
@@ -29,7 +29,7 @@ use rustc::util::nodemap::{DefIdMap, FxHashMap, FxHashSet};
 use rustc_data_structures::small_c_str::SmallCStr;
 use rustc_data_structures::indexed_vec::IndexVec;
 use rustc_codegen_ssa::debuginfo::{FunctionDebugContext, MirDebugScope, VariableAccess,
-    VariableKind, FunctionDebugContextData};
+    VariableKind, FunctionDebugContextData, type_names};
 
 use libc::c_uint;
 use std::cell::RefCell;
@@ -44,7 +44,6 @@ use rustc_codegen_ssa::traits::*;
 pub mod gdb;
 mod utils;
 mod namespace;
-mod type_names;
 pub mod metadata;
 mod create_scope_map;
 mod source_loc;
@@ -422,7 +421,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
                 let actual_type =
                     cx.tcx.normalize_erasing_regions(ParamEnv::reveal_all(), actual_type);
                 // Add actual type name to <...> clause of function name
-                let actual_type_name = compute_debuginfo_type_name(cx,
+                let actual_type_name = compute_debuginfo_type_name(cx.tcx(),
                                                                    actual_type,
                                                                    true);
                 name_to_append_suffix_to.push_str(&actual_type_name[..]);
diff --git a/src/librustc_codegen_ssa/debuginfo.rs b/src/librustc_codegen_ssa/debuginfo/mod.rs
index aa7cdbed994..d60a2e0cb13 100644
--- a/src/librustc_codegen_ssa/debuginfo.rs
+++ b/src/librustc_codegen_ssa/debuginfo/mod.rs
@@ -1,6 +1,8 @@
 use syntax_pos::{BytePos, Span};
 use rustc::hir::def_id::CrateNum;
 
+pub mod type_names;
+
 pub enum FunctionDebugContext<D> {
     RegularContext(FunctionDebugContextData<D>),
     DebugInfoDisabled,
diff --git a/src/librustc_codegen_llvm/debuginfo/type_names.rs b/src/librustc_codegen_ssa/debuginfo/type_names.rs
index eff7cd1bc8a..fee6c5b04d0 100644
--- a/src/librustc_codegen_llvm/debuginfo/type_names.rs
+++ b/src/librustc_codegen_ssa/debuginfo/type_names.rs
@@ -1,31 +1,26 @@
 // Type Names for Debug Info.
 
-use crate::common::CodegenCx;
-use rustc::hir::def_id::DefId;
-use rustc::ty::subst::SubstsRef;
-use rustc::ty::{self, Ty};
-use rustc_codegen_ssa::traits::*;
+use rustc::hir::{self, def_id::DefId};
+use rustc::ty::{self, Ty, TyCtxt, subst::SubstsRef};
 use rustc_data_structures::fx::FxHashSet;
 
-use rustc::hir;
-
 // Compute the name of the type as it should be stored in debuginfo. Does not do
 // any caching, i.e., calling the function twice with the same type will also do
 // the work twice. The `qualified` parameter only affects the first level of the
 // type name, further levels (i.e., type parameters) are always fully qualified.
-pub fn compute_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
+pub fn compute_debuginfo_type_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                              t: Ty<'tcx>,
                                              qualified: bool)
                                              -> String {
     let mut result = String::with_capacity(64);
     let mut visited = FxHashSet::default();
-    push_debuginfo_type_name(cx, t, qualified, &mut result, &mut visited);
+    push_debuginfo_type_name(tcx, t, qualified, &mut result, &mut visited);
     result
 }
 
 // Pushes the name of the type as it should be stored in debuginfo on the
 // `output` String. See also compute_debuginfo_type_name().
-pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
+pub fn push_debuginfo_type_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                           t: Ty<'tcx>,
                                           qualified: bool,
                                           output: &mut String,
@@ -33,7 +28,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
 
     // When targeting MSVC, emit C++ style type names for compatibility with
     // .natvis visualizers (and perhaps other existing native debuggers?)
-    let cpp_like_names = cx.sess().target.target.options.is_like_msvc;
+    let cpp_like_names = tcx.sess.target.target.options.is_like_msvc;
 
     match t.sty {
         ty::Bool => output.push_str("bool"),
@@ -43,15 +38,15 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
         ty::Int(int_ty) => output.push_str(int_ty.ty_to_string()),
         ty::Uint(uint_ty) => output.push_str(uint_ty.ty_to_string()),
         ty::Float(float_ty) => output.push_str(float_ty.ty_to_string()),
-        ty::Foreign(def_id) => push_item_name(cx, def_id, qualified, output),
+        ty::Foreign(def_id) => push_item_name(tcx, def_id, qualified, output),
         ty::Adt(def, substs) => {
-            push_item_name(cx, def.did, qualified, output);
-            push_type_params(cx, substs, output, visited);
+            push_item_name(tcx, def.did, qualified, output);
+            push_type_params(tcx, substs, output, visited);
         },
         ty::Tuple(component_types) => {
             output.push('(');
             for &component_type in component_types {
-                push_debuginfo_type_name(cx, component_type, true, output, visited);
+                push_debuginfo_type_name(tcx, component_type, true, output, visited);
                 output.push_str(", ");
             }
             if !component_types.is_empty() {
@@ -69,7 +64,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
                 hir::MutMutable => output.push_str("mut "),
             }
 
-            push_debuginfo_type_name(cx, inner_type, true, output, visited);
+            push_debuginfo_type_name(tcx, inner_type, true, output, visited);
 
             if cpp_like_names {
                 output.push('*');
@@ -83,7 +78,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
                 output.push_str("mut ");
             }
 
-            push_debuginfo_type_name(cx, inner_type, true, output, visited);
+            push_debuginfo_type_name(tcx, inner_type, true, output, visited);
 
             if cpp_like_names {
                 output.push('*');
@@ -91,8 +86,8 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
         },
         ty::Array(inner_type, len) => {
             output.push('[');
-            push_debuginfo_type_name(cx, inner_type, true, output, visited);
-            output.push_str(&format!("; {}", len.unwrap_usize(cx.tcx)));
+            push_debuginfo_type_name(tcx, inner_type, true, output, visited);
+            output.push_str(&format!("; {}", len.unwrap_usize(tcx)));
             output.push(']');
         },
         ty::Slice(inner_type) => {
@@ -102,7 +97,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
                 output.push('[');
             }
 
-            push_debuginfo_type_name(cx, inner_type, true, output, visited);
+            push_debuginfo_type_name(tcx, inner_type, true, output, visited);
 
             if cpp_like_names {
                 output.push('>');
@@ -112,12 +107,12 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
         },
         ty::Dynamic(ref trait_data, ..) => {
             if let Some(principal) = trait_data.principal() {
-                let principal = cx.tcx.normalize_erasing_late_bound_regions(
+                let principal = tcx.normalize_erasing_late_bound_regions(
                     ty::ParamEnv::reveal_all(),
                     &principal,
                 );
-                push_item_name(cx, principal.def_id, false, output);
-                push_type_params(cx, principal.substs, output, visited);
+                push_item_name(tcx, principal.def_id, false, output);
+                push_type_params(tcx, principal.substs, output, visited);
             } else {
                 output.push_str("dyn '_");
             }
@@ -142,13 +137,13 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
             }
 
 
-            let sig = t.fn_sig(cx.tcx);
+            let sig = t.fn_sig(tcx);
             if sig.unsafety() == hir::Unsafety::Unsafe {
                 output.push_str("unsafe ");
             }
 
             let abi = sig.abi();
-            if abi != crate::abi::Abi::Rust {
+            if abi != rustc_target::spec::abi::Abi::Rust {
                 output.push_str("extern \"");
                 output.push_str(abi.name());
                 output.push_str("\" ");
@@ -156,10 +151,10 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
 
             output.push_str("fn(");
 
-            let sig = cx.tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig);
+            let sig = tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig);
             if !sig.inputs().is_empty() {
                 for &parameter_type in sig.inputs() {
-                    push_debuginfo_type_name(cx, parameter_type, true, output, visited);
+                    push_debuginfo_type_name(tcx, parameter_type, true, output, visited);
                     output.push_str(", ");
                 }
                 output.pop();
@@ -178,7 +173,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
 
             if !sig.output().is_unit() {
                 output.push_str(" -> ");
-                push_debuginfo_type_name(cx, sig.output(), true, output, visited);
+                push_debuginfo_type_name(tcx, sig.output(), true, output, visited);
             }
 
 
@@ -213,18 +208,18 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
         }
     }
 
-    fn push_item_name(cx: &CodegenCx<'_, '_>,
+    fn push_item_name(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                       def_id: DefId,
                       qualified: bool,
                       output: &mut String) {
         if qualified {
-            output.push_str(&cx.tcx.crate_name(def_id.krate).as_str());
-            for path_element in cx.tcx.def_path(def_id).data {
+            output.push_str(&tcx.crate_name(def_id.krate).as_str());
+            for path_element in tcx.def_path(def_id).data {
                 output.push_str("::");
                 output.push_str(&path_element.data.as_interned_str().as_str());
             }
         } else {
-            output.push_str(&cx.tcx.item_name(def_id).as_str());
+            output.push_str(&tcx.item_name(def_id).as_str());
         }
     }
 
@@ -233,7 +228,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
     // reconstructed for items from non-local crates. For local crates, this
     // would be possible but with inlining and LTO we have to use the least
     // common denominator - otherwise we would run into conflicts.
-    fn push_type_params<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
+    fn push_type_params<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                   substs: SubstsRef<'tcx>,
                                   output: &mut String,
                                   visited: &mut FxHashSet<Ty<'tcx>>) {
@@ -244,7 +239,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
         output.push('<');
 
         for type_parameter in substs.types() {
-            push_debuginfo_type_name(cx, type_parameter, true, output, visited);
+            push_debuginfo_type_name(tcx, type_parameter, true, output, visited);
             output.push_str(", ");
         }