Skip to content

Commit c86b470

Browse files
committed
Denote defaulted functions.
1 parent edc8b7f commit c86b470

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/codegen/helpers.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ pub trait CppSemanticAttributeCreator {
166166
self.add_ident("deleted")
167167
}
168168

169+
fn defaulted_fn(&mut self) {
170+
self.add_ident("defaulted")
171+
}
172+
169173
fn layout(&mut self, layout: &Layout) {
170174
let sz = ast_ty::int_expr(layout.size as i64);
171175
let align = ast_ty::int_expr(layout.align as i64);

src/codegen/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4281,6 +4281,9 @@ impl CodeGenerator for Function {
42814281
if self.deleted_fn() {
42824282
semantic_annotations.deleted_fn();
42834283
}
4284+
if self.defaulted_fn() {
4285+
semantic_annotations.defaulted_fn();
4286+
}
42844287

42854288
let link_name = mangled_name.unwrap_or(name);
42864289
if !is_dynamic_function &&

src/ir/function.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,11 @@ pub struct Function {
123123
/// C++ visibility
124124
visibility: Visibility,
125125

126-
/// Whether it's deleted (=default)
126+
/// Whether it's deleted (=delete)
127127
is_deleted: bool,
128+
129+
/// Whether it's explicitly defaulted (=default)
130+
is_defaulted: bool,
128131
}
129132

130133
impl Function {
@@ -139,6 +142,7 @@ impl Function {
139142
special_member: Option<SpecialMemberKind>,
140143
visibility: Visibility,
141144
is_deleted: bool,
145+
is_defaulted: bool,
142146
) -> Self {
143147
Function {
144148
name,
@@ -150,6 +154,7 @@ impl Function {
150154
special_member,
151155
visibility,
152156
is_deleted,
157+
is_defaulted,
153158
}
154159
}
155160

@@ -197,6 +202,11 @@ impl Function {
197202
pub fn deleted_fn(&self) -> bool {
198203
self.is_deleted
199204
}
205+
206+
/// Whether this is a function that's been deleted (=delete)
207+
pub fn defaulted_fn(&self) -> bool {
208+
self.is_defaulted
209+
}
200210
}
201211

202212
impl DotAttributes for Function {
@@ -722,6 +732,7 @@ impl ClangSubItemParser for Function {
722732
special_member,
723733
visibility,
724734
cursor.is_deleted_function(),
735+
cursor.is_defaulted_function(),
725736
);
726737
Ok(ParseResult::New(function, Some(cursor)))
727738
}

0 commit comments

Comments
 (0)