]> git.lizzy.rs Git - rust.git/commitdiff
Normalize DebugInfoLevel to standard style
authorMark Rousskov <mark.simulacrum@gmail.com>
Thu, 26 Jul 2018 17:41:10 +0000 (11:41 -0600)
committerMark Rousskov <mark.simulacrum@gmail.com>
Sat, 4 Aug 2018 12:54:34 +0000 (06:54 -0600)
src/librustc/session/config.rs
src/librustc_codegen_llvm/back/link.rs
src/librustc_codegen_llvm/back/linker.rs
src/librustc_codegen_llvm/back/write.rs
src/librustc_codegen_llvm/base.rs
src/librustc_codegen_llvm/context.rs
src/librustc_codegen_llvm/debuginfo/gdb.rs
src/librustc_codegen_llvm/debuginfo/mod.rs
src/librustc_codegen_llvm/mir/mod.rs
src/librustc_mir/transform/simplify.rs

index e69e6215ba14bd223ff963f2c5c355fb3901911f..2281aca7a624e7498fb5d883f0a598daacd120e6 100644 (file)
@@ -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};
@@ -110,10 +108,10 @@ pub fn enabled(&self) -> bool {
 }
 
 #[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)]
@@ -378,7 +376,7 @@ pub struct 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],
@@ -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,
@@ -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,
@@ -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 \
@@ -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};
@@ -2448,7 +2446,7 @@ fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType) {
     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);
index 7cd2deabdeb7c0e2a63717441d57363a7ace990c..108734b67d3b837a92efb20e85e24d56d719a3ee 100644 (file)
@@ -17,7 +17,7 @@
 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;
@@ -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
     }
 
@@ -834,7 +834,7 @@ fn escape_string(s: &[u8]) -> String {
     // 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() {
index 0383539e7c475a0be1f25e72587d1b653e3027dc..e0a30ef5dbc9abe10befecbda24285ef84a394fd 100644 (file)
@@ -21,7 +21,7 @@
 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};
@@ -338,7 +338,7 @@ fn pgo_gen(&mut self) {
 
     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.
@@ -826,9 +826,9 @@ fn pgo_gen(&mut self) {
     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"
         });
     }
 
index aec43be0795b17c68e366443049a3c6d596f0c99..a5c6a0d5cd690e4828b2b4595db3220b9a7cb291 100644 (file)
@@ -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,
index d98a8981da724dd1c2a3128f67c5866caa956bd2..41336165684f61ff630eb59570c7653610dbd0b9 100644 (file)
@@ -46,7 +46,7 @@
 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;
@@ -1249,7 +1249,7 @@ fn module_codegen<'a, 'tcx>(
             }
 
             // Finalize debuginfo
-            if cx.sess().opts.debuginfo != NoDebugInfo {
+            if cx.sess().opts.debuginfo != DebugInfo::None {
                 debuginfo::finalize(&cx);
             }
 
index 2832c114f5158c4b0c32c45c5bbf0240f8f9996a..2f557d0b099986eb9d716ce5f2569b28e4819709 100644 (file)
@@ -26,7 +26,7 @@
 
 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};
@@ -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(),
@@ -770,7 +770,7 @@ macro_rules! mk_struct {
     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);
     }
index 08128a729b5f0ca02dc8bcc31e4ac929a2cdac2c..f6faddb894ffdf41c532659fffc92afea806f412 100644 (file)
@@ -15,7 +15,7 @@
 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;
 
@@ -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
 }
index 143b122a5a172e1098c4da91a9f190082dcd9f73..d4fb2549a752c80f6d03c287c8462dfb07bf180c 100644 (file)
@@ -32,7 +32,7 @@
 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;
 
@@ -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;
     }
 
@@ -314,7 +314,7 @@ fn get_function_signature(
         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), &[]);
         }
 
@@ -400,7 +400,7 @@ fn get_template_parameters(
         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() {
index a099cb5c64b211fcf1087717dfe5325db1e15099..8fdb67f5930cecb8f05d9eea7d86df76a79fd7aa 100644 (file)
@@ -16,7 +16,7 @@
 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};
@@ -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);
@@ -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
index 6e8471c672934e127bac884eeefcc7066bd9d584..164790db4b5ec81b0f0ab62420b4481f8afc6419 100644 (file)
@@ -42,7 +42,7 @@
 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};
 
@@ -294,7 +294,7 @@ fn run_pass<'a, 'tcx>(&self,
         }
 
         // 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);
             }