]> git.lizzy.rs Git - rust.git/commitdiff
Explain flag value of 8 for msvc_try
authorAmanieu d'Antras <amanieu@gmail.com>
Wed, 1 Jan 2020 21:24:39 +0000 (22:24 +0100)
committerAmanieu d'Antras <amanieu@gmail.com>
Sat, 11 Jan 2020 10:18:44 +0000 (10:18 +0000)
src/librustc_codegen_llvm/intrinsic.rs

index 5adff0d1f9233a081ee4f1bb36eca4d4e2bbb614..27308cabd45e600d6205cf2f3fbc2aa6acc62ed9 100644 (file)
@@ -952,11 +952,15 @@ fn codegen_msvc_try(
         let cs = catchswitch.catch_switch(None, None, 1);
         catchswitch.add_handler(cs, catchpad.llbb());
 
+        // The flag value of 8 indicates that we are catching the exception by
+        // reference instead of by value.
+        //
+        // Source: MicrosoftCXXABI::getAddrOfCXXCatchHandlerType in clang
+        let flags = bx.const_i32(8);
         let tydesc = match bx.tcx().lang_items().eh_catch_typeinfo() {
             Some(did) => bx.get_static(did),
             None => bug!("eh_catch_typeinfo not defined, but needed for SEH unwinding"),
         };
-        let flags = bx.const_i32(8); // Catch by reference
         let funclet = catchpad.catch_pad(cs, &[tydesc, flags, slot]);
 
         let i64_align = bx.tcx().data_layout.i64_align.abi;