[clang] WIP: [clang] MicrosoftCXXABI: Serialize the exception copy constructor table in the AST (PR #114075)

Andrey Glebov via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 30 12:03:22 PST 2025


================
@@ -2316,6 +2316,20 @@ void ASTDeclReader::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
   }
 
   VisitCXXMethodDecl(D);
+
+  // Microsoft CXX ABI specific:
+  // Restore the RecordToCopyCtor sidecar LUT entry so that `throw` expressions
+  // find the correct copy constructor for exceptions during codegen.
+  // There is no need to check the target info because the
+  // HasCopyConstructorForExceptionObject bit only gets set for the MS ABI.
+  if (D->isCopyConstructor()) {
+    // TODO What if this is not the same copy constructor which was chosen by
+    //      LookupCopyingConstructor() in SemaExprCXX? Is there a better way?
----------------
glebov-andrey wrote:

Confirmed that `std::current_exception` causes UB/crash when the type is non-copyable. But this appears to be a matter of implementing [CWG-2775](https://cplusplus.github.io/CWG/issues/2775.html).

https://github.com/llvm/llvm-project/pull/114075


More information about the cfe-commits mailing list