Skip to content

Commit 3798bc7

Browse files
author
bors-servo
authored
Auto merge of rust-lang#722 - emilio:mangling-panic, r=fitzgen
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.
2 parents c160b3d + f2c2b78 commit 3798bc7

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/codegen/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2869,7 +2869,7 @@ impl TryToRustTy for FunctionSig {
28692869

28702870
let fnty = ast::TyKind::BareFn(P(ast::BareFnTy {
28712871
unsafety: ast::Unsafety::Unsafe,
2872-
abi: self.abi().expect("Invalid abi for function!"),
2872+
abi: self.abi().expect("Invalid or unknown ABI for function!"),
28732873
lifetimes: vec![],
28742874
decl: decl,
28752875
}));
@@ -2950,7 +2950,7 @@ impl CodeGenerator for Function {
29502950
};
29512951

29522952
let item = ForeignModBuilder::new(signature.abi()
2953-
.expect("Invalid abi for function!"))
2953+
.expect("Invalid or unknown ABI for function!"))
29542954
.with_foreign_item(foreign_item)
29552955
.build(ctx);
29562956

src/ir/function.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ fn get_abi(cc: CXCallingConv) -> Option<abi::Abi> {
105105
CXCallingConv_X86FastCall => Some(abi::Abi::Fastcall),
106106
CXCallingConv_AAPCS => Some(abi::Abi::Aapcs),
107107
CXCallingConv_X86_64Win64 => Some(abi::Abi::Win64),
108-
CXCallingConv_Invalid => None,
109-
other => panic!("unsupported calling convention: {:?}", other),
108+
_ => None,
110109
}
111110
}
112111

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

302302
if abi.is_none() {
303-
assert!(cursor.kind() == CXCursor_ObjCInstanceMethodDecl ||
304-
cursor.kind() == CXCursor_ObjCClassMethodDecl,
305-
"Invalid ABI for function signature")
303+
warn!("Unknown calling convention: {:?}", call_conv);
306304
}
307305

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

0 commit comments

Comments
 (0)