Skip to content

Commit db92fb8

Browse files
committed
[clang][ASTImporter] Add import of 'DependentSizedExtVectorType'
Add import of 'DependentSizedExtVectorType'. Reviewed By: balazske Differential Revision: https://reviews.llvm.org/D157238
1 parent caa5167 commit db92fb8

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

clang/lib/AST/ASTImporter.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@ namespace clang {
381381
ExpectedType VisitIncompleteArrayType(const IncompleteArrayType *T);
382382
ExpectedType VisitVariableArrayType(const VariableArrayType *T);
383383
ExpectedType VisitDependentSizedArrayType(const DependentSizedArrayType *T);
384-
// FIXME: DependentSizedExtVectorType
384+
ExpectedType
385+
VisitDependentSizedExtVectorType(const DependentSizedExtVectorType *T);
385386
ExpectedType VisitVectorType(const VectorType *T);
386387
ExpectedType VisitExtVectorType(const ExtVectorType *T);
387388
ExpectedType VisitFunctionNoProtoType(const FunctionNoProtoType *T);
@@ -1264,6 +1265,18 @@ ExpectedType ASTNodeImporter::VisitDependentSizedArrayType(
12641265
T->getIndexTypeCVRQualifiers(), ToBracketsRange);
12651266
}
12661267

1268+
ExpectedType ASTNodeImporter::VisitDependentSizedExtVectorType(
1269+
const DependentSizedExtVectorType *T) {
1270+
Error Err = Error::success();
1271+
QualType ToElementType = importChecked(Err, T->getElementType());
1272+
Expr *ToSizeExpr = importChecked(Err, T->getSizeExpr());
1273+
SourceLocation ToAttrLoc = importChecked(Err, T->getAttributeLoc());
1274+
if (Err)
1275+
return std::move(Err);
1276+
return Importer.getToContext().getDependentSizedExtVectorType(
1277+
ToElementType, ToSizeExpr, ToAttrLoc);
1278+
}
1279+
12671280
ExpectedType ASTNodeImporter::VisitVectorType(const VectorType *T) {
12681281
ExpectedType ToElementTypeOrErr = import(T->getElementType());
12691282
if (!ToElementTypeOrErr)

clang/unittests/AST/ASTImporterFixtures.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ class TestImportBase
260260
FromAST->getFileManager(), false);
261261

262262
auto FoundNodes = match(SearchMatcher, FromCtx);
263+
if (FoundNodes.empty())
264+
return testing::AssertionFailure() << "No node was found!";
263265
if (FoundNodes.size() != 1)
264266
return testing::AssertionFailure()
265267
<< "Multiple potential nodes were found!";

clang/unittests/AST/ASTImporterTest.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,17 @@ TEST_P(ImportExpr, DependentSizedArrayType) {
10441044
has(fieldDecl(hasType(dependentSizedArrayType())))))));
10451045
}
10461046

1047+
TEST_P(ImportExpr, DependentSizedExtVectorType) {
1048+
MatchVerifier<Decl> Verifier;
1049+
testImport("template<typename T, int Size>"
1050+
"class declToImport {"
1051+
" typedef T __attribute__((ext_vector_type(Size))) type;"
1052+
"};",
1053+
Lang_CXX03, "", Lang_CXX03, Verifier,
1054+
classTemplateDecl(has(cxxRecordDecl(
1055+
has(typedefDecl(hasType(dependentSizedExtVectorType())))))));
1056+
}
1057+
10471058
TEST_P(ASTImporterOptionSpecificTestBase, ImportUsingPackDecl) {
10481059
Decl *FromTU = getTuDecl(
10491060
"struct A { int operator()() { return 1; } };"

0 commit comments

Comments
 (0)