]> git.lizzy.rs Git - rust.git/commitdiff
Clean up uses of set_personality_fn.
authorMark Simulacrum <mark.simulacrum@gmail.com>
Mon, 19 Dec 2016 21:10:48 +0000 (14:10 -0700)
committerMark Simulacrum <mark.simulacrum@gmail.com>
Wed, 21 Dec 2016 03:03:35 +0000 (20:03 -0700)
Remove gnu/msvc constructors for Funclet; these are worse for
readability than explicit Some/None.

src/librustc_trans/cleanup.rs
src/librustc_trans/common.rs
src/librustc_trans/mir/block.rs
src/librustc_trans/mir/mod.rs

index 7b655bbd60675a44cb3da94ccf7d6495ba1b6505..4eb786d63941bd0e8b8b92d94563318ce8e42974 100644 (file)
@@ -203,8 +203,8 @@ fn get_landing_pad<'a>(fcx: &FunctionContext<'a, 'tcx>, drop_val: &DropValue<'tc
 
         // Insert cleanup instructions into the cleanup block
         let funclet = match val {
-            UnwindKind::CleanupPad(_) => Funclet::msvc(cleanup.cleanup_pad(None, &[])),
-            UnwindKind::LandingPad => Funclet::gnu(),
+            UnwindKind::CleanupPad(_) => Some(Funclet::new(cleanup.cleanup_pad(None, &[]))),
+            UnwindKind::LandingPad => None,
         };
         drop_val.trans(funclet.as_ref(), &cleanup);
 
index b7f2fabf184da3ff4bae2a11aa1f55e7babd9d78..81aba269a8b3b407605654a270f6da69f99be022 100644 (file)
@@ -466,15 +466,11 @@ pub struct Funclet {
 }
 
 impl Funclet {
-    pub fn gnu() -> Option<Funclet> {
-        None
-    }
-
-    pub fn msvc(cleanuppad: ValueRef) -> Option<Funclet> {
-        Some(Funclet {
+    pub fn new(cleanuppad: ValueRef) -> Funclet {
+        Funclet {
             cleanuppad: cleanuppad,
             operand: OperandBundleDef::new("funclet", &[cleanuppad]),
-        })
+        }
     }
 
     pub fn cleanuppad(&self) -> ValueRef {
index 6b6ca1a98a38681717c3a387fa65f8d19ee5ad8f..7edc3b00532387cadbd96ae7acaa67488a371225 100644 (file)
@@ -86,7 +86,6 @@ pub fn trans_block(&mut self, bb: mir::BasicBlock,
                         debug!("llblock: creating cleanup trampoline for {:?}", target);
                         let name = &format!("{:?}_cleanup_trampoline_{:?}", bb, target);
                         let trampoline = this.fcx.build_new_block(name);
-                        trampoline.set_personality_fn(this.fcx.eh_personality());
                         trampoline.cleanup_ret(cp, Some(lltarget));
                         trampoline.llbb()
                     }
@@ -121,9 +120,6 @@ pub fn trans_block(&mut self, bb: mir::BasicBlock,
                 if let Some(cleanup_pad) = cleanup_pad {
                     bcx.cleanup_ret(cleanup_pad, None);
                 } else {
-                    let llpersonality = bcx.fcx().eh_personality();
-                    bcx.set_personality_fn(llpersonality);
-
                     let ps = self.get_personality_slot(&bcx);
                     let lp = bcx.load(ps);
                     Lifetime::End.call(&bcx, ps);
index 2cb181340405e34b1c1828089981b8667c93f5db..6041b76d18e698b3cf9149382d7efa949b38e117 100644 (file)
@@ -303,19 +303,15 @@ pub fn trans_mir<'a, 'tcx: 'a>(
     // If false, all funclets should be None (which is the default)
     let funclets: IndexVec<mir::BasicBlock, Option<Funclet>> =
     mircx.cleanup_kinds.iter_enumerated().map(|(bb, cleanup_kind)| {
-        let bcx = mircx.build_block(bb);
-        match *cleanup_kind {
-            _ if !base::wants_msvc_seh(fcx.ccx.sess()) => None,
-            CleanupKind::Internal { .. } => {
-                bcx.set_personality_fn(fcx.eh_personality());
-                None
+        if let CleanupKind::Funclet = *cleanup_kind {
+            let bcx = mircx.build_block(bb);
+            bcx.set_personality_fn(fcx.eh_personality());
+            if base::wants_msvc_seh(fcx.ccx.sess()) {
+                return Some(Funclet::new(bcx.cleanup_pad(None, &[])));
             }
-            CleanupKind::Funclet => {
-                bcx.set_personality_fn(fcx.eh_personality());
-                Funclet::msvc(bcx.cleanup_pad(None, &[]))
-            }
-            _ => None
         }
+
+        None
     }).collect();
 
     let rpo = traversal::reverse_postorder(&mir);