[clang] 8baf862 - [clang][ASTMatcher] Add Matcher 'convertVectorExpr'
via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 7 06:54:53 PDT 2023
Author: dingfei
Date: 2023-08-07T21:53:14+08:00
New Revision: 8baf86275639ec332408f1e1fac0066e4f0788d2
URL: https://github.com/llvm/llvm-project/commit/8baf86275639ec332408f1e1fac0066e4f0788d2
DIFF: https://github.com/llvm/llvm-project/commit/8baf86275639ec332408f1e1fac0066e4f0788d2.diff
LOG: [clang][ASTMatcher] Add Matcher 'convertVectorExpr'
Add Matcher convertVectorExpr.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D157248
Added:
Modified:
clang/docs/LibASTMatchersReference.html
clang/docs/ReleaseNotes.rst
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/lib/ASTMatchers/ASTMatchersInternal.cpp
clang/lib/ASTMatchers/Dynamic/Registry.cpp
clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
Removed:
################################################################################
diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html
index 88153436330f43..d30e151edae05b 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -1491,6 +1491,11 @@ <h2 id="decl-matchers">Node Matchers</h2>
</pre></td></tr>
+<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('convertVectorExpr0')"><a name="convertVectorExpr0Anchor">convertVectorExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ConvertVectorExpr.html">ConvertVectorExpr</a>>...</td></tr>
+<tr><td colspan="4" class="doc" id="convertVectorExpr0"><pre>Matches builtin function __builtin_convertvector.
+</pre></td></tr>
+
+
<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('coreturnStmt0')"><a name="coreturnStmt0Anchor">coreturnStmt</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CoreturnStmt.html">CoreturnStmt</a>>...</td></tr>
<tr><td colspan="4" class="doc" id="coreturnStmt0"><pre>Matches co_return statements.
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b5fcf1b699cd49..949e3fe7d2c8d7 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -231,6 +231,7 @@ Floating Point Support in Clang
AST Matchers
------------
+- Add ``convertVectorExpr``.
- Add ``dependentSizedExtVectorType``.
clang-format
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h
index b522392a32c372..620f0cb7872f1f 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2519,6 +2519,10 @@ extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXNullPtrLiteralExpr>
extern const internal::VariadicDynCastAllOfMatcher<Stmt, ChooseExpr>
chooseExpr;
+/// Matches builtin function __builtin_convertvector.
+extern const internal::VariadicDynCastAllOfMatcher<Stmt, ConvertVectorExpr>
+ convertVectorExpr;
+
/// Matches GNU __null expression.
extern const internal::VariadicDynCastAllOfMatcher<Stmt, GNUNullExpr>
gnuNullExpr;
diff --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index dccfec35ea4081..6a2c85ef2b5176 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -941,6 +941,8 @@ const internal::VariadicDynCastAllOfMatcher<Stmt, CompoundLiteralExpr>
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXNullPtrLiteralExpr>
cxxNullPtrLiteralExpr;
const internal::VariadicDynCastAllOfMatcher<Stmt, ChooseExpr> chooseExpr;
+const internal::VariadicDynCastAllOfMatcher<Stmt, ConvertVectorExpr>
+ convertVectorExpr;
const internal::VariadicDynCastAllOfMatcher<Stmt, CoawaitExpr>
coawaitExpr;
const internal::VariadicDynCastAllOfMatcher<Stmt, DependentCoawaitExpr>
diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
index b0006483dc7cb0..0cd65d4c95cbcd 100644
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -178,6 +178,7 @@ RegistryMaps::RegistryMaps() {
REGISTER_MATCHER(constantExpr);
REGISTER_MATCHER(containsDeclaration);
REGISTER_MATCHER(continueStmt);
+ REGISTER_MATCHER(convertVectorExpr);
REGISTER_MATCHER(coreturnStmt);
REGISTER_MATCHER(coroutineBodyStmt);
REGISTER_MATCHER(coyieldExpr);
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
index 14d3360f5bdc9c..bb7d8cc771a349 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -986,6 +986,17 @@ TEST_P(ASTMatchersTest, ChooseExpr) {
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;
More information about the cfe-commits
mailing list