diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html --- a/clang/docs/LibASTMatchersReference.html +++ b/clang/docs/LibASTMatchersReference.html @@ -1491,6 +1491,11 @@ +
Matches builtin function __builtin_convertvector. +
Matches co_return statements. diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -228,6 +228,7 @@ AST Matchers ------------ +- Add ``convertVectorExpr``. clang-format ------------ diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h --- a/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/clang/include/clang/ASTMatchers/ASTMatchers.h @@ -2519,6 +2519,10 @@ extern const internal::VariadicDynCastAllOfMatcherchooseExpr; +/// Matches builtin function __builtin_convertvector. +extern const internal::VariadicDynCastAllOfMatcher + convertVectorExpr; + /// Matches GNU __null expression. extern const internal::VariadicDynCastAllOfMatcher gnuNullExpr; diff --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp --- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp +++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp @@ -941,6 +941,8 @@ const internal::VariadicDynCastAllOfMatcher cxxNullPtrLiteralExpr; const internal::VariadicDynCastAllOfMatcher chooseExpr; +const internal::VariadicDynCastAllOfMatcher + convertVectorExpr; const internal::VariadicDynCastAllOfMatcher coawaitExpr; const internal::VariadicDynCastAllOfMatcher diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp b/clang/lib/ASTMatchers/Dynamic/Registry.cpp --- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp +++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp @@ -165,6 +165,7 @@ REGISTER_MATCHER(castExpr); REGISTER_MATCHER(characterLiteral); REGISTER_MATCHER(chooseExpr); + REGISTER_MATCHER(convertVectorExpr); REGISTER_MATCHER(classTemplateDecl); REGISTER_MATCHER(classTemplatePartialSpecializationDecl); REGISTER_MATCHER(classTemplateSpecializationDecl); diff --git a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp --- a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp +++ b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp @@ -986,6 +986,17 @@ chooseExpr())); } +TEST_P(ASTMatchersTest, ConvertVectorExpr) { + EXPECT_TRUE(matches( + "typedef double vector4double __attribute__((__vector_size__(32)));" + "typedef float vector4float __attribute__((__vector_size__(16)));" + "vector4float vf;" + "void f() { (void)__builtin_convertvector(vf, vector4double); }", + convertVectorExpr())); + EXPECT_TRUE(notMatches("void f() { (void)__builtin_choose_expr(1, 2, 3); }", + convertVectorExpr())); +} + TEST_P(ASTMatchersTest, GNUNullExpr) { if (!GetParam().isCXX()) { return;