Replace Session should_remap_filepaths with filename_display_preference
This commit is contained in:
parent
4f4fa42b0e
commit
fefb8f1f9c
6 changed files with 48 additions and 50 deletions
|
@ -258,19 +258,17 @@ pub fn target_machine_factory(
|
|||
};
|
||||
let debuginfo_compression = SmallCStr::new(&debuginfo_compression);
|
||||
|
||||
let should_prefer_remapped_paths =
|
||||
sess.should_prefer_remapped(RemapPathScopeComponents::DEBUGINFO);
|
||||
let file_name_display_preference =
|
||||
sess.filename_display_preference(RemapPathScopeComponents::DEBUGINFO);
|
||||
|
||||
Arc::new(move |config: TargetMachineFactoryConfig| {
|
||||
let path_to_cstring_helper = |path: Option<PathBuf>| -> CString {
|
||||
let path = path.unwrap_or_default();
|
||||
let path = path_mapping.to_real_filename(path);
|
||||
let path = if should_prefer_remapped_paths {
|
||||
path.remapped_path_if_available()
|
||||
} else {
|
||||
path.local_path_if_available()
|
||||
};
|
||||
CString::new(path.to_str().unwrap()).unwrap()
|
||||
let path = path_mapping
|
||||
.to_real_filename(path)
|
||||
.to_string_lossy(file_name_display_preference)
|
||||
.into_owned();
|
||||
CString::new(path).unwrap()
|
||||
};
|
||||
|
||||
let split_dwarf_file = path_to_cstring_helper(config.split_dwarf_file);
|
||||
|
|
|
@ -554,13 +554,16 @@ pub fn file_metadata<'ll>(cx: &CodegenCx<'ll, '_>, source_file: &SourceFile) ->
|
|||
) -> &'ll DIFile {
|
||||
debug!(?source_file.name);
|
||||
|
||||
use rustc_session::{config::RemapPathScopeComponents, RemapFileNameExt};
|
||||
let filename_display_preference =
|
||||
cx.sess().filename_display_preference(RemapPathScopeComponents::DEBUGINFO);
|
||||
|
||||
use rustc_session::config::RemapPathScopeComponents;
|
||||
let (directory, file_name) = match &source_file.name {
|
||||
FileName::Real(filename) => {
|
||||
let working_directory = &cx.sess().opts.working_dir;
|
||||
debug!(?working_directory);
|
||||
|
||||
if cx.sess().should_prefer_remapped(RemapPathScopeComponents::DEBUGINFO) {
|
||||
if filename_display_preference == FileNameDisplayPreference::Remapped {
|
||||
let filename = cx
|
||||
.sess()
|
||||
.source_map()
|
||||
|
@ -623,13 +626,7 @@ pub fn file_metadata<'ll>(cx: &CodegenCx<'ll, '_>, source_file: &SourceFile) ->
|
|||
}
|
||||
other => {
|
||||
debug!(?other);
|
||||
(
|
||||
"".into(),
|
||||
other
|
||||
.for_scope(cx.sess(), RemapPathScopeComponents::DEBUGINFO)
|
||||
.to_string_lossy()
|
||||
.into_owned(),
|
||||
)
|
||||
("".into(), other.display(filename_display_preference).to_string())
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue