Skip to content

Commit

Permalink
Auto merge of rust-lang#722 - emilio:mangling-panic, r=fitzgen
Browse files Browse the repository at this point in the history
ir: Don't panic when finding an unknown calling convention until code generation

This unblocks stylo in windows until we get `__thiscall` support in syntex. see rust-lang#541.
  • Loading branch information
bors-servo authored May 26, 2017
2 parents c160b3d + f2c2b78 commit 3798bc7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2869,7 +2869,7 @@ impl TryToRustTy for FunctionSig {

let fnty = ast::TyKind::BareFn(P(ast::BareFnTy {
unsafety: ast::Unsafety::Unsafe,
abi: self.abi().expect("Invalid abi for function!"),
abi: self.abi().expect("Invalid or unknown ABI for function!"),
lifetimes: vec![],
decl: decl,
}));
Expand Down Expand Up @@ -2950,7 +2950,7 @@ impl CodeGenerator for Function {
};

let item = ForeignModBuilder::new(signature.abi()
.expect("Invalid abi for function!"))
.expect("Invalid or unknown ABI for function!"))
.with_foreign_item(foreign_item)
.build(ctx);

Expand Down
10 changes: 4 additions & 6 deletions src/ir/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ fn get_abi(cc: CXCallingConv) -> Option<abi::Abi> {
CXCallingConv_X86FastCall => Some(abi::Abi::Fastcall),
CXCallingConv_AAPCS => Some(abi::Abi::Aapcs),
CXCallingConv_X86_64Win64 => Some(abi::Abi::Win64),
CXCallingConv_Invalid => None,
other => panic!("unsupported calling convention: {:?}", other),
_ => None,
}
}

Expand Down Expand Up @@ -297,12 +296,11 @@ impl FunctionSig {
try!(ty.ret_type().ok_or(ParseError::Continue))
};
let ret = Item::from_ty_or_ref(ty_ret_type, cursor, None, ctx);
let abi = get_abi(ty.call_conv());
let call_conv = ty.call_conv();
let abi = get_abi(call_conv);

if abi.is_none() {
assert!(cursor.kind() == CXCursor_ObjCInstanceMethodDecl ||
cursor.kind() == CXCursor_ObjCClassMethodDecl,
"Invalid ABI for function signature")
warn!("Unknown calling convention: {:?}", call_conv);
}

Ok(Self::new(ret, args, ty.is_variadic(), abi))
Expand Down

0 comments on commit 3798bc7

Please sign in to comment.