teemperor updated this revision to Diff 182718. teemperor added a comment. - Moved code into the VisitFunctionDecl function.
I don't mind if we clean up that function in a later commit. Thanks for the feedback! CHANGES SINCE LAST ACTION https://reviews.llvm.org/D56651/new/ https://reviews.llvm.org/D56651 Files: lib/AST/ASTImporter.cpp test/Import/destructor/Inputs/F.cpp test/Import/destructor/test.cpp Index: test/Import/destructor/test.cpp =================================================================== --- /dev/null +++ test/Import/destructor/test.cpp @@ -0,0 +1,10 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s + +// Triggers the deserialization of B's destructor. +B b1; + +// CHECK: CXXDestructorDecl + +// CHECK-NEXT: ~B 'void () noexcept' virtual +// CHECK-SAME: 'void () noexcept' +// CHECK-SAME: virtual Index: test/Import/destructor/Inputs/F.cpp =================================================================== --- /dev/null +++ test/Import/destructor/Inputs/F.cpp @@ -0,0 +1,3 @@ +struct B { + virtual ~B() {} +}; Index: lib/AST/ASTImporter.cpp =================================================================== --- lib/AST/ASTImporter.cpp +++ lib/AST/ASTImporter.cpp @@ -3091,12 +3091,28 @@ FromConstructor->isExplicit(), D->isInlineSpecified(), D->isImplicit(), D->isConstexpr())) return ToFunction; - } else if (isa<CXXDestructorDecl>(D)) { + } else if (CXXDestructorDecl *FromDtor = dyn_cast<CXXDestructorDecl>(D)) { + + auto Imp = + importSeq(const_cast<FunctionDecl *>(FromDtor->getOperatorDelete()), + FromDtor->getOperatorDeleteThisArg()); + + if (!Imp) + return Imp.takeError(); + + FunctionDecl *ToOperatorDelete; + Expr *ToThisArg; + std::tie(ToOperatorDelete, ToThisArg) = *Imp; + if (GetImportedOrCreateDecl<CXXDestructorDecl>( ToFunction, D, Importer.getToContext(), cast<CXXRecordDecl>(DC), ToInnerLocStart, NameInfo, T, TInfo, D->isInlineSpecified(), D->isImplicit())) return ToFunction; + + CXXDestructorDecl *ToDtor = cast<CXXDestructorDecl>(ToFunction); + + ToDtor->setOperatorDelete(ToOperatorDelete, ToThisArg); } else if (CXXConversionDecl *FromConversion = dyn_cast<CXXConversionDecl>(D)) { if (GetImportedOrCreateDecl<CXXConversionDecl>(
Index: test/Import/destructor/test.cpp =================================================================== --- /dev/null +++ test/Import/destructor/test.cpp @@ -0,0 +1,10 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s + +// Triggers the deserialization of B's destructor. +B b1; + +// CHECK: CXXDestructorDecl + +// CHECK-NEXT: ~B 'void () noexcept' virtual +// CHECK-SAME: 'void () noexcept' +// CHECK-SAME: virtual Index: test/Import/destructor/Inputs/F.cpp =================================================================== --- /dev/null +++ test/Import/destructor/Inputs/F.cpp @@ -0,0 +1,3 @@ +struct B { + virtual ~B() {} +}; Index: lib/AST/ASTImporter.cpp =================================================================== --- lib/AST/ASTImporter.cpp +++ lib/AST/ASTImporter.cpp @@ -3091,12 +3091,28 @@ FromConstructor->isExplicit(), D->isInlineSpecified(), D->isImplicit(), D->isConstexpr())) return ToFunction; - } else if (isa<CXXDestructorDecl>(D)) { + } else if (CXXDestructorDecl *FromDtor = dyn_cast<CXXDestructorDecl>(D)) { + + auto Imp = + importSeq(const_cast<FunctionDecl *>(FromDtor->getOperatorDelete()), + FromDtor->getOperatorDeleteThisArg()); + + if (!Imp) + return Imp.takeError(); + + FunctionDecl *ToOperatorDelete; + Expr *ToThisArg; + std::tie(ToOperatorDelete, ToThisArg) = *Imp; + if (GetImportedOrCreateDecl<CXXDestructorDecl>( ToFunction, D, Importer.getToContext(), cast<CXXRecordDecl>(DC), ToInnerLocStart, NameInfo, T, TInfo, D->isInlineSpecified(), D->isImplicit())) return ToFunction; + + CXXDestructorDecl *ToDtor = cast<CXXDestructorDecl>(ToFunction); + + ToDtor->setOperatorDelete(ToOperatorDelete, ToThisArg); } else if (CXXConversionDecl *FromConversion = dyn_cast<CXXConversionDecl>(D)) { if (GetImportedOrCreateDecl<CXXConversionDecl>(
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits