Author: dingfei Date: 2023-08-07T21:50:42+08:00 New Revision: 4cce27d9184ed5a71e296c8a18a603ec3e23b06d
URL: https://github.com/llvm/llvm-project/commit/4cce27d9184ed5a71e296c8a18a603ec3e23b06d DIFF: https://github.com/llvm/llvm-project/commit/4cce27d9184ed5a71e296c8a18a603ec3e23b06d.diff LOG: [clang][ASTMatcher] Add Matcher 'dependentSizedExtVectorType' Add Matcher dependentSizedExtVectorType for DependentSizedExtVectorType. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D157237 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 4f2a1f9508baa2..88153436330f43 100644 --- a/clang/docs/LibASTMatchersReference.html +++ b/clang/docs/LibASTMatchersReference.html @@ -2531,6 +2531,19 @@ <h2 id="decl-matchers">Node Matchers</h2> </pre></td></tr> +<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('dependentSizedExtVectorType')"><a name="dependentSizedExtVectorType0Anchor">dependentSizedExtVectorType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DependentSizedExtVectorType.html">DependentSizedExtVectorType</a>>...</td></tr> +<tr><td colspan="4" class="doc" id="dependentSizedExtVectorType0"><pre>Matches C++ extended vector type where either the type or size is dependent. + +Given + template<typename T, int Size> + class vector { + typedef T __attribute__((ext_vector_type(Size))) type; + }; +dependentSizedExtVectorType + matches "T __attribute__((ext_vector_type(Size)))" +</pre></td></tr> + + <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('elaboratedType0')"><a name="elaboratedType0Anchor">elaboratedType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>>...</td></tr> <tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a qualified name. diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 4d1ca7afad1f10..b5fcf1b699cd49 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -231,6 +231,7 @@ Floating Point Support in Clang AST Matchers ------------ +- Add ``dependentSizedExtVectorType``. clang-format ------------ diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h index f49204a3d90626..b522392a32c372 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/clang/include/clang/ASTMatchers/ASTMatchers.h @@ -6938,6 +6938,21 @@ AST_POLYMORPHIC_MATCHER_P(hasSize, /// matches "T data[Size]" extern const AstTypeMatcher<DependentSizedArrayType> dependentSizedArrayType; +/// Matches C++ extended vector type where either the type or size is +/// dependent. +/// +/// Given +/// \code +/// template<typename T, int Size> +/// class vector { +/// typedef T __attribute__((ext_vector_type(Size))) type; +/// }; +/// \endcode +/// dependentSizedExtVectorType +/// matches "T __attribute__((ext_vector_type(Size)))" +extern const AstTypeMatcher<DependentSizedExtVectorType> + dependentSizedExtVectorType; + /// Matches C arrays with unspecified size. /// /// Given diff --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp index 3470467112dd5f..dccfec35ea4081 100644 --- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp +++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp @@ -1046,6 +1046,7 @@ const AstTypeMatcher<ConstantArrayType> constantArrayType; const AstTypeMatcher<DeducedTemplateSpecializationType> deducedTemplateSpecializationType; const AstTypeMatcher<DependentSizedArrayType> dependentSizedArrayType; +const AstTypeMatcher<DependentSizedExtVectorType> dependentSizedExtVectorType; const AstTypeMatcher<IncompleteArrayType> incompleteArrayType; const AstTypeMatcher<VariableArrayType> variableArrayType; const AstTypeMatcher<AtomicType> atomicType; diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp b/clang/lib/ASTMatchers/Dynamic/Registry.cpp index 1098df032a64b9..b0006483dc7cb0 100644 --- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp +++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp @@ -227,6 +227,7 @@ RegistryMaps::RegistryMaps() { REGISTER_MATCHER(defaultStmt); REGISTER_MATCHER(dependentCoawaitExpr); REGISTER_MATCHER(dependentSizedArrayType); + REGISTER_MATCHER(dependentSizedExtVectorType); REGISTER_MATCHER(designatedInitExpr); REGISTER_MATCHER(designatorCountIs); REGISTER_MATCHER(doStmt); diff --git a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp index d2abd87115b50c..14d3360f5bdc9c 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp +++ b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp @@ -1560,6 +1560,20 @@ TEST_P(ASTMatchersTest, DependentSizedArrayType) { dependentSizedArrayType())); } +TEST_P(ASTMatchersTest, DependentSizedExtVectorType) { + if (!GetParam().isCXX()) { + return; + } + EXPECT_TRUE(matches("template<typename T, int Size>" + "class vector {" + " typedef T __attribute__((ext_vector_type(Size))) type;" + "};", + dependentSizedExtVectorType())); + EXPECT_TRUE( + notMatches("int a[42]; int b[] = { 2, 3 }; void f() { int c[b[0]]; }", + dependentSizedExtVectorType())); +} + TEST_P(ASTMatchersTest, IncompleteArrayType) { EXPECT_TRUE(matches("int a[] = { 2, 3 };", incompleteArrayType())); EXPECT_TRUE(matches("void f(int a[]) {}", incompleteArrayType())); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits