Skip to content

Commit

Permalink
Normalize DebugInfoLevel to standard style
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Aug 4, 2018
1 parent 442a474 commit 2bc7197
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 40 deletions.
28 changes: 13 additions & 15 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
//! Contains infrastructure for configuring the compiler, including parsing
//! command line options.
pub use self::DebugInfoLevel::*;

use std::str::FromStr;

use session::{early_error, early_warn, Session};
Expand Down Expand Up @@ -110,10 +108,10 @@ impl CrossLangLto {
}

#[derive(Clone, Copy, PartialEq, Hash)]
pub enum DebugInfoLevel {
NoDebugInfo,
LimitedDebugInfo,
FullDebugInfo,
pub enum DebugInfo {
None,
Limited,
Full,
}

#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, PartialOrd, Ord, RustcEncodable, RustcDecodable)]
Expand Down Expand Up @@ -378,7 +376,7 @@ top_level_options!(
// Include the debug_assertions flag into dependency tracking, since it
// can influence whether overflow checks are done or not.
debug_assertions: bool [TRACKED],
debuginfo: DebugInfoLevel [TRACKED],
debuginfo: DebugInfo [TRACKED],
lint_opts: Vec<(String, lint::Level)> [TRACKED],
lint_cap: Option<lint::Level> [TRACKED],
describe_lints: bool [UNTRACKED],
Expand Down Expand Up @@ -603,7 +601,7 @@ pub fn basic_options() -> Options {
Options {
crate_types: Vec::new(),
optimize: OptLevel::No,
debuginfo: NoDebugInfo,
debuginfo: DebugInfo::None,
lint_opts: Vec::new(),
lint_cap: None,
describe_lints: false,
Expand Down Expand Up @@ -2080,12 +2078,12 @@ pub fn build_session_options_and_crate_config(
if cg.debuginfo.is_some() {
early_error(error_format, "-g and -C debuginfo both provided");
}
FullDebugInfo
DebugInfo::Full
} else {
match cg.debuginfo {
None | Some(0) => NoDebugInfo,
Some(1) => LimitedDebugInfo,
Some(2) => FullDebugInfo,
None | Some(0) => DebugInfo::None,
Some(1) => DebugInfo::Limited,
Some(2) => DebugInfo::Full,
Some(arg) => {
early_error(
error_format,
Expand Down Expand Up @@ -2184,7 +2182,7 @@ pub fn build_session_options_and_crate_config(
Some(m) => early_error(error_format, &format!("unknown borrowck mode `{}`", m)),
};

if !cg.remark.is_empty() && debuginfo == NoDebugInfo {
if !cg.remark.is_empty() && debuginfo == DebugInfo::None {
early_warn(
error_format,
"-C remark will not show source locations without \
Expand Down Expand Up @@ -2391,7 +2389,7 @@ mod dep_tracking {
use std::hash::Hash;
use std::path::PathBuf;
use std::collections::hash_map::DefaultHasher;
use super::{CrateType, DebugInfoLevel, ErrorOutputType, Lto, OptLevel, OutputTypes,
use super::{CrateType, DebugInfo, ErrorOutputType, Lto, OptLevel, OutputTypes,
Passes, Sanitizer, CrossLangLto};
use syntax::feature_gate::UnstableFeatures;
use rustc_target::spec::{PanicStrategy, RelroLevel, TargetTriple};
Expand Down Expand Up @@ -2448,7 +2446,7 @@ mod dep_tracking {
impl_dep_tracking_hash_via_hash!(Passes);
impl_dep_tracking_hash_via_hash!(OptLevel);
impl_dep_tracking_hash_via_hash!(Lto);
impl_dep_tracking_hash_via_hash!(DebugInfoLevel);
impl_dep_tracking_hash_via_hash!(DebugInfo);
impl_dep_tracking_hash_via_hash!(UnstableFeatures);
impl_dep_tracking_hash_via_hash!(OutputTypes);
impl_dep_tracking_hash_via_hash!(cstore::NativeLibraryKind);
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_codegen_llvm/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use super::command::Command;
use super::rpath::RPathConfig;
use super::rpath;
use metadata::METADATA_FILENAME;
use rustc::session::config::{self, NoDebugInfo, OutputFilenames, OutputType, PrintRequest};
use rustc::session::config::{self, DebugInfo, OutputFilenames, OutputType, PrintRequest};
use rustc::session::config::{RUST_CGU_EXT, Lto};
use rustc::session::filesearch;
use rustc::session::search_paths::PathKind;
Expand Down Expand Up @@ -200,7 +200,7 @@ pub(crate) fn link_binary(sess: &Session,
/// split-dwarf like schemes.
fn preserve_objects_for_their_debuginfo(sess: &Session) -> bool {
// If the objects don't have debuginfo there's nothing to preserve.
if sess.opts.debuginfo == NoDebugInfo {
if sess.opts.debuginfo == DebugInfo::None {
return false
}

Expand Down Expand Up @@ -834,7 +834,7 @@ fn link_natively(sess: &Session,
// the symbols. Note, though, that if the object files are being preserved
// for their debug information there's no need for us to run dsymutil.
if sess.target.target.options.is_like_osx &&
sess.opts.debuginfo != NoDebugInfo &&
sess.opts.debuginfo != DebugInfo::None &&
!preserve_objects_for_their_debuginfo(sess)
{
match Command::new("dsymutil").arg(out_filename).output() {
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_codegen_llvm/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use back::symbol_export;
use rustc::hir::def_id::{LOCAL_CRATE, CrateNum};
use rustc::middle::dependency_format::Linkage;
use rustc::session::Session;
use rustc::session::config::{self, CrateType, OptLevel, DebugInfoLevel,
use rustc::session::config::{self, CrateType, OptLevel, DebugInfo,
CrossLangLto};
use rustc::ty::TyCtxt;
use rustc_target::spec::{LinkerFlavor, LldFlavor};
Expand Down Expand Up @@ -338,7 +338,7 @@ impl<'a> Linker for GccLinker<'a> {

fn debuginfo(&mut self) {
match self.sess.opts.debuginfo {
DebugInfoLevel::NoDebugInfo => {
DebugInfo::None => {
// If we are building without debuginfo enabled and we were called with
// `-Zstrip-debuginfo-if-disabled=yes`, tell the linker to strip any debuginfo
// found when linking to get rid of symbols from libstd.
Expand Down Expand Up @@ -826,9 +826,9 @@ impl<'a> Linker for EmLinker<'a> {
fn debuginfo(&mut self) {
// Preserve names or generate source maps depending on debug info
self.cmd.arg(match self.sess.opts.debuginfo {
DebugInfoLevel::NoDebugInfo => "-g0",
DebugInfoLevel::LimitedDebugInfo => "-g3",
DebugInfoLevel::FullDebugInfo => "-g4"
DebugInfo::None => "-g0",
DebugInfo::Limited => "-g3",
DebugInfo::Full => "-g4"
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ pub struct CodegenContext {
pub tm_factory: Arc<dyn Fn() -> Result<&'static mut llvm::TargetMachine, String> + Send + Sync>,
pub msvc_imps_needed: bool,
pub target_pointer_width: String,
debuginfo: config::DebugInfoLevel,
debuginfo: config::DebugInfo,

// Number of cgus excluding the allocator/metadata modules
pub total_cgus: usize,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use rustc::middle::cstore::{self, LinkMeta, LinkagePreference};
use rustc::middle::exported_symbols;
use rustc::util::common::{time, print_time_passes_entry};
use rustc::util::profiling::ProfileCategory;
use rustc::session::config::{self, NoDebugInfo, EntryFnType};
use rustc::session::config::{self, DebugInfo, EntryFnType};
use rustc::session::Session;
use rustc_incremental;
use allocator;
Expand Down Expand Up @@ -1249,7 +1249,7 @@ fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}

// Finalize debuginfo
if cx.sess().opts.debuginfo != NoDebugInfo {
if cx.sess().opts.debuginfo != DebugInfo::None {
debuginfo::finalize(&cx);
}

Expand Down
6 changes: 3 additions & 3 deletions src/librustc_codegen_llvm/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use type_of::PointeeInfo;

use rustc_data_structures::base_n;
use rustc::mir::mono::Stats;
use rustc::session::config::{self, NoDebugInfo};
use rustc::session::config::{self, DebugInfo};
use rustc::session::Session;
use rustc::ty::layout::{LayoutError, LayoutOf, Size, TyLayout};
use rustc::ty::{self, Ty, TyCtxt};
Expand Down Expand Up @@ -270,7 +270,7 @@ impl<'a, 'tcx> CodegenCx<'a, 'tcx> {

let (llcx, llmod) = (&*llvm_module.llcx, llvm_module.llmod());

let dbg_cx = if tcx.sess.opts.debuginfo != NoDebugInfo {
let dbg_cx = if tcx.sess.opts.debuginfo != DebugInfo::None {
let dctx = debuginfo::CrateDebugContext::new(llmod);
debuginfo::metadata::compile_unit_metadata(tcx,
&codegen_unit.name().as_str(),
Expand Down Expand Up @@ -770,7 +770,7 @@ fn declare_intrinsic(cx: &CodegenCx<'ll, '_>, key: &str) -> Option<&'ll Value> {
ifn!("llvm.assume", fn(i1) -> void);
ifn!("llvm.prefetch", fn(i8p, t_i32, t_i32, t_i32) -> void);

if cx.sess().opts.debuginfo != NoDebugInfo {
if cx.sess().opts.debuginfo != DebugInfo::None {
ifn!("llvm.dbg.declare", fn(Type::metadata(cx), Type::metadata(cx)) -> void);
ifn!("llvm.dbg.value", fn(Type::metadata(cx), t_i64, Type::metadata(cx)) -> void);
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/debuginfo/gdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use llvm;
use common::{C_bytes, CodegenCx, C_i32};
use builder::Builder;
use declare;
use rustc::session::config::NoDebugInfo;
use rustc::session::config::DebugInfo;
use type_::Type;
use value::Value;

Expand Down Expand Up @@ -81,6 +81,6 @@ pub fn needs_gdb_debug_scripts_section(cx: &CodegenCx) -> bool {
"omit_gdb_pretty_printer_section");

!omit_gdb_pretty_printer_section &&
cx.sess().opts.debuginfo != NoDebugInfo &&
cx.sess().opts.debuginfo != DebugInfo::None &&
cx.sess().target.target.options.emit_debug_gdb_scripts
}
8 changes: 4 additions & 4 deletions src/librustc_codegen_llvm/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use builder::Builder;
use monomorphize::Instance;
use rustc::ty::{self, ParamEnv, Ty, InstanceDef};
use rustc::mir;
use rustc::session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo};
use rustc::session::config::{self, DebugInfo};
use rustc::util::nodemap::{DefIdMap, FxHashMap, FxHashSet};
use value::Value;

Expand Down Expand Up @@ -214,7 +214,7 @@ pub fn create_function_debug_context(
llfn: &'ll Value,
mir: &mir::Mir,
) -> FunctionDebugContext<'ll> {
if cx.sess().opts.debuginfo == NoDebugInfo {
if cx.sess().opts.debuginfo == DebugInfo::None {
return FunctionDebugContext::DebugInfoDisabled;
}

Expand Down Expand Up @@ -314,7 +314,7 @@ pub fn create_function_debug_context(
cx: &CodegenCx<'ll, 'tcx>,
sig: ty::FnSig<'tcx>,
) -> &'ll DIArray {
if cx.sess().opts.debuginfo == LimitedDebugInfo {
if cx.sess().opts.debuginfo == DebugInfo::Limited {
return create_DIArray(DIB(cx), &[]);
}

Expand Down Expand Up @@ -400,7 +400,7 @@ pub fn create_function_debug_context(
name_to_append_suffix_to.push('>');

// Again, only create type information if full debuginfo is enabled
let template_params: Vec<_> = if cx.sess().opts.debuginfo == FullDebugInfo {
let template_params: Vec<_> = if cx.sess().opts.debuginfo == DebugInfo::Full {
let names = get_parameter_names(cx, generics);
substs.iter().zip(names).filter_map(|(kind, name)| {
if let UnpackedKind::Type(ty) = kind.unpack() {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_codegen_llvm/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use rustc::ty::{self, Ty, TypeFoldable, UpvarSubsts};
use rustc::ty::layout::{LayoutOf, TyLayout};
use rustc::mir::{self, Mir};
use rustc::ty::subst::Substs;
use rustc::session::config::FullDebugInfo;
use rustc::session::config::DebugInfo;
use base;
use builder::Builder;
use common::{CodegenCx, Funclet};
Expand Down Expand Up @@ -267,7 +267,7 @@ pub fn codegen_mir(
if let Some(name) = decl.name {
// User variable
let debug_scope = fx.scopes[decl.visibility_scope];
let dbg = debug_scope.is_valid() && bx.sess().opts.debuginfo == FullDebugInfo;
let dbg = debug_scope.is_valid() && bx.sess().opts.debuginfo == DebugInfo::Full;

if !memory_locals.contains(local) && !dbg {
debug!("alloc: {:?} ({}) -> operand", local, name);
Expand Down Expand Up @@ -426,7 +426,7 @@ fn arg_local_refs(

// Get the argument scope, if it exists and if we need it.
let arg_scope = scopes[mir::OUTERMOST_SOURCE_SCOPE];
let arg_scope = if bx.sess().opts.debuginfo == FullDebugInfo {
let arg_scope = if bx.sess().opts.debuginfo == DebugInfo::Full {
arg_scope.scope_metadata
} else {
None
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/transform/simplify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use rustc_data_structures::indexed_vec::{Idx, IndexVec};
use rustc::ty::TyCtxt;
use rustc::mir::*;
use rustc::mir::visit::{MutVisitor, Visitor, PlaceContext};
use rustc::session::config::FullDebugInfo;
use rustc::session::config::DebugInfo;
use std::borrow::Cow;
use transform::{MirPass, MirSource};

Expand Down Expand Up @@ -294,7 +294,7 @@ impl MirPass for SimplifyLocals {
}

// We may need to keep dead user variables live for debuginfo.
if tcx.sess.opts.debuginfo == FullDebugInfo {
if tcx.sess.opts.debuginfo == DebugInfo::Full {
for local in mir.vars_iter() {
marker.locals.insert(local);
}
Expand Down

0 comments on commit 2bc7197

Please sign in to comment.