================
@@ -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?
----------------
rnk wrote:

I'm proud of the depth of the test cases we added when implementing this the 
first time. There may be modules bugs, but at least there are good tests, and I 
remembered how to leverage them, so we don't have to rediscover all the edge 
cases. :)

I think we don't have to worry about cases involving deleted copy ctors because 
they will be diagnosed at the catch site (attempting to catch an uncopyable 
type by value), so the catchable type entry will effectively be dead. Skipping 
those entries is probably the right thing to do.

I think templated copy ctors is what makes this hard. The `throw` expression 
will instantiate the appropriate template, but the natural thing to do in other 
parts of the AST is store the lookup result in the AST and use it later in 
codegen.

I guess the most straightforward thing to do here is to create a special 
serialization record, like VTABLE_USES, that records a record type and a 
relevant copy constructor.

https://github.com/llvm/llvm-project/pull/114075
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to