@@ -32,7 +32,9 @@ use crate::ir::derive::{
32
32
} ;
33
33
use crate :: ir:: dot;
34
34
use crate :: ir:: enum_ty:: { Enum , EnumVariant , EnumVariantValue } ;
35
- use crate :: ir:: function:: { Abi , Function , FunctionKind , FunctionSig , Linkage } ;
35
+ use crate :: ir:: function:: {
36
+ Abi , ClangAbi , Function , FunctionKind , FunctionSig , Linkage ,
37
+ } ;
36
38
use crate :: ir:: int:: IntKind ;
37
39
use crate :: ir:: item:: { IsOpaque , Item , ItemCanonicalName , ItemCanonicalPath } ;
38
40
use crate :: ir:: item_kind:: ItemKind ;
@@ -2474,9 +2476,13 @@ impl MethodCodegen for Method {
2474
2476
_ => panic ! ( "How in the world?" ) ,
2475
2477
} ;
2476
2478
2477
- let supported_abi = match signature. abi ( ) {
2478
- Abi :: ThisCall => ctx. options ( ) . rust_features ( ) . thiscall_abi ,
2479
- Abi :: Vectorcall => ctx. options ( ) . rust_features ( ) . vectorcall_abi ,
2479
+ let supported_abi = match signature. abi ( ctx, Some ( & * name) ) {
2480
+ ClangAbi :: Known ( Abi :: ThisCall ) => {
2481
+ ctx. options ( ) . rust_features ( ) . thiscall_abi
2482
+ }
2483
+ ClangAbi :: Known ( Abi :: Vectorcall ) => {
2484
+ ctx. options ( ) . rust_features ( ) . vectorcall_abi
2485
+ }
2480
2486
_ => true ,
2481
2487
} ;
2482
2488
@@ -3988,14 +3994,16 @@ impl TryToRustTy for FunctionSig {
3988
3994
// TODO: we might want to consider ignoring the reference return value.
3989
3995
let ret = utils:: fnsig_return_ty ( ctx, self ) ;
3990
3996
let arguments = utils:: fnsig_arguments ( ctx, self ) ;
3991
- let abi = self . abi ( ) ;
3997
+ let abi = self . abi ( ctx , None ) ;
3992
3998
3993
3999
match abi {
3994
- Abi :: ThisCall if !ctx. options ( ) . rust_features ( ) . thiscall_abi => {
4000
+ ClangAbi :: Known ( Abi :: ThisCall )
4001
+ if !ctx. options ( ) . rust_features ( ) . thiscall_abi =>
4002
+ {
3995
4003
warn ! ( "Skipping function with thiscall ABI that isn't supported by the configured Rust target" ) ;
3996
4004
Ok ( proc_macro2:: TokenStream :: new ( ) )
3997
4005
}
3998
- Abi :: Vectorcall
4006
+ ClangAbi :: Known ( Abi :: Vectorcall )
3999
4007
if !ctx. options ( ) . rust_features ( ) . vectorcall_abi =>
4000
4008
{
4001
4009
warn ! ( "Skipping function with vectorcall ABI that isn't supported by the configured Rust target" ) ;
@@ -4099,22 +4107,24 @@ impl CodeGenerator for Function {
4099
4107
attributes. push ( attributes:: doc ( comment) ) ;
4100
4108
}
4101
4109
4102
- let abi = match signature. abi ( ) {
4103
- Abi :: ThisCall if !ctx. options ( ) . rust_features ( ) . thiscall_abi => {
4110
+ let abi = match signature. abi ( ctx, Some ( name) ) {
4111
+ ClangAbi :: Known ( Abi :: ThisCall )
4112
+ if !ctx. options ( ) . rust_features ( ) . thiscall_abi =>
4113
+ {
4104
4114
warn ! ( "Skipping function with thiscall ABI that isn't supported by the configured Rust target" ) ;
4105
4115
return None ;
4106
4116
}
4107
- Abi :: Vectorcall
4117
+ ClangAbi :: Known ( Abi :: Vectorcall )
4108
4118
if !ctx. options ( ) . rust_features ( ) . vectorcall_abi =>
4109
4119
{
4110
4120
warn ! ( "Skipping function with vectorcall ABI that isn't supported by the configured Rust target" ) ;
4111
4121
return None ;
4112
4122
}
4113
- Abi :: Win64 if signature. is_variadic ( ) => {
4123
+ ClangAbi :: Known ( Abi :: Win64 ) if signature. is_variadic ( ) => {
4114
4124
warn ! ( "Skipping variadic function with Win64 ABI that isn't supported" ) ;
4115
4125
return None ;
4116
4126
}
4117
- Abi :: Unknown ( unknown_abi) => {
4127
+ ClangAbi :: Unknown ( unknown_abi) => {
4118
4128
panic ! (
4119
4129
"Invalid or unknown abi {:?} for function {:?} ({:?})" ,
4120
4130
unknown_abi, canonical_name, self
@@ -4512,7 +4522,7 @@ pub(crate) fn codegen(
4512
4522
pub mod utils {
4513
4523
use super :: { error, ToRustTyOrOpaque } ;
4514
4524
use crate :: ir:: context:: BindgenContext ;
4515
- use crate :: ir:: function:: { Abi , FunctionSig } ;
4525
+ use crate :: ir:: function:: { Abi , ClangAbi , FunctionSig } ;
4516
4526
use crate :: ir:: item:: { Item , ItemCanonicalPath } ;
4517
4527
use crate :: ir:: ty:: TypeKind ;
4518
4528
use proc_macro2;
@@ -4973,10 +4983,10 @@ pub mod utils {
4973
4983
// Returns true if `canonical_name` will end up as `mangled_name` at the
4974
4984
// machine code level, i.e. after LLVM has applied any target specific
4975
4985
// mangling.
4976
- pub fn names_will_be_identical_after_mangling (
4986
+ pub ( crate ) fn names_will_be_identical_after_mangling (
4977
4987
canonical_name : & str ,
4978
4988
mangled_name : & str ,
4979
- call_conv : Option < Abi > ,
4989
+ call_conv : Option < ClangAbi > ,
4980
4990
) -> bool {
4981
4991
// If the mangled name and the canonical name are the same then no
4982
4992
// mangling can have happened between the two versions.
@@ -4989,13 +4999,13 @@ pub mod utils {
4989
4999
let mangled_name = mangled_name. as_bytes ( ) ;
4990
5000
4991
5001
let ( mangling_prefix, expect_suffix) = match call_conv {
4992
- Some ( Abi :: C ) |
5002
+ Some ( ClangAbi :: Known ( Abi :: C ) ) |
4993
5003
// None is the case for global variables
4994
5004
None => {
4995
5005
( b'_' , false )
4996
5006
}
4997
- Some ( Abi :: Stdcall ) => ( b'_' , true ) ,
4998
- Some ( Abi :: Fastcall ) => ( b'@' , true ) ,
5007
+ Some ( ClangAbi :: Known ( Abi :: Stdcall ) ) => ( b'_' , true ) ,
5008
+ Some ( ClangAbi :: Known ( Abi :: Fastcall ) ) => ( b'@' , true ) ,
4999
5009
5000
5010
// This is something we don't recognize, stay on the safe side
5001
5011
// by emitting the `#[link_name]` attribute
0 commit comments