Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 9 additions & 1 deletion src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rustc_data_structures::fingerprint::Fingerprint;

use crate::lint;
use crate::lint::builtin::BuiltinLintDiagnostics;
use crate::session::config::{OutputType, PrintRequest, SwitchWithOptPath};
use crate::session::config::{OutputType, PrintRequest, Sanitizer, SwitchWithOptPath};
use crate::session::search_paths::{PathKind, SearchPath};
use crate::util::nodemap::{FxHashMap, FxHashSet};
use crate::util::common::{duration_to_secs_str, ErrorReported};
Expand Down Expand Up @@ -626,6 +626,14 @@ impl Session {
.output_types
.contains_key(&OutputType::LlvmAssembly)
|| self.opts.output_types.contains_key(&OutputType::Bitcode);

// Address sanitizer and memory sanitizer use alloca name when reporting an issue.
let more_names = match self.opts.debugging_opts.sanitizer {
Some(Sanitizer::Address) => true,
Some(Sanitizer::Memory) => true,
_ => more_names,
};

self.opts.debugging_opts.fewer_names || !more_names
}

Expand Down
3 changes: 3 additions & 0 deletions src/test/run-make-fulldeps/sanitizer-address/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ endif

all:
$(RUSTC) -g -Z sanitizer=address -Z print-link-args $(EXTRA_RUSTFLAG) overflow.rs | $(CGREP) librustc_asan
# Verify that stack buffer overflow is detected:
$(TMPDIR)/overflow 2>&1 | $(CGREP) stack-buffer-overflow
# Verify that variable name is included in address sanitizer report:
$(TMPDIR)/overflow 2>&1 | $(CGREP) "'xs'"