diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -616,6 +616,7 @@ ExpectedStmt VisitSourceLocExpr(SourceLocExpr *E); ExpectedStmt VisitVAArgExpr(VAArgExpr *E); ExpectedStmt VisitChooseExpr(ChooseExpr *E); + ExpectedStmt VisitConvertVectorExpr(ConvertVectorExpr *E); ExpectedStmt VisitShuffleVectorExpr(ShuffleVectorExpr *E); ExpectedStmt VisitGNUNullExpr(GNUNullExpr *E); ExpectedStmt VisitGenericSelectionExpr(GenericSelectionExpr *E); @@ -7051,6 +7052,21 @@ ToRParenLoc, CondIsTrue); } +ExpectedStmt ASTNodeImporter::VisitConvertVectorExpr(ConvertVectorExpr *E) { + Error Err = Error::success(); + auto *ToSrcExpr = importChecked(Err, E->getSrcExpr()); + auto ToRParenLoc = importChecked(Err, E->getRParenLoc()); + auto ToBuiltinLoc = importChecked(Err, E->getBuiltinLoc()); + auto ToType = importChecked(Err, E->getType()); + auto *ToTSI = importChecked(Err, E->getTypeSourceInfo()); + if (Err) + return std::move(Err); + + return new (Importer.getToContext()) + ConvertVectorExpr(ToSrcExpr, ToTSI, ToType, E->getValueKind(), + E->getObjectKind(), ToBuiltinLoc, ToRParenLoc); +} + ExpectedStmt ASTNodeImporter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { Error Err = Error::success(); auto ToRParenLoc = importChecked(Err, E->getRParenLoc()); diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -1306,6 +1306,29 @@ ToChooseExpr->isConditionDependent()); } +TEST_P(ASTImporterOptionSpecificTestBase, ImportConvertVectorExpr) { + Decl *From, *To; + std::tie(From, To) = getImportedDecl( + "typedef double v4double __attribute__((__vector_size__(32)));" + "typedef float v4float __attribute__((__vector_size__(16)));" + "v4float vf;" + "void declToImport() { (void)__builtin_convertvector(vf, v4double); }", + Lang_CXX03, "", Lang_CXX03); + + auto ToResults = + match(convertVectorExpr().bind("convert"), To->getASTContext()); + auto FromResults = + match(convertVectorExpr().bind("convert"), From->getASTContext()); + + const ConvertVectorExpr *FromConvertVectorExpr = + selectFirst("convert", FromResults); + ASSERT_TRUE(FromConvertVectorExpr); + + const ConvertVectorExpr *ToConvertVectorExpr = + selectFirst("convert", ToResults); + ASSERT_TRUE(ToConvertVectorExpr); +} + TEST_P(ASTImporterOptionSpecificTestBase, ImportGenericSelectionExpr) { Decl *From, *To; std::tie(From, To) = getImportedDecl(