-
Notifications
You must be signed in to change notification settings - Fork 698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rustified_enum doesn't work with anonymous enums #1161
Comments
I'm 99% sure this is a dupe of #1125. |
So shall we close this issue? Any reason you wanted to leave it open? |
It's not clear to me that this is a dupe; maybe just leave it open and I'll investigate once #1125 is closed. |
OK, so #1162 didn't fix this for me, at least not the way I'm (naively) trying to use this. However, looking closer, I'm not really sure what the semantics here are. The C++ code is roughly: namespace llvm {
namespace CallingConv {
using ID = unsigned;
enum {
C = 0,
Fast = 8,
....
MaxID = 1023
};
} // end namespace CallingConv
} // end namespace llvm My C++ is pretty nascent, so I'm not really sure what this code does, but it looks like it just declares a bunch of integral constants and not a true enum. From my perspective, it would be nice to be able to make this a rustified enum, but I'm quite certain that's not currently a feature of bindgen. @emilio? |
eh, I misspoke - this is weird. This doesn't work if I pass /// LLVM IR allows to use arbitrary numbers as calling convention identifiers.
pub type llvm_CallingConv_ID = ::std::os::raw::c_uint;
pub const C: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::C;
pub const Fast: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::Fast;
pub const Cold: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::Cold;
pub const GHC: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::GHC;
pub const HiPE: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::HiPE;
pub const WebKit_JS: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::WebKit_JS;
pub const AnyReg: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::AnyReg;
pub const PreserveMost: llvm_CallingConv__bindgen_ty_1 =
llvm_CallingConv__bindgen_ty_1::PreserveMost;
pub const PreserveAll: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::PreserveAll;
pub const Swift: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::Swift;
pub const CXX_FAST_TLS: llvm_CallingConv__bindgen_ty_1 =
llvm_CallingConv__bindgen_ty_1::CXX_FAST_TLS;
pub const FirstTargetCC: llvm_CallingConv__bindgen_ty_1 =
llvm_CallingConv__bindgen_ty_1::FirstTargetCC;
pub const X86_StdCall: llvm_CallingConv__bindgen_ty_1 =
llvm_CallingConv__bindgen_ty_1::FirstTargetCC;
pub const X86_FastCall: llvm_CallingConv__bindgen_ty_1 =
llvm_CallingConv__bindgen_ty_1::X86_FastCall;
pub const ARM_APCS: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::ARM_APCS;
pub const ARM_AAPCS: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::ARM_AAPCS;
pub const ARM_AAPCS_VFP: llvm_CallingConv__bindgen_ty_1 =
llvm_CallingConv__bindgen_ty_1::ARM_AAPCS_VFP;
pub const MSP430_INTR: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::MSP430_INTR;
pub const X86_ThisCall: llvm_CallingConv__bindgen_ty_1 =
llvm_CallingConv__bindgen_ty_1::X86_ThisCall;
pub const PTX_Kernel: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::PTX_Kernel;
pub const PTX_Device: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::PTX_Device;
pub const SPIR_FUNC: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::SPIR_FUNC;
pub const SPIR_KERNEL: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::SPIR_KERNEL;
pub const Intel_OCL_BI: llvm_CallingConv__bindgen_ty_1 =
llvm_CallingConv__bindgen_ty_1::Intel_OCL_BI;
pub const X86_64_SysV: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::X86_64_SysV;
pub const X86_64_Win64: llvm_CallingConv__bindgen_ty_1 =
llvm_CallingConv__bindgen_ty_1::X86_64_Win64;
pub const X86_VectorCall: llvm_CallingConv__bindgen_ty_1 =
llvm_CallingConv__bindgen_ty_1::X86_VectorCall;
pub const HHVM: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::HHVM;
pub const HHVM_C: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::HHVM_C;
pub const X86_INTR: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::X86_INTR;
pub const AVR_INTR: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::AVR_INTR;
pub const AVR_SIGNAL: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::AVR_SIGNAL;
pub const AVR_BUILTIN: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::AVR_BUILTIN;
pub const AMDGPU_VS: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::AMDGPU_VS;
pub const AMDGPU_GS: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::AMDGPU_GS;
pub const AMDGPU_PS: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::AMDGPU_PS;
pub const AMDGPU_CS: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::AMDGPU_CS;
pub const AMDGPU_KERNEL: llvm_CallingConv__bindgen_ty_1 =
llvm_CallingConv__bindgen_ty_1::AMDGPU_KERNEL;
pub const X86_RegCall: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::X86_RegCall;
pub const MSP430_BUILTIN: llvm_CallingConv__bindgen_ty_1 =
llvm_CallingConv__bindgen_ty_1::MSP430_BUILTIN;
pub const MaxID: llvm_CallingConv__bindgen_ty_1 = llvm_CallingConv__bindgen_ty_1::MaxID;
#[repr(u32)]
/// A set of enums which specify the assigned numeric values for known llvm
/// /// calling conventions.
/// /// @brief LLVM Calling Convention Representation
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum llvm_CallingConv__bindgen_ty_1 {
C = 0,
Fast = 8,
Cold = 9,
GHC = 10,
HiPE = 11,
WebKit_JS = 12,
AnyReg = 13,
PreserveMost = 14,
PreserveAll = 15,
Swift = 16,
CXX_FAST_TLS = 17,
FirstTargetCC = 64,
X86_FastCall = 65,
ARM_APCS = 66,
ARM_AAPCS = 67,
ARM_AAPCS_VFP = 68,
MSP430_INTR = 69,
X86_ThisCall = 70,
PTX_Kernel = 71,
PTX_Device = 72,
SPIR_FUNC = 75,
SPIR_KERNEL = 76,
Intel_OCL_BI = 77,
X86_64_SysV = 78,
X86_64_Win64 = 79,
X86_VectorCall = 80,
HHVM = 81,
HHVM_C = 82,
X86_INTR = 83,
AVR_INTR = 84,
AVR_SIGNAL = 85,
AVR_BUILTIN = 86,
AMDGPU_VS = 87,
AMDGPU_GS = 88,
AMDGPU_PS = 89,
AMDGPU_CS = 90,
AMDGPU_KERNEL = 91,
X86_RegCall = 92,
MSP430_BUILTIN = 94,
MaxID = 1023,
} In other words, I get both the rustified enum and all the constants. |
This is the expected behavior. Whenever there is an explicit value given to an enum variant, we also make a constant (if I remember the rules correctly). I think we can close this issue, unless I am overlooking something. |
I wasn't complaining about the generated code, I was just saying that the rules for matching this enum are not clear. Why do I need to use a wildcard? Separately, I do have a complaint about the generated code: take a look at |
Input C/C++ Header
https://github.com/llvm-mirror/llvm/blob/master/include/llvm/IR/CallingConv.h
Bindgen Invocation
Actual Results
Expected Results
A Rust enum resembling:
The text was updated successfully, but these errors were encountered: