]> git.lizzy.rs Git - rust.git/commitdiff
Abort creating wrapper fn for multiple inner fns
authorSimonas Kazlauskas <git@kazlauskas.me>
Fri, 27 Feb 2015 12:18:39 +0000 (14:18 +0200)
committerSimonas Kazlauskas <git@kazlauskas.me>
Fri, 3 Apr 2015 12:46:09 +0000 (15:46 +0300)
This discovers another class of mis-trans where we wrap multiple native functions into a single
wrapper, which is wrong.

src/librustc_trans/trans/foreign.rs

index e87a5865df05446f5f08f51a649348d648547b87..e154bc1d579ff6d3aded8695a2b4dacd12adfb3d 100644 (file)
@@ -642,6 +642,11 @@ unsafe fn build_wrap_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
         //         return r;
         //     }
 
+        if llvm::LLVMCountBasicBlocks(llwrapfn) != 0 {
+            ccx.sess().bug("wrapping a function inside non-empty wrapper, most likely cause is \
+                           multiple functions being wrapped");
+        }
+
         let ptr = "the block\0".as_ptr();
         let the_block = llvm::LLVMAppendBasicBlockInContext(ccx.llcx(), llwrapfn,
                                                             ptr as *const _);