@@ -37,13 +37,40 @@ pub enum MethodKind {
37
37
/// A destructor.
38
38
Destructor ,
39
39
/// A virtual destructor.
40
- VirtualDestructor ,
40
+ VirtualDestructor {
41
+ /// Whether it's pure virtual.
42
+ pure_virtual : bool ,
43
+ } ,
41
44
/// A static method.
42
45
Static ,
43
46
/// A normal method.
44
47
Normal ,
45
48
/// A virtual method.
46
- Virtual ,
49
+ Virtual {
50
+ /// Whether it's pure virtual.
51
+ pure_virtual : bool ,
52
+ } ,
53
+ }
54
+
55
+
56
+ impl MethodKind {
57
+ /// Is this a destructor method?
58
+ pub fn is_destructor ( & self ) -> bool {
59
+ match * self {
60
+ MethodKind :: Destructor |
61
+ MethodKind :: VirtualDestructor { .. } => true ,
62
+ _ => false ,
63
+ }
64
+ }
65
+
66
+ /// Is this a pure virtual method?
67
+ pub fn is_pure_virtual ( & self ) -> bool {
68
+ match * self {
69
+ MethodKind :: Virtual { pure_virtual } |
70
+ MethodKind :: VirtualDestructor { pure_virtual } => pure_virtual,
71
+ _ => false ,
72
+ }
73
+ }
47
74
}
48
75
49
76
/// A struct representing a C++ method, either static, normal, or virtual.
@@ -73,21 +100,18 @@ impl Method {
73
100
self . kind
74
101
}
75
102
76
- /// Is this a destructor method?
77
- pub fn is_destructor ( & self ) -> bool {
78
- self . kind == MethodKind :: Destructor ||
79
- self . kind == MethodKind :: VirtualDestructor
80
- }
81
-
82
103
/// Is this a constructor?
83
104
pub fn is_constructor ( & self ) -> bool {
84
105
self . kind == MethodKind :: Constructor
85
106
}
86
107
87
108
/// Is this a virtual method?
88
109
pub fn is_virtual ( & self ) -> bool {
89
- self . kind == MethodKind :: Virtual ||
90
- self . kind == MethodKind :: VirtualDestructor
110
+ match self . kind {
111
+ MethodKind :: Virtual { .. } |
112
+ MethodKind :: VirtualDestructor { .. } => true ,
113
+ _ => false ,
114
+ }
91
115
}
92
116
93
117
/// Is this a static method?
@@ -960,7 +984,7 @@ pub struct CompInfo {
960
984
961
985
/// The destructor of this type. The bool represents whether this destructor
962
986
/// is virtual.
963
- destructor : Option < ( bool , FunctionId ) > ,
987
+ destructor : Option < ( MethodKind , FunctionId ) > ,
964
988
965
989
/// Vector of classes this one inherits from.
966
990
base_members : Vec < Base > ,
@@ -1104,7 +1128,7 @@ impl CompInfo {
1104
1128
}
1105
1129
1106
1130
/// Get this type's destructor.
1107
- pub fn destructor ( & self ) -> Option < ( bool , FunctionId ) > {
1131
+ pub fn destructor ( & self ) -> Option < ( MethodKind , FunctionId ) > {
1108
1132
self . destructor
1109
1133
}
1110
1134
@@ -1355,14 +1379,23 @@ impl CompInfo {
1355
1379
ci. constructors . push ( signature) ;
1356
1380
}
1357
1381
CXCursor_Destructor => {
1358
- ci. destructor = Some ( ( is_virtual, signature) ) ;
1382
+ let kind = if is_virtual {
1383
+ MethodKind :: VirtualDestructor {
1384
+ pure_virtual : cur. method_is_pure_virtual ( ) ,
1385
+ }
1386
+ } else {
1387
+ MethodKind :: Destructor
1388
+ } ;
1389
+ ci. destructor = Some ( ( kind, signature) ) ;
1359
1390
}
1360
1391
CXCursor_CXXMethod => {
1361
1392
let is_const = cur. method_is_const ( ) ;
1362
1393
let method_kind = if is_static {
1363
1394
MethodKind :: Static
1364
1395
} else if is_virtual {
1365
- MethodKind :: Virtual
1396
+ MethodKind :: Virtual {
1397
+ pure_virtual : cur. method_is_pure_virtual ( ) ,
1398
+ }
1366
1399
} else {
1367
1400
MethodKind :: Normal
1368
1401
} ;
@@ -1658,11 +1691,11 @@ impl Trace for CompInfo {
1658
1691
}
1659
1692
1660
1693
for method in self . methods ( ) {
1661
- if method. is_destructor ( ) {
1662
- tracer . visit_kind ( method . signature . into ( ) , EdgeKind :: Destructor ) ;
1663
- } else {
1664
- tracer . visit_kind ( method . signature . into ( ) , EdgeKind :: Method ) ;
1665
- }
1694
+ tracer . visit_kind ( method. signature . into ( ) , EdgeKind :: Method ) ;
1695
+ }
1696
+
1697
+ if let Some ( ( _kind , signature ) ) = self . destructor ( ) {
1698
+ tracer . visit_kind ( signature . into ( ) , EdgeKind :: Destructor ) ;
1666
1699
}
1667
1700
1668
1701
for ctor in self . constructors ( ) {
0 commit comments