]> git.lizzy.rs Git - rust.git/commitdiff
Move debug info check into create_function_debug_context
authorMark Simulacrum <mark.simulacrum@gmail.com>
Mon, 19 Dec 2016 14:33:35 +0000 (07:33 -0700)
committerMark Simulacrum <mark.simulacrum@gmail.com>
Wed, 21 Dec 2016 03:03:34 +0000 (20:03 -0700)
src/librustc_trans/debuginfo/mod.rs
src/librustc_trans/mir/mod.rs

index e984edacaf871eff810e0e0387748bdfe97fce65..8bd9786c665739f948b9946e5faab959547f6582 100644 (file)
@@ -195,15 +195,6 @@ pub fn finalize(cx: &CrateContext) {
     };
 }
 
-/// Creates a function-specific debug context for a function w/o debuginfo.
-pub fn empty_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>) -> FunctionDebugContext {
-    if cx.sess().opts.debuginfo == NoDebugInfo {
-        FunctionDebugContext::DebugInfoDisabled
-    } else {
-        FunctionDebugContext::FunctionWithoutDebugInfo
-    }
-}
-
 /// Creates the function-specific debug context.
 ///
 /// Returns the FunctionDebugContext for the function which holds state needed
@@ -220,6 +211,12 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
         return FunctionDebugContext::DebugInfoDisabled;
     }
 
+    for attr in cx.tcx().get_attrs(instance.def).iter() {
+        if attr.check_name("no_debug") {
+            return FunctionDebugContext::FunctionWithoutDebugInfo;
+        }
+    }
+
     let containing_scope = get_containing_scope(cx, instance);
     let span = mir.span;
 
index 1cfe60727fcd2423826b9e661a4353f7edb773c6..4a908e8cea9b4b027fd232c93e1b83bc7729d450 100644 (file)
@@ -199,22 +199,10 @@ pub fn trans_mir<'a, 'tcx: 'a>(
     sig: &ty::FnSig<'tcx>,
     abi: Abi,
 ) {
-    let def_id = instance.def;
-    let local_id = fcx.ccx.tcx().map.as_local_node_id(def_id);
-    let no_debug = if let Some(id) = local_id {
-        fcx.ccx.tcx().map.attrs(id).iter().any(|item| item.check_name("no_debug"))
-    } else {
-        fcx.ccx.sess().cstore.item_attrs(def_id).iter().any(|item| item.check_name("no_debug"))
-    };
-
-    let debug_context = if !no_debug {
-        debuginfo::create_function_debug_context(fcx.ccx, instance, sig, abi, fcx.llfn, mir)
-    } else {
-        debuginfo::empty_function_debug_context(fcx.ccx)
-    };
+    let debug_context =
+        debuginfo::create_function_debug_context(fcx.ccx, instance, sig, abi, fcx.llfn, mir);
     let bcx = fcx.get_entry_block();
 
-    // Analyze the temps to determine which must be lvalues
     let cleanup_kinds = analyze::cleanup_kinds(&mir);
 
     // Allocate a `Block` for every basic block