diff options
author | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2023-02-07 15:14:26 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-07 15:14:26 +0000 |
commit | 75ec12d1bb5f8b2e83d0548edd9982a1e7746639 (patch) | |
tree | c2775e75c393aab280598bb763db52d4859ccc3d /bindgen/ir/function.rs | |
parent | 3267ffc1ba88578607e0ea584896f2f1141cedf9 (diff) | |
parent | 2be14a33451b0259bfed8e0fe517502e46fab7b6 (diff) |
Diffstat (limited to 'bindgen/ir/function.rs')
-rw-r--r-- | bindgen/ir/function.rs | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/bindgen/ir/function.rs b/bindgen/ir/function.rs index 8e83d980..baa2c36c 100644 --- a/bindgen/ir/function.rs +++ b/bindgen/ir/function.rs @@ -664,7 +664,6 @@ impl ClangSubItemParser for Function { }; debug!("Function::parse({:?}, {:?})", cursor, cursor.cur_type()); - let visibility = cursor.visibility(); if visibility != CXVisibility_Default { return Err(ParseError::Continue); @@ -674,25 +673,36 @@ impl ClangSubItemParser for Function { return Err(ParseError::Continue); } + let linkage = cursor.linkage(); + let linkage = match linkage { + CXLinkage_External | CXLinkage_UniqueExternal => Linkage::External, + CXLinkage_Internal => Linkage::Internal, + _ => return Err(ParseError::Continue), + }; + if cursor.is_inlined_function() || cursor .definition() .map_or(false, |x| x.is_inlined_function()) { - if !context.options().generate_inline_functions { + if !context.options().generate_inline_functions && + !context.options().wrap_static_fns + { return Err(ParseError::Continue); } + if cursor.is_deleted_function() { return Err(ParseError::Continue); } - } - let linkage = cursor.linkage(); - let linkage = match linkage { - CXLinkage_External | CXLinkage_UniqueExternal => Linkage::External, - CXLinkage_Internal => Linkage::Internal, - _ => return Err(ParseError::Continue), - }; + // We cannot handle `inline` functions that are not `static`. + if context.options().wrap_static_fns && + cursor.is_inlined_function() && + matches!(linkage, Linkage::External) + { + return Err(ParseError::Continue); + } + } // Grab the signature using Item::from_ty. let sig = Item::from_ty(&cursor.cur_type(), cursor, None, context)?; @@ -727,7 +737,8 @@ impl ClangSubItemParser for Function { let comment = cursor.raw_comment(); let function = - Self::new(name, mangled_name, sig, comment, kind, linkage); + Self::new(name.clone(), mangled_name, sig, comment, kind, linkage); + Ok(ParseResult::New(function, Some(cursor))) } } |