Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
af6ace6
convert custom try macro to `?`
hellow554 May 6, 2019
5458b65
use exhaustive_patterns to be able to use `?`
hellow554 May 6, 2019
c5d9401
Avoid symbol interning in `file_metadata`.
nnethercote May 6, 2019
a7e1431
Update boxed::Box docs on memory layout
blkerby May 19, 2019
178b753
Remove trailing whitespaces to satisfy tidy
blkerby May 19, 2019
d320c7c
Do not fail on child without DefId
estebank May 20, 2019
419ca9d
LocalDecl push returns Local len
spastorino May 20, 2019
4e37785
Create and reference Memory Layout section of boxed docs
blkerby May 21, 2019
e186d3f
Add stream_to_parser_with_base_dir
topecongiro May 21, 2019
5ea5fe3
static_assert: make use of anonymous constants
RalfJung May 21, 2019
61735ab
adjust deprecation date of mem::uninitialized
RalfJung May 21, 2019
b07dbe1
Add doc comment
topecongiro May 21, 2019
1f1a917
Fix tidy: remove a trailing whitespace
topecongiro May 21, 2019
a2168b0
update doc comment
RalfJung May 21, 2019
ea01af4
Rollup merge of #60581 - hellow554:fix_60580, r=alexcrichton
Centril May 21, 2019
bb03f31
Rollup merge of #60963 - blkerby:boxed_docs, r=alexcrichton
Centril May 21, 2019
cd84e24
Rollup merge of #60973 - nnethercote:fix-file_metadata-more, r=michae…
Centril May 21, 2019
c09259c
Rollup merge of #60982 - estebank:fix-60976, r=petrochenkov
Centril May 21, 2019
d152bf2
Rollup merge of #60991 - spastorino:local-decls-push, r=oli-obk
Centril May 21, 2019
36680df
Rollup merge of #60995 - topecongiro:parser-from-stream-and-base-dir,…
Centril May 21, 2019
557af5b
Rollup merge of #60998 - RalfJung:static_assert, r=Centril
Centril May 21, 2019
d504b33
Rollup merge of #61006 - RalfJung:maybe-uninit, r=Centril
Centril May 21, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 32 additions & 32 deletions src/librustc_codegen_llvm/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ use rustc_data_structures::small_c_str::SmallCStr;
use rustc_target::abi::HasDataLayout;

use libc::{c_uint, c_longlong};
use std::collections::hash_map::Entry;
use std::ffi::CString;
use std::fmt::{self, Write};
use std::hash::{Hash, Hasher};
use std::iter;
use std::ptr;
use std::path::{Path, PathBuf};
use syntax::ast;
use syntax::symbol::{Interner, InternedString, Symbol};
use syntax::symbol::{Interner, InternedString};
use syntax_pos::{self, Span, FileName};

impl PartialEq for llvm::Metadata {
Expand Down Expand Up @@ -787,49 +788,48 @@ pub fn file_metadata(cx: &CodegenCx<'ll, '_>,
file_name,
defining_crate);

let file_name = &file_name.to_string();
let file_name_symbol = Symbol::intern(file_name);
if defining_crate == LOCAL_CRATE {
let directory = &cx.sess().working_dir.0.to_string_lossy();
file_metadata_raw(cx, file_name, Some(file_name_symbol),
directory, Some(Symbol::intern(directory)))
let file_name = Some(file_name.to_string());
let directory = if defining_crate == LOCAL_CRATE {
Some(cx.sess().working_dir.0.to_string_lossy().to_string())
} else {
// If the path comes from an upstream crate we assume it has been made
// independent of the compiler's working directory one way or another.
file_metadata_raw(cx, file_name, Some(file_name_symbol), "", None)
}
None
};
file_metadata_raw(cx, file_name, directory)
}

pub fn unknown_file_metadata(cx: &CodegenCx<'ll, '_>) -> &'ll DIFile {
file_metadata_raw(cx, "<unknown>", None, "", None)
file_metadata_raw(cx, None, None)
}

fn file_metadata_raw(cx: &CodegenCx<'ll, '_>,
file_name: &str,
file_name_symbol: Option<Symbol>,
directory: &str,
directory_symbol: Option<Symbol>)
file_name: Option<String>,
directory: Option<String>)
-> &'ll DIFile {
let key = (file_name_symbol, directory_symbol);
let key = (file_name, directory);

match debug_context(cx).created_files.borrow_mut().entry(key) {
Entry::Occupied(o) => return o.get(),
Entry::Vacant(v) => {
let (file_name, directory) = v.key();
debug!("file_metadata: file_name: {:?}, directory: {:?}", file_name, directory);

let file_name = SmallCStr::new(
if let Some(file_name) = file_name { &file_name } else { "<unknown>" });
let directory = SmallCStr::new(
if let Some(directory) = directory { &directory } else { "" });

let file_metadata = unsafe {
llvm::LLVMRustDIBuilderCreateFile(DIB(cx),
file_name.as_ptr(),
directory.as_ptr())
};

if let Some(file_metadata) = debug_context(cx).created_files.borrow().get(&key) {
return *file_metadata;
v.insert(file_metadata);
file_metadata
}
}

debug!("file_metadata: file_name: {}, directory: {}", file_name, directory);

let file_name = SmallCStr::new(file_name);
let directory = SmallCStr::new(directory);

let file_metadata = unsafe {
llvm::LLVMRustDIBuilderCreateFile(DIB(cx),
file_name.as_ptr(),
directory.as_ptr())
};

let mut created_files = debug_context(cx).created_files.borrow_mut();
created_files.insert(key, file_metadata);
file_metadata
}

fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use std::ffi::CString;

use syntax_pos::{self, Span, Pos};
use syntax::ast;
use syntax::symbol::{Symbol, InternedString};
use syntax::symbol::InternedString;
use rustc::ty::layout::{self, LayoutOf, HasTyCtxt};
use rustc_codegen_ssa::traits::*;

Expand All @@ -63,7 +63,7 @@ pub struct CrateDebugContext<'a, 'tcx> {
llcontext: &'a llvm::Context,
llmod: &'a llvm::Module,
builder: &'a mut DIBuilder<'a>,
created_files: RefCell<FxHashMap<(Option<Symbol>, Option<Symbol>), &'a DIFile>>,
created_files: RefCell<FxHashMap<(Option<String>, Option<String>), &'a DIFile>>,
created_enum_disr_types: RefCell<FxHashMap<(DefId, layout::Primitive), &'a DIType>>,

type_map: RefCell<TypeMap<'a, 'tcx>>,
Expand Down