[llvm] a349c09 - Fix MSVC build with C++ EH enabled

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 11 15:56:16 PST 2020


Author: Reid Kleckner
Date: 2020-02-11T15:56:10-08:00
New Revision: a349c09162a8260bdf691c4f7ab72a16c33975f6

URL: https://github.com/llvm/llvm-project/commit/a349c09162a8260bdf691c4f7ab72a16c33975f6
DIFF: https://github.com/llvm/llvm-project/commit/a349c09162a8260bdf691c4f7ab72a16c33975f6.diff

LOG: Fix MSVC build with C++ EH enabled

Mark the CrashRecoveryContextImpl constructor noexcept, so that MSVC
won't emit an unwind helper to clean up the allocation from `new` if the
constructor throws an exception.

Otherwise, MSVC complains:
  llvm\lib\Support\CrashRecoveryContext.cpp(220): error C2712: \
  Cannot use __try in functions that require object unwinding

The other simple fix would be to wrap `new` in a static helper or
lambda.

Users have reported that Tensorflow builds LLVM with /EHsc.

Added: 
    

Modified: 
    llvm/lib/Support/CrashRecoveryContext.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Support/CrashRecoveryContext.cpp b/llvm/lib/Support/CrashRecoveryContext.cpp
index f708da773f4c..356835609830 100644
--- a/llvm/lib/Support/CrashRecoveryContext.cpp
+++ b/llvm/lib/Support/CrashRecoveryContext.cpp
@@ -41,7 +41,7 @@ struct CrashRecoveryContextImpl {
   unsigned ValidJumpBuffer : 1;
 
 public:
-  CrashRecoveryContextImpl(CrashRecoveryContext *CRC)
+  CrashRecoveryContextImpl(CrashRecoveryContext *CRC) noexcept
       : CRC(CRC), Failed(false), SwitchedThread(false), ValidJumpBuffer(false) {
     Next = CurrentContext->get();
     CurrentContext->set(this);


        


More information about the llvm-commits mailing list