From 1c5d23f1405994da05697b3b66c9f5a32735fdc3 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Tue, 22 Jan 2019 17:59:45 +0000 Subject: [ASTImporter] Fix importing OperatorDelete from CXXConstructorDecl Summary: Shafik found out that importing a CXXConstructorDecl will create a translation unit that causes Clang's CodeGen to crash. The reason for that is that we don't copy the OperatorDelete from the CXXConstructorDecl when importing. This patch fixes it and adds a test case for that. Reviewers: shafik, martong, a_sidorin, a.sidorin Reviewed By: martong, a_sidorin Subscribers: rnkovacs, cfe-commits Differential Revision: https://reviews.llvm.org/D56651 llvm-svn: 351849 --- clang/lib/AST/ASTImporter.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'clang/lib/AST/ASTImporter.cpp') diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 6c245991031..f24a5698f58 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -3091,12 +3091,28 @@ ExpectedDecl ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) { FromConstructor->isExplicit(), D->isInlineSpecified(), D->isImplicit(), D->isConstexpr())) return ToFunction; - } else if (isa(D)) { + } else if (CXXDestructorDecl *FromDtor = dyn_cast(D)) { + + auto Imp = + importSeq(const_cast(FromDtor->getOperatorDelete()), + FromDtor->getOperatorDeleteThisArg()); + + if (!Imp) + return Imp.takeError(); + + FunctionDecl *ToOperatorDelete; + Expr *ToThisArg; + std::tie(ToOperatorDelete, ToThisArg) = *Imp; + if (GetImportedOrCreateDecl( ToFunction, D, Importer.getToContext(), cast(DC), ToInnerLocStart, NameInfo, T, TInfo, D->isInlineSpecified(), D->isImplicit())) return ToFunction; + + CXXDestructorDecl *ToDtor = cast(ToFunction); + + ToDtor->setOperatorDelete(ToOperatorDelete, ToThisArg); } else if (CXXConversionDecl *FromConversion = dyn_cast(D)) { if (GetImportedOrCreateDecl( -- cgit v1.2.3