================ @@ -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 think we can rely on this assumption, and if it holds, then we don't actually need this lookup table at all. I've observed that LookupSpecialMember is cached, so once a special member (copy ctor) is looked up, it cannot change. Since we know at the point of the throw site, all relevant copy constructors are looked up, I think it should be safe to, in all cases, in MicrosoftCXXABI.cpp, when building the catchable type array, iterate the constructors and use the first constructor that returns true for `isCopyConstructor`. I propose you prototype that change (replace the call to getCopyCtor... with the constructor search), run the tests, and see if that creates any fallout. If all tests involving copy constructors with default arguments pass, then I think it's safe to rely on this assumption in all cases, not just in the cases where we're doing a modules build. And, if it turns out we're wrong and we should be storing the result of LookupCopyConstructor in a lookup table, that bug won't be hidden in a modules-only build configuration. It's better for the behavior to be consistent between regular builds and modules builds. I propose the following experiment: * 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