Skip to content

Commit 125474d

Browse files
committed
Auto merge of #37857 - shepmaster:llvm-4.0-dinodes, r=michaelwoerister
[LLVM 4.0] Handle new DIFlags enum
2 parents 28d6623 + 757a9ce commit 125474d

File tree

8 files changed

+177
-60
lines changed

8 files changed

+177
-60
lines changed

src/Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/librustc_llvm/Cargo.lock

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/librustc_llvm/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ crate-type = ["dylib"]
1212
[features]
1313
static-libstdcpp = []
1414

15+
[dependencies]
16+
rustc_bitflags = { path = "../librustc_bitflags" }
17+
1518
[build-dependencies]
1619
build_helper = { path = "../build_helper" }
1720
gcc = "0.3.27"

src/librustc_llvm/ffi.rs

+29-25
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use debuginfo::{DIBuilderRef, DIDescriptor, DIFile, DILexicalBlock, DISubprogram, DIType,
1212
DIBasicType, DIDerivedType, DICompositeType, DIScope, DIVariable,
1313
DIGlobalVariable, DIArray, DISubrange, DITemplateTypeParameter, DIEnumerator,
14-
DINameSpace};
14+
DINameSpace, DIFlags};
1515

1616
use libc::{c_uint, c_int, size_t, c_char};
1717
use libc::{c_longlong, c_ulonglong, c_void};
@@ -408,7 +408,6 @@ pub enum Visibility {
408408
}
409409

410410
pub mod debuginfo {
411-
pub use self::DIDescriptorFlags::*;
412411
use super::MetadataRef;
413412

414413
#[allow(missing_copy_implementations)]
@@ -433,24 +432,29 @@ pub mod debuginfo {
433432
pub type DIEnumerator = DIDescriptor;
434433
pub type DITemplateTypeParameter = DIDescriptor;
435434

436-
#[derive(Copy, Clone)]
437-
pub enum DIDescriptorFlags {
438-
FlagPrivate = 1 << 0,
439-
FlagProtected = 1 << 1,
440-
FlagFwdDecl = 1 << 2,
441-
FlagAppleBlock = 1 << 3,
442-
FlagBlockByrefStruct = 1 << 4,
443-
FlagVirtual = 1 << 5,
444-
FlagArtificial = 1 << 6,
445-
FlagExplicit = 1 << 7,
446-
FlagPrototyped = 1 << 8,
447-
FlagObjcClassComplete = 1 << 9,
448-
FlagObjectPointer = 1 << 10,
449-
FlagVector = 1 << 11,
450-
FlagStaticMember = 1 << 12,
451-
FlagIndirectVariable = 1 << 13,
452-
FlagLValueReference = 1 << 14,
453-
FlagRValueReference = 1 << 15,
435+
// These values **must** match with LLVMRustDIFlags!!
436+
bitflags! {
437+
#[repr(C)]
438+
#[derive(Debug, Default)]
439+
flags DIFlags: ::libc::uint32_t {
440+
const FlagZero = 0,
441+
const FlagPrivate = 1,
442+
const FlagProtected = 2,
443+
const FlagPublic = 3,
444+
const FlagFwdDecl = (1 << 2),
445+
const FlagAppleBlock = (1 << 3),
446+
const FlagBlockByrefStruct = (1 << 4),
447+
const FlagVirtual = (1 << 5),
448+
const FlagArtificial = (1 << 6),
449+
const FlagExplicit = (1 << 7),
450+
const FlagPrototyped = (1 << 8),
451+
const FlagObjcClassComplete = (1 << 9),
452+
const FlagObjectPointer = (1 << 10),
453+
const FlagVector = (1 << 11),
454+
const FlagStaticMember = (1 << 12),
455+
const FlagLValueReference = (1 << 13),
456+
const FlagRValueReference = (1 << 14),
457+
}
454458
}
455459
}
456460

@@ -1343,7 +1347,7 @@ extern "C" {
13431347
isLocalToUnit: bool,
13441348
isDefinition: bool,
13451349
ScopeLine: c_uint,
1346-
Flags: c_uint,
1350+
Flags: DIFlags,
13471351
isOptimized: bool,
13481352
Fn: ValueRef,
13491353
TParam: DIArray,
@@ -1371,7 +1375,7 @@ extern "C" {
13711375
LineNumber: c_uint,
13721376
SizeInBits: u64,
13731377
AlignInBits: u64,
1374-
Flags: c_uint,
1378+
Flags: DIFlags,
13751379
DerivedFrom: DIType,
13761380
Elements: DIArray,
13771381
RunTimeLang: c_uint,
@@ -1387,7 +1391,7 @@ extern "C" {
13871391
SizeInBits: u64,
13881392
AlignInBits: u64,
13891393
OffsetInBits: u64,
1390-
Flags: c_uint,
1394+
Flags: DIFlags,
13911395
Ty: DIType)
13921396
-> DIDerivedType;
13931397

@@ -1423,7 +1427,7 @@ extern "C" {
14231427
LineNo: c_uint,
14241428
Ty: DIType,
14251429
AlwaysPreserve: bool,
1426-
Flags: c_uint,
1430+
Flags: DIFlags,
14271431
ArgNo: c_uint)
14281432
-> DIVariable;
14291433

@@ -1483,7 +1487,7 @@ extern "C" {
14831487
LineNumber: c_uint,
14841488
SizeInBits: u64,
14851489
AlignInBits: u64,
1486-
Flags: c_uint,
1490+
Flags: DIFlags,
14871491
Elements: DIArray,
14881492
RunTimeLang: c_uint,
14891493
UniqueId: *const c_char)

src/librustc_llvm/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@
2929
#![feature(link_args)]
3030
#![feature(linked_from)]
3131
#![feature(staged_api)]
32+
#![cfg_attr(not(stage0), feature(rustc_private))]
3233

3334
extern crate libc;
35+
#[macro_use]
36+
#[no_link]
37+
extern crate rustc_bitflags;
3438

3539
pub use self::IntPredicate::*;
3640
pub use self::RealPredicate::*;

src/librustc_trans/debuginfo/metadata.rs

+17-18
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ use context::SharedCrateContext;
2222
use session::Session;
2323

2424
use llvm::{self, ValueRef};
25-
use llvm::debuginfo::{DIType, DIFile, DIScope, DIDescriptor, DICompositeType, DILexicalBlock};
25+
use llvm::debuginfo::{DIType, DIFile, DIScope, DIDescriptor,
26+
DICompositeType, DILexicalBlock, DIFlags};
2627

2728
use rustc::hir::def::CtorKind;
2829
use rustc::hir::def_id::DefId;
@@ -69,8 +70,6 @@ pub const UNKNOWN_COLUMN_NUMBER: c_uint = 0;
6970
// ptr::null() doesn't work :(
7071
pub const NO_SCOPE_METADATA: DIScope = (0 as DIScope);
7172

72-
const FLAGS_NONE: c_uint = 0;
73-
7473
#[derive(Copy, Debug, Hash, Eq, PartialEq, Clone)]
7574
pub struct UniqueTypeId(ast::Name);
7675

@@ -347,14 +346,14 @@ fn vec_slice_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
347346
llvm_type: member_llvm_types[0],
348347
type_metadata: element_type_metadata,
349348
offset: ComputedMemberOffset,
350-
flags: FLAGS_NONE
349+
flags: DIFlags::FlagZero,
351350
},
352351
MemberDescription {
353352
name: "length".to_string(),
354353
llvm_type: member_llvm_types[1],
355354
type_metadata: type_metadata(cx, cx.tcx().types.usize, span),
356355
offset: ComputedMemberOffset,
357-
flags: FLAGS_NONE
356+
flags: DIFlags::FlagZero,
358357
},
359358
];
360359

@@ -838,7 +837,7 @@ struct MemberDescription {
838837
llvm_type: Type,
839838
type_metadata: DIType,
840839
offset: MemberOffset,
841-
flags: c_uint
840+
flags: DIFlags,
842841
}
843842

844843
// A factory for MemberDescriptions. It produces a list of member descriptions
@@ -922,7 +921,7 @@ impl<'tcx> StructMemberDescriptionFactory<'tcx> {
922921
llvm_type: type_of::type_of(cx, fty),
923922
type_metadata: type_metadata(cx, fty, self.span),
924923
offset: offset,
925-
flags: FLAGS_NONE,
924+
flags: DIFlags::FlagZero,
926925
}
927926
}).collect()
928927
}
@@ -987,7 +986,7 @@ impl<'tcx> TupleMemberDescriptionFactory<'tcx> {
987986
llvm_type: type_of::type_of(cx, component_type),
988987
type_metadata: type_metadata(cx, component_type, self.span),
989988
offset: ComputedMemberOffset,
990-
flags: FLAGS_NONE,
989+
flags: DIFlags::FlagZero,
991990
}
992991
}).collect()
993992
}
@@ -1039,7 +1038,7 @@ impl<'tcx> UnionMemberDescriptionFactory<'tcx> {
10391038
llvm_type: type_of::type_of(cx, fty),
10401039
type_metadata: type_metadata(cx, fty, self.span),
10411040
offset: FixedMemberOffset { bytes: 0 },
1042-
flags: FLAGS_NONE,
1041+
flags: DIFlags::FlagZero,
10431042
}
10441043
}).collect()
10451044
}
@@ -1137,7 +1136,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
11371136
llvm_type: variant_llvm_type,
11381137
type_metadata: variant_type_metadata,
11391138
offset: FixedMemberOffset { bytes: 0 },
1140-
flags: FLAGS_NONE
1139+
flags: DIFlags::FlagZero
11411140
}
11421141
}).collect()
11431142
},
@@ -1171,7 +1170,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
11711170
llvm_type: variant_llvm_type,
11721171
type_metadata: variant_type_metadata,
11731172
offset: FixedMemberOffset { bytes: 0 },
1174-
flags: FLAGS_NONE
1173+
flags: DIFlags::FlagZero
11751174
}
11761175
]
11771176
}
@@ -1208,7 +1207,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
12081207
llvm_type: non_null_llvm_type,
12091208
type_metadata: non_null_type_metadata,
12101209
offset: FixedMemberOffset { bytes: 0 },
1211-
flags: FLAGS_NONE
1210+
flags: DIFlags::FlagZero
12121211
};
12131212

12141213
let unique_type_id = debug_context(cx).type_map
@@ -1245,7 +1244,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
12451244
llvm_type: artificial_struct_llvm_type,
12461245
type_metadata: artificial_struct_metadata,
12471246
offset: FixedMemberOffset { bytes: 0 },
1248-
flags: FLAGS_NONE
1247+
flags: DIFlags::FlagZero
12491248
}
12501249
]
12511250
},
@@ -1289,7 +1288,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
12891288
llvm_type: variant_llvm_type,
12901289
type_metadata: variant_type_metadata,
12911290
offset: FixedMemberOffset { bytes: 0 },
1292-
flags: FLAGS_NONE
1291+
flags: DIFlags::FlagZero
12931292
}
12941293
]
12951294
},
@@ -1318,7 +1317,7 @@ impl<'tcx> VariantMemberDescriptionFactory<'tcx> {
13181317
_ => type_metadata(cx, ty, self.span)
13191318
},
13201319
offset: ComputedMemberOffset,
1321-
flags: FLAGS_NONE
1320+
flags: DIFlags::FlagZero
13221321
}
13231322
}).collect()
13241323
}
@@ -1535,7 +1534,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
15351534
UNKNOWN_LINE_NUMBER,
15361535
bytes_to_bits(enum_type_size),
15371536
bytes_to_bits(enum_type_align),
1538-
0, // Flags
1537+
DIFlags::FlagZero,
15391538
ptr::null_mut(),
15401539
0, // RuntimeLang
15411540
unique_type_id_str.as_ptr())
@@ -1680,7 +1679,7 @@ fn create_struct_stub(cx: &CrateContext,
16801679
UNKNOWN_LINE_NUMBER,
16811680
bytes_to_bits(struct_size),
16821681
bytes_to_bits(struct_align),
1683-
0,
1682+
DIFlags::FlagZero,
16841683
ptr::null_mut(),
16851684
empty_array,
16861685
0,
@@ -1717,7 +1716,7 @@ fn create_union_stub(cx: &CrateContext,
17171716
UNKNOWN_LINE_NUMBER,
17181717
bytes_to_bits(union_size),
17191718
bytes_to_bits(union_align),
1720-
0, // Flags
1719+
DIFlags::FlagZero,
17211720
empty_array,
17221721
0, // RuntimeLang
17231722
unique_type_id.as_ptr())

src/librustc_trans/debuginfo/mod.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ use self::source_loc::InternalDebugLocation::{self, UnknownLocation};
2222

2323
use llvm;
2424
use llvm::{ModuleRef, ContextRef, ValueRef};
25-
use llvm::debuginfo::{DIFile, DIType, DIScope, DIBuilderRef, DISubprogram, DIArray,
26-
FlagPrototyped};
25+
use llvm::debuginfo::{DIFile, DIType, DIScope, DIBuilderRef, DISubprogram, DIArray, DIFlags};
2726
use rustc::hir::def_id::DefId;
2827
use rustc::ty::subst::Substs;
2928

@@ -286,7 +285,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
286285
is_local_to_unit,
287286
true,
288287
scope_line as c_uint,
289-
FlagPrototyped as c_uint,
288+
DIFlags::FlagPrototyped,
290289
cx.sess().opts.optimize != config::OptLevel::No,
291290
llfn,
292291
template_parameters,
@@ -478,7 +477,7 @@ pub fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
478477
loc.line as c_uint,
479478
type_metadata,
480479
cx.sess().opts.optimize != config::OptLevel::No,
481-
0,
480+
DIFlags::FlagZero,
482481
argument_index)
483482
};
484483
source_loc::set_debug_location(cx, None,

0 commit comments

Comments
 (0)