Skip to content

Commit

Permalink
[clang][ASTImporter] Add import of 'DependentSizedExtVectorType'
Browse files Browse the repository at this point in the history
Add import of 'DependentSizedExtVectorType'.

Reviewed By: balazske

Differential Revision: https://reviews.llvm.org/D157238
  • Loading branch information
danix800 committed Aug 8, 2023
1 parent caa5167 commit db92fb8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
15 changes: 14 additions & 1 deletion clang/lib/AST/ASTImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ namespace clang {
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);
Expand Down Expand Up @@ -1264,6 +1265,18 @@ ExpectedType ASTNodeImporter::VisitDependentSizedArrayType(
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)
Expand Down
2 changes: 2 additions & 0 deletions clang/unittests/AST/ASTImporterFixtures.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ class TestImportBase
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!";
Expand Down
11 changes: 11 additions & 0 deletions clang/unittests/AST/ASTImporterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,17 @@ TEST_P(ImportExpr, DependentSizedArrayType) {
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; } };"
Expand Down

0 comments on commit db92fb8

Please sign in to comment.