balazske created this revision. Herald added subscribers: martong, teemperor, gamesh411, Szelethus, dkrupp. Herald added a reviewer: a.sidorin. Herald added a reviewer: shafik. balazske requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D94786 Files: clang/lib/AST/ASTImporter.cpp clang/unittests/AST/ASTImporterTest.cpp Index: clang/unittests/AST/ASTImporterTest.cpp =================================================================== --- clang/unittests/AST/ASTImporterTest.cpp +++ clang/unittests/AST/ASTImporterTest.cpp @@ -639,6 +639,22 @@ hasUnqualifiedDesugaredType(constantArrayType(hasSize(7)))))))))); } +const internal::VariadicDynCastAllOfMatcher<Stmt, CXXFoldExpr> cxxFoldExpr; + +TEST_P(ImportExpr, ImportCXXFoldExpr) { + MatchVerifier<Decl> Verifier; + testImport("template <typename... Ts>" + "void declToImport(Ts... args) {" + " const int i1 = (... + args);" + " const int i2 = (1 + ... + args);" + " const int i3 = (args + ...);" + " const int i4 = (args + ... + 1);" + "};" + "void g() { declToImport(1, 2, 3, 4, 5); }", + Lang_CXX17, "", Lang_CXX17, Verifier, + functionTemplateDecl(hasDescendant(cxxFoldExpr()))); +} + /// \brief Matches __builtin_types_compatible_p: /// GNU extension to check equivalent types /// Given Index: clang/lib/AST/ASTImporter.cpp =================================================================== --- clang/lib/AST/ASTImporter.cpp +++ clang/lib/AST/ASTImporter.cpp @@ -644,6 +644,7 @@ ExpectedStmt VisitSubstNonTypeTemplateParmExpr(SubstNonTypeTemplateParmExpr *E); ExpectedStmt VisitTypeTraitExpr(TypeTraitExpr *E); ExpectedStmt VisitCXXTypeidExpr(CXXTypeidExpr *E); + ExpectedStmt VisitCXXFoldExpr(CXXFoldExpr *E); template<typename IIter, typename OIter> Error ImportArrayChecked(IIter Ibegin, IIter Iend, OIter Obegin) { @@ -8011,6 +8012,25 @@ *ToTypeOrErr, *ToExprOperandOrErr, *ToSourceRangeOrErr); } +ExpectedStmt ASTNodeImporter::VisitCXXFoldExpr(CXXFoldExpr *E) { + Error Err = Error::success(); + + auto ToType = importChecked(Err, E->getType()); + auto ToCallee = importChecked(Err, E->getCallee()); + auto ToLParenLoc = importChecked(Err, E->getLParenLoc()); + auto ToLHS = importChecked(Err, E->getLHS()); + auto ToEllipsisLoc = importChecked(Err, E->getEllipsisLoc()); + auto ToRHS = importChecked(Err, E->getRHS()); + auto ToRParenLoc = importChecked(Err, E->getRParenLoc()); + + if (Err) + return std::move(Err); + + return new (Importer.getToContext()) + CXXFoldExpr(ToType, ToCallee, ToLParenLoc, ToLHS, E->getOperator(), + ToEllipsisLoc, ToRHS, ToRParenLoc, E->getNumExpansions()); +} + Error ASTNodeImporter::ImportOverriddenMethods(CXXMethodDecl *ToMethod, CXXMethodDecl *FromMethod) { Error ImportErrors = Error::success();
Index: clang/unittests/AST/ASTImporterTest.cpp =================================================================== --- clang/unittests/AST/ASTImporterTest.cpp +++ clang/unittests/AST/ASTImporterTest.cpp @@ -639,6 +639,22 @@ hasUnqualifiedDesugaredType(constantArrayType(hasSize(7)))))))))); } +const internal::VariadicDynCastAllOfMatcher<Stmt, CXXFoldExpr> cxxFoldExpr; + +TEST_P(ImportExpr, ImportCXXFoldExpr) { + MatchVerifier<Decl> Verifier; + testImport("template <typename... Ts>" + "void declToImport(Ts... args) {" + " const int i1 = (... + args);" + " const int i2 = (1 + ... + args);" + " const int i3 = (args + ...);" + " const int i4 = (args + ... + 1);" + "};" + "void g() { declToImport(1, 2, 3, 4, 5); }", + Lang_CXX17, "", Lang_CXX17, Verifier, + functionTemplateDecl(hasDescendant(cxxFoldExpr()))); +} + /// \brief Matches __builtin_types_compatible_p: /// GNU extension to check equivalent types /// Given Index: clang/lib/AST/ASTImporter.cpp =================================================================== --- clang/lib/AST/ASTImporter.cpp +++ clang/lib/AST/ASTImporter.cpp @@ -644,6 +644,7 @@ ExpectedStmt VisitSubstNonTypeTemplateParmExpr(SubstNonTypeTemplateParmExpr *E); ExpectedStmt VisitTypeTraitExpr(TypeTraitExpr *E); ExpectedStmt VisitCXXTypeidExpr(CXXTypeidExpr *E); + ExpectedStmt VisitCXXFoldExpr(CXXFoldExpr *E); template<typename IIter, typename OIter> Error ImportArrayChecked(IIter Ibegin, IIter Iend, OIter Obegin) { @@ -8011,6 +8012,25 @@ *ToTypeOrErr, *ToExprOperandOrErr, *ToSourceRangeOrErr); } +ExpectedStmt ASTNodeImporter::VisitCXXFoldExpr(CXXFoldExpr *E) { + Error Err = Error::success(); + + auto ToType = importChecked(Err, E->getType()); + auto ToCallee = importChecked(Err, E->getCallee()); + auto ToLParenLoc = importChecked(Err, E->getLParenLoc()); + auto ToLHS = importChecked(Err, E->getLHS()); + auto ToEllipsisLoc = importChecked(Err, E->getEllipsisLoc()); + auto ToRHS = importChecked(Err, E->getRHS()); + auto ToRParenLoc = importChecked(Err, E->getRParenLoc()); + + if (Err) + return std::move(Err); + + return new (Importer.getToContext()) + CXXFoldExpr(ToType, ToCallee, ToLParenLoc, ToLHS, E->getOperator(), + ToEllipsisLoc, ToRHS, ToRParenLoc, E->getNumExpansions()); +} + Error ASTNodeImporter::ImportOverriddenMethods(CXXMethodDecl *ToMethod, CXXMethodDecl *FromMethod) { Error ImportErrors = Error::success();
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits