summaryrefslogtreecommitdiffstats
path: root/contrib/restricted/wavm/patches/0014-cache-runtime-exception-pointer-type-info.patch
blob: 66b4723d227c237e7d298bb65fadc75d3434e494 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
diff --git a/contrib/restricted/wavm/Lib/LLVMJIT/LLVMModule.cpp b/contrib/restricted/wavm/Lib/LLVMJIT/LLVMModule.cpp
--- a/contrib/restricted/wavm/Lib/LLVMJIT/LLVMModule.cpp
+++ b/contrib/restricted/wavm/Lib/LLVMJIT/LLVMModule.cpp
@@ -762,15 +762,17 @@ std::shared_ptr<LLVMJIT::Module> LLVMJIT::loadModule(
 #if !USE_WINDOWS_SEH
 	// Use __cxxabiv1::__cxa_current_exception_type to get a reference to the std::type_info for
 	// Runtime::Exception* without enabling RTTI.
-	std::type_info* runtimeExceptionPointerTypeInfo = nullptr;
-	try
-	{
-		throw(Runtime::Exception*) nullptr;
-	}
-	catch(Runtime::Exception*)
-	{
-		runtimeExceptionPointerTypeInfo = __cxxabiv1::__cxa_current_exception_type();
-	}
+	static auto* runtimeExceptionPointerTypeInfo = [] -> std::type_info* {
+		try
+		{
+			throw(Runtime::Exception*) nullptr;
+		}
+		catch(Runtime::Exception*)
+		{
+			return __cxxabiv1::__cxa_current_exception_type();
+		}
+		return nullptr;
+	}();
 
 	// Bind the std::type_info for Runtime::Exception.
 	importedSymbolMap.addOrFail("runtimeExceptionTypeInfo",