================
@@ -198,6 +199,138 @@ static llvm::StringRef getPersonalityFn(CIRGenModule &cgm,
   return personalityFn.getSymName();
 }
 
+void CIRGenFunction::emitStartEHSpec(const Decl *d) {
+  if (!cgm.getLangOpts().CXXExceptions)
+    return;
+
+  const FunctionDecl *fd = dyn_cast_or_null<FunctionDecl>(d);
+  if (!fd) {
+    // This can't currently happen in CIR, but if we do get here, we need to
+    // handle the cd->isNoThrow() case.
+    if (const CapturedDecl *cd = dyn_cast_or_null<CapturedDecl>(d)) {
+      if (cd->isNothrow())
+        cgm.errorNYI(cd->getSourceRange(),
+                     "emitStartEHSpec CapturedDecl nothrow");
+    }
+    return;
+  }
+
+  const FunctionProtoType *proto = fd->getType()->getAs<FunctionProtoType>();
+  if (!proto)
+    return;
+
+  ExceptionSpecificationType est = proto->getExceptionSpecType();
+  // In C++17 and later, 'throw()' aka EST_DynamicNone is treated the same way
+  // as noexcept. In earlier standards, it is handled with 'throw(X...)'.
+  if (est != EST_Dynamic &&
+      !(est == EST_DynamicNone && !getLangOpts().CPlusPlus17)) {
+    // noexcept functions are terminate scopes in classic codegen.
+    if (proto->canThrow() == CT_Cannot && !getLangOpts().EHAsynch)
+      cgm.errorNYI(fd->getSourceRange(),
+                   "emitStartEHSpec noexcept terminate scope");
+    return;
+  }
+
+  // TODO: Revisit exception specifications for the MS ABI. There is a way
+  // to encode these in an object file but MSVC doesn't do anything with it.
+  if (getTarget().getCXXABI().isMicrosoft())
----------------
andykaylor wrote:

This TODO comment is copied from classic codegen.

https://github.com/llvm/llvm-project/pull/224375
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to