[PATCH] D157249: [clang][ASTImporter] Add import of 'ConvertVectorExpr'
Ding Fei via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 7 07:32:03 PDT 2023
danix800 updated this revision to Diff 547781.
danix800 added a comment.
Cleanup since D157248 <https://reviews.llvm.org/D157248> is landed.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157249/new/
https://reviews.llvm.org/D157249
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
@@ -1295,6 +1295,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<ConvertVectorExpr>("convert", FromResults);
+ ASSERT_TRUE(FromConvertVectorExpr);
+
+ const ConvertVectorExpr *ToConvertVectorExpr =
+ selectFirst<ConvertVectorExpr>("convert", ToResults);
+ ASSERT_TRUE(ToConvertVectorExpr);
+}
+
TEST_P(ASTImporterOptionSpecificTestBase, ImportGenericSelectionExpr) {
Decl *From, *To;
std::tie(From, To) = getImportedDecl(
Index: clang/lib/AST/ASTImporter.cpp
===================================================================
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -615,6 +615,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);
@@ -7038,6 +7039,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());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157249.547781.patch
Type: text/x-patch
Size: 2803 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230807/6c94deda/attachment-0001.bin>
More information about the cfe-commits
mailing list