Index: clang/lib/AST/ASTImporter.cpp =================================================================== --- clang/lib/AST/ASTImporter.cpp +++ clang/lib/AST/ASTImporter.cpp @@ -599,6 +599,7 @@ ExpectedStmt VisitSourceLocExpr(SourceLocExpr *E); ExpectedStmt VisitVAArgExpr(VAArgExpr *E); ExpectedStmt VisitChooseExpr(ChooseExpr *E); + ExpectedStmt VisitShuffleVectorExpr(ShuffleVectorExpr *E); ExpectedStmt VisitGNUNullExpr(GNUNullExpr *E); ExpectedStmt VisitGenericSelectionExpr(GenericSelectionExpr *E); ExpectedStmt VisitPredefinedExpr(PredefinedExpr *E); @@ -6730,6 +6731,24 @@ ToRParenLoc, CondIsTrue); } +ExpectedStmt ASTNodeImporter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { + Error Err = Error::success(); + auto ToRParenLoc = importChecked(Err, E->getRParenLoc()); + auto ToBeginLoc = importChecked(Err, E->getBeginLoc()); + auto ToType = importChecked(Err, E->getType()); + const unsigned NumSubExprs = E->getNumSubExprs(); + + llvm::SmallVector ToSubExprs; + llvm::ArrayRef FromSubExprs(E->getSubExprs(), NumSubExprs); + ToSubExprs.resize(NumSubExprs); + + if ((Err = ImportContainerChecked(FromSubExprs, ToSubExprs))) + return std::move(Err); + + return new (Importer.getToContext()) ShuffleVectorExpr( + Importer.getToContext(), ToSubExprs, ToType, ToBeginLoc, ToRParenLoc); +} + ExpectedStmt ASTNodeImporter::VisitGNUNullExpr(GNUNullExpr *E) { ExpectedType TypeOrErr = import(E->getType()); if (!TypeOrErr) Index: clang/unittests/AST/ASTImporterTest.cpp =================================================================== --- clang/unittests/AST/ASTImporterTest.cpp +++ clang/unittests/AST/ASTImporterTest.cpp @@ -290,6 +290,25 @@ functionDecl(hasDescendant(chooseExpr()))); } +const internal::VariadicDynCastAllOfMatcher + shuffleVectorExpr; + +TEST_P(ImportExpr, ImportShuffleVectorExpr) { + MatchVerifier Verifier; + constexpr auto Code = R"code( + typedef double vector4double __attribute__((__vector_size__(32))); + vector4double declToImport(vector4double a, vector4double b) { + return __builtin_shufflevector(a, b, 0, 1, 2, 3); + } + )code"; + const auto Pattern = functionDecl(hasDescendant(shuffleVectorExpr( + allOf(has(declRefExpr(to(parmVarDecl(hasName("a"))))), + has(declRefExpr(to(parmVarDecl(hasName("b"))))), + has(integerLiteral(equals(0))), has(integerLiteral(equals(1))), + has(integerLiteral(equals(2))), has(integerLiteral(equals(3))))))); + testImport(Code, Lang_C99, "", Lang_C99, Verifier, Pattern); +} + TEST_P(ImportExpr, ImportGNUNullExpr) { MatchVerifier Verifier; testImport("void declToImport() { (void)__null; }", Lang_CXX03, "",