1
Fork 0

rustc_codegen_llvm: move from empty enums to extern types.

This commit is contained in:
Irina Popa 2018-06-27 13:12:47 +03:00
parent 077be49bde
commit af04e9426c
18 changed files with 178 additions and 197 deletions

View file

@ -26,6 +26,7 @@ use std::borrow::Cow;
use std::ffi::CString;
use std::ops::Range;
use std::ptr;
use std::ptr::NonNull;
use syntax_pos::Span;
// All Builders must have an llfn associated with them
@ -211,7 +212,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
.join(", "));
let args = self.check_call("invoke", llfn, args);
let bundle = bundle.as_ref().map(|b| b.raw()).unwrap_or(ptr::null_mut());
let bundle = bundle.as_ref().and_then(|b| NonNull::new(b.raw()));
unsafe {
llvm::LLVMRustBuildInvoke(self.llbuilder,
@ -909,7 +910,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
.join(", "));
let args = self.check_call("call", llfn, args);
let bundle = bundle.as_ref().map(|b| b.raw()).unwrap_or(ptr::null_mut());
let bundle = bundle.as_ref().and_then(|b| NonNull::new(b.raw()));
unsafe {
llvm::LLVMRustBuildCall(self.llbuilder, llfn, args.as_ptr(),
@ -1196,7 +1197,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
parent: Option<ValueRef>,
args: &[ValueRef]) -> ValueRef {
self.count_insn("cleanuppad");
let parent = parent.unwrap_or(ptr::null_mut());
let parent = parent.and_then(NonNull::new);
let name = CString::new("cleanuppad").unwrap();
let ret = unsafe {
llvm::LLVMRustBuildCleanupPad(self.llbuilder,
@ -1212,7 +1213,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
pub fn cleanup_ret(&self, cleanup: ValueRef,
unwind: Option<BasicBlockRef>) -> ValueRef {
self.count_insn("cleanupret");
let unwind = unwind.unwrap_or(ptr::null_mut());
let unwind = unwind.and_then(NonNull::new);
let ret = unsafe {
llvm::LLVMRustBuildCleanupRet(self.llbuilder, cleanup, unwind)
};
@ -1248,8 +1249,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
unwind: Option<BasicBlockRef>,
num_handlers: usize) -> ValueRef {
self.count_insn("catchswitch");
let parent = parent.unwrap_or(ptr::null_mut());
let unwind = unwind.unwrap_or(ptr::null_mut());
let parent = parent.and_then(NonNull::new);
let unwind = unwind.and_then(NonNull::new);
let name = CString::new("catchswitch").unwrap();
let ret = unsafe {
llvm::LLVMRustBuildCatchSwitch(self.llbuilder, parent, unwind,