[PATCH] D157238: [clang][ASTImporter] Add import of 'DependentSizedExtVectorType'
Ding Fei via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 7 07:35:31 PDT 2023
danix800 updated this revision to Diff 547783.
danix800 added a comment.
Cleanup since D157237 <https://reviews.llvm.org/D157237> is landed.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157238/new/
https://reviews.llvm.org/D157238
Files:
clang/lib/AST/ASTImporter.cpp
clang/unittests/AST/ASTImporterFixtures.h
clang/unittests/AST/ASTImporterTest.cpp
Index: clang/unittests/AST/ASTImporterTest.cpp
===================================================================
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -1044,6 +1044,17 @@
has(fieldDecl(hasType(dependentSizedArrayType())))))));
}
+TEST_P(ImportExpr, DependentSizedExtVectorType) {
+ MatchVerifier<Decl> Verifier;
+ testImport("template<typename T, int Size>"
+ "class declToImport {"
+ " typedef T __attribute__((ext_vector_type(Size))) type;"
+ "};",
+ Lang_CXX03, "", Lang_CXX03, Verifier,
+ classTemplateDecl(has(cxxRecordDecl(
+ has(typedefDecl(hasType(dependentSizedExtVectorType())))))));
+}
+
TEST_P(ASTImporterOptionSpecificTestBase, ImportUsingPackDecl) {
Decl *FromTU = getTuDecl(
"struct A { int operator()() { return 1; } };"
Index: clang/unittests/AST/ASTImporterFixtures.h
===================================================================
--- clang/unittests/AST/ASTImporterFixtures.h
+++ clang/unittests/AST/ASTImporterFixtures.h
@@ -260,6 +260,8 @@
FromAST->getFileManager(), false);
auto FoundNodes = match(SearchMatcher, FromCtx);
+ if (FoundNodes.empty())
+ return testing::AssertionFailure() << "No node was found!";
if (FoundNodes.size() != 1)
return testing::AssertionFailure()
<< "Multiple potential nodes were found!";
Index: clang/lib/AST/ASTImporter.cpp
===================================================================
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -381,7 +381,8 @@
ExpectedType VisitIncompleteArrayType(const IncompleteArrayType *T);
ExpectedType VisitVariableArrayType(const VariableArrayType *T);
ExpectedType VisitDependentSizedArrayType(const DependentSizedArrayType *T);
- // FIXME: DependentSizedExtVectorType
+ ExpectedType
+ VisitDependentSizedExtVectorType(const DependentSizedExtVectorType *T);
ExpectedType VisitVectorType(const VectorType *T);
ExpectedType VisitExtVectorType(const ExtVectorType *T);
ExpectedType VisitFunctionNoProtoType(const FunctionNoProtoType *T);
@@ -1264,6 +1265,18 @@
T->getIndexTypeCVRQualifiers(), ToBracketsRange);
}
+ExpectedType ASTNodeImporter::VisitDependentSizedExtVectorType(
+ const DependentSizedExtVectorType *T) {
+ Error Err = Error::success();
+ QualType ToElementType = importChecked(Err, T->getElementType());
+ Expr *ToSizeExpr = importChecked(Err, T->getSizeExpr());
+ SourceLocation ToAttrLoc = importChecked(Err, T->getAttributeLoc());
+ if (Err)
+ return std::move(Err);
+ return Importer.getToContext().getDependentSizedExtVectorType(
+ ToElementType, ToSizeExpr, ToAttrLoc);
+}
+
ExpectedType ASTNodeImporter::VisitVectorType(const VectorType *T) {
ExpectedType ToElementTypeOrErr = import(T->getElementType());
if (!ToElementTypeOrErr)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157238.547783.patch
Type: text/x-patch
Size: 2976 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230807/81758a56/attachment-0001.bin>
More information about the cfe-commits
mailing list