Author: dingfei Date: 2023-08-08T10:22:00+08:00 New Revision: db92fb8726fc09e6d76346a02169685025fd59ca
URL: https://github.com/llvm/llvm-project/commit/db92fb8726fc09e6d76346a02169685025fd59ca DIFF: https://github.com/llvm/llvm-project/commit/db92fb8726fc09e6d76346a02169685025fd59ca.diff LOG: [clang][ASTImporter] Add import of 'DependentSizedExtVectorType' Add import of 'DependentSizedExtVectorType'. Reviewed By: balazske Differential Revision: https://reviews.llvm.org/D157238 Added: Modified: clang/lib/AST/ASTImporter.cpp clang/unittests/AST/ASTImporterFixtures.h clang/unittests/AST/ASTImporterTest.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index f122c09629e1c2..c64b92c5c830e4 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -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); @@ -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) diff --git a/clang/unittests/AST/ASTImporterFixtures.h b/clang/unittests/AST/ASTImporterFixtures.h index ed561f4b5eaf2e..87e62cbda422ab 100644 --- a/clang/unittests/AST/ASTImporterFixtures.h +++ b/clang/unittests/AST/ASTImporterFixtures.h @@ -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!"; diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp index 4c53d4b7eee9d8..667e94521da131 100644 --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -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; } };" _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits