File tree 2 files changed +33
-1
lines changed
librustc_codegen_llvm/debuginfo
2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -1780,14 +1780,19 @@ fn prepare_enum_metadata(
1780
1780
. zip ( & def. variants )
1781
1781
. map ( |( ( _, discr) , v) | {
1782
1782
let name = v. ident . as_str ( ) ;
1783
+ let is_unsigned = match discr. ty . kind {
1784
+ ty:: Int ( _) => false ,
1785
+ ty:: Uint ( _) => true ,
1786
+ _ => bug ! ( "non integer discriminant" ) ,
1787
+ } ;
1783
1788
unsafe {
1784
1789
Some ( llvm:: LLVMRustDIBuilderCreateEnumerator (
1785
1790
DIB ( cx) ,
1786
1791
name. as_ptr ( ) . cast ( ) ,
1787
1792
name. len ( ) ,
1788
1793
// FIXME: what if enumeration has i128 discriminant?
1789
1794
discr. val as i64 ,
1790
- false , // FIXME: IsUnsigned.
1795
+ is_unsigned ,
1791
1796
) )
1792
1797
}
1793
1798
} )
Original file line number Diff line number Diff line change
1
+ // Verify that DIEnumerator uses isUnsigned flag when appropriate.
2
+ //
3
+ // compile-flags: -g -C no-prepopulate-passes
4
+
5
+ #[ repr( i64 ) ]
6
+ pub enum I64 {
7
+ I64Min = std:: i64:: MIN ,
8
+ I64Max = std:: i64:: MAX ,
9
+ }
10
+
11
+ #[ repr( u64 ) ]
12
+ pub enum U64 {
13
+ U64Min = std:: u64:: MIN ,
14
+ U64Max = std:: u64:: MAX ,
15
+ }
16
+
17
+ fn main ( ) {
18
+ let _a = I64 :: I64Min ;
19
+ let _b = I64 :: I64Max ;
20
+ let _c = U64 :: U64Min ;
21
+ let _d = U64 :: U64Max ;
22
+ }
23
+
24
+ // CHECK: !DIEnumerator(name: "I64Min", value: -9223372036854775808)
25
+ // CHECK: !DIEnumerator(name: "I64Max", value: 9223372036854775807)
26
+ // CHECK: !DIEnumerator(name: "U64Min", value: 0, isUnsigned: true)
27
+ // CHECK: !DIEnumerator(name: "U64Max", value: 18446744073709551615, isUnsigned: true)
You can’t perform that action at this time.
0 commit comments