Skip to content

Commit f711c05

Browse files
Clean up attribute handling in create_function_debug_context().
1 parent f78b8c0 commit f711c05

File tree

1 file changed

+11
-7
lines changed
  • src/librustc_trans/debuginfo

1 file changed

+11
-7
lines changed

src/librustc_trans/debuginfo/mod.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ use self::source_loc::InternalDebugLocation::{self, UnknownLocation};
2323
use llvm;
2424
use llvm::{ModuleRef, ContextRef, ValueRef};
2525
use llvm::debuginfo::{DIFile, DIType, DIScope, DIBuilderRef, DISubprogram, DIArray, DIFlags};
26+
use rustc::hir::TransFnAttrFlags;
2627
use rustc::hir::def_id::{DefId, CrateNum};
2728
use rustc::ty::subst::Substs;
2829

2930
use abi::Abi;
3031
use common::CodegenCx;
3132
use builder::Builder;
3233
use monomorphize::Instance;
33-
use rustc::ty::{self, ParamEnv, Ty};
34+
use rustc::ty::{self, ParamEnv, Ty, InstanceDef};
3435
use rustc::mir;
3536
use rustc::session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo};
3637
use rustc::util::nodemap::{DefIdMap, FxHashMap, FxHashSet};
@@ -210,13 +211,16 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
210211
return FunctionDebugContext::DebugInfoDisabled;
211212
}
212213

213-
for attr in instance.def.attrs(cx.tcx).iter() {
214-
if attr.check_name("no_debug") {
215-
return FunctionDebugContext::FunctionWithoutDebugInfo;
216-
}
214+
let def_id = if let InstanceDef::Item(def_id) = instance.def {
215+
def_id
216+
} else {
217+
return FunctionDebugContext::FunctionWithoutDebugInfo;
218+
};
219+
220+
if cx.tcx.trans_fn_attrs(def_id).flags.contains(TransFnAttrFlags::NO_DEBUG) {
221+
return FunctionDebugContext::FunctionWithoutDebugInfo;
217222
}
218223

219-
let containing_scope = get_containing_scope(cx, instance);
220224
let span = mir.span;
221225

222226
// This can be the case for functions inlined from another crate
@@ -225,7 +229,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
225229
return FunctionDebugContext::FunctionWithoutDebugInfo;
226230
}
227231

228-
let def_id = instance.def_id();
232+
let containing_scope = get_containing_scope(cx, instance);
229233
let loc = span_start(cx, span);
230234
let file_metadata = file_metadata(cx, &loc.file.name, def_id.krate);
231235

0 commit comments

Comments
 (0)