danix800 created this revision. Herald added a subscriber: ChuanqiXu. Herald added a project: All. danix800 requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Add a few type-related Matchers - bitIntType - constantMatrixType - dependentAddressSpaceType - dependentBitIntType - dependentSizedMatrixType - dependentVectorType - hasTypeForDecl - objcTypeParamDecl - objcTypeParamType - pipeType - vectorType Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D158872 Files: clang/docs/LibASTMatchersReference.html clang/docs/ReleaseNotes.rst clang/include/clang/ASTMatchers/ASTMatchers.h clang/lib/ASTMatchers/ASTMatchFinder.cpp clang/lib/ASTMatchers/ASTMatchersInternal.cpp clang/lib/ASTMatchers/Dynamic/Registry.cpp clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp clang/unittests/ASTMatchers/ASTMatchersTest.h
Index: clang/unittests/ASTMatchers/ASTMatchersTest.h =================================================================== --- clang/unittests/ASTMatchers/ASTMatchersTest.h +++ clang/unittests/ASTMatchers/ASTMatchersTest.h @@ -284,6 +284,33 @@ {"-fopenmp=libomp", "-fopenmp-version=51"}); } +template <typename T> +testing::AssertionResult matchesOpenCL(const Twine &Code, const T &AMatcher) { + return matchesConditionally(Code, AMatcher, true, + {"-x", "cl", "-cl-no-stdinc", "-cl-std=CL2.0"}, + FileContentMappings(), "input.cl"); +} + +template <typename T> +testing::AssertionResult notMatchesOpenCL(const Twine &Code, + const T &AMatcher) { + return matchesConditionally(Code, AMatcher, false, + {"-x", "cl", "-cl-no-stdinc", "-cl-std=CL2.0"}, + FileContentMappings(), "input.cl"); +} + +template <typename T> +testing::AssertionResult matchesWithMatrixEnabled(const Twine &Code, + const T &AMatcher) { + return matchesConditionally(Code, AMatcher, true, {"-fenable-matrix"}); +} + +template <typename T> +testing::AssertionResult notMatchesWithMatrixEnabled(const Twine &Code, + const T &AMatcher) { + return matchesConditionally(Code, AMatcher, false, {"-fenable-matrix"}); +} + template <typename T> testing::AssertionResult matchAndVerifyResultConditionally( const Twine &Code, const T &AMatcher, Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp =================================================================== --- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp +++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp @@ -1549,6 +1549,89 @@ EXPECT_TRUE(matches("struct S {};", qualType().bind("loc"))); } +TEST_P(ASTMatchersTest, BitIntType) { + StringRef code = "_BitInt(10) i;"; + EXPECT_TRUE(matches(code, varDecl(hasType(bitIntType())))); + EXPECT_TRUE(notMatches(code, varDecl(hasType(builtinType())))); +} + +TEST_P(ASTMatchersTest, ConstantMatrixType) { + StringRef Code = "typedef int __attribute__((matrix_type(5, 5))) X;"; + + EXPECT_TRUE(matchesWithMatrixEnabled( + Code, typedefDecl(hasType(constantMatrixType())))); + EXPECT_TRUE( + notMatchesWithMatrixEnabled(Code, typedefDecl(hasType(vectorType())))); +} + +TEST_P(ASTMatchersTest, DependentAddressSpaceType) { + if (!GetParam().isCXX()) + return; + + StringRef Code = "template<typename T, int AddrSpace>" + "class vector {" + " typedef T __attribute__((address_space(AddrSpace))) X;" + "};"; + EXPECT_TRUE(matches(Code, typedefDecl(hasType(dependentAddressSpaceType())))); + + EXPECT_TRUE(notMatches("int __attribute__((address_space(0))) X;", + typedefDecl(hasType(dependentAddressSpaceType())))); +} + +TEST_P(ASTMatchersTest, DependentBitIntType) { + if (!GetParam().isCXX11OrLater()) + return; + + EXPECT_TRUE(matches("template<int Width> using X = _BitInt(Width);", + typeAliasDecl(hasType(dependentBitIntType())))); + + EXPECT_TRUE(notMatches("typedef _BitInt(10) Int10;", + typedefDecl(hasType(dependentBitIntType())))); +} + +TEST_P(ASTMatchersTest, DependentVectorType) { + if (!GetParam().isCXX()) + return; + + StringRef DepCode = "template<typename T, int Size>" + "class vector {" + " typedef T __attribute__((vector_size(Size))) X;" + "};"; + EXPECT_TRUE(matches(DepCode, dependentVectorType())); + + StringRef NonDepCode = "typedef int __attribute__((vector_size(16))) X;"; + EXPECT_TRUE(notMatches(NonDepCode, dependentVectorType())); +} + +TEST_P(ASTMatchersTest, VectorType) { + if (!GetParam().isCXX()) + return; + + StringRef NonDepCode = "typedef int __attribute__((vector_size(16))) X;"; + EXPECT_TRUE(matches(NonDepCode, vectorType())); + + StringRef DepCode = "template<typename T, int Size>" + "class vector {" + " typedef T __attribute__((vector_size(Size))) X;" + "};"; + EXPECT_TRUE(notMatches(DepCode, vectorType())); +} + +TEST_P(ASTMatchersTest, DependentSizedMatrixType) { + if (!GetParam().isCXX()) + return; + + StringRef DepCode = "template<typename T, int Rows, int Cols>" + "class matrix {" + " typedef T __attribute__((matrix_type(Rows, Cols))) X;" + "};"; + EXPECT_TRUE(matchesWithMatrixEnabled(DepCode, dependentSizedMatrixType())); + + StringRef NonDepCode = "typedef int __attribute__((matrix_type(3, 3))) Y;"; + EXPECT_TRUE( + notMatchesWithMatrixEnabled(NonDepCode, dependentSizedMatrixType())); +} + TEST_P(ASTMatchersTest, ConstantArrayType) { EXPECT_TRUE(matches("int a[2];", constantArrayType())); EXPECT_TRUE(notMatches("void f() { int a[] = { 2, 3 }; int b[a[0]]; }", @@ -2518,6 +2601,28 @@ EXPECT_TRUE(matchesObjC(ObjCString, objcFinallyStmt())); } +TEST(ASTMatchersTestObjC, ObjCTypeParamDecl) { + StringRef ObjCString = "@interface Dictionary <FirstParam: id>" + "@end"; + EXPECT_TRUE(matchesObjC(ObjCString, objcTypeParamDecl())); + EXPECT_TRUE(notMatchesObjC(ObjCString, parmVarDecl())); +} + +TEST(ASTMatchersTestObjC, ObjCTypeParamType) { + StringRef ObjCString = "@interface Dictionary <FirstParam: id>" + "@end"; + EXPECT_TRUE(matchesObjC( + ObjCString, objcTypeParamDecl(hasTypeForDecl(objcTypeParamType())))); + EXPECT_TRUE(notMatchesObjC(ObjCString, + objcTypeParamDecl(hasTypeForDecl(builtinType())))); +} + +TEST(ASTMatchersTestOpenCL, PipeType) { + StringRef code = "typedef pipe int X;"; + EXPECT_TRUE(matchesOpenCL(code, typedefDecl(hasType(pipeType())))); + EXPECT_TRUE(notMatchesOpenCL(code, typedefDecl(hasType(isInteger())))); +} + TEST(ASTMatchersTest, DecompositionDecl) { StringRef Code = R"cpp( void foo() Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp =================================================================== --- clang/lib/ASTMatchers/Dynamic/Registry.cpp +++ clang/lib/ASTMatchers/Dynamic/Registry.cpp @@ -151,6 +151,7 @@ REGISTER_MATCHER(binaryOperator); REGISTER_MATCHER(binaryOperation); REGISTER_MATCHER(bindingDecl); + REGISTER_MATCHER(bitIntType); REGISTER_MATCHER(blockDecl); REGISTER_MATCHER(blockExpr); REGISTER_MATCHER(blockPointerType); @@ -176,6 +177,7 @@ REGISTER_MATCHER(conditionalOperator); REGISTER_MATCHER(constantArrayType); REGISTER_MATCHER(constantExpr); + REGISTER_MATCHER(constantMatrixType); REGISTER_MATCHER(containsDeclaration); REGISTER_MATCHER(continueStmt); REGISTER_MATCHER(convertVectorExpr); @@ -226,9 +228,13 @@ REGISTER_MATCHER(decltypeType); REGISTER_MATCHER(deducedTemplateSpecializationType); REGISTER_MATCHER(defaultStmt); + REGISTER_MATCHER(dependentAddressSpaceType); + REGISTER_MATCHER(dependentBitIntType); REGISTER_MATCHER(dependentCoawaitExpr); REGISTER_MATCHER(dependentSizedArrayType); REGISTER_MATCHER(dependentSizedExtVectorType); + REGISTER_MATCHER(dependentSizedMatrixType); + REGISTER_MATCHER(dependentVectorType); REGISTER_MATCHER(designatedInitExpr); REGISTER_MATCHER(designatorCountIs); REGISTER_MATCHER(doStmt); @@ -371,6 +377,7 @@ REGISTER_MATCHER(hasThreadStorageDuration); REGISTER_MATCHER(hasTrailingReturn); REGISTER_MATCHER(hasTrueExpression); + REGISTER_MATCHER(hasTypeForDecl); REGISTER_MATCHER(hasTypeLoc); REGISTER_MATCHER(hasUnaryOperand); REGISTER_MATCHER(hasUnarySelector); @@ -517,6 +524,8 @@ REGISTER_MATCHER(objcStringLiteral); REGISTER_MATCHER(objcThrowStmt); REGISTER_MATCHER(objcTryStmt); + REGISTER_MATCHER(objcTypeParamDecl); + REGISTER_MATCHER(objcTypeParamType); REGISTER_MATCHER(ofClass); REGISTER_MATCHER(ofKind); REGISTER_MATCHER(ompDefaultClause); @@ -530,6 +539,7 @@ REGISTER_MATCHER(parenListExpr); REGISTER_MATCHER(parenType); REGISTER_MATCHER(parmVarDecl); + REGISTER_MATCHER(pipeType); REGISTER_MATCHER(pointee); REGISTER_MATCHER(pointerType); REGISTER_MATCHER(pointerTypeLoc); @@ -599,6 +609,7 @@ REGISTER_MATCHER(valueDecl); REGISTER_MATCHER(varDecl); REGISTER_MATCHER(variableArrayType); + REGISTER_MATCHER(vectorType); REGISTER_MATCHER(voidType); REGISTER_MATCHER(whileStmt); REGISTER_MATCHER(withInitializer); Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp =================================================================== --- clang/lib/ASTMatchers/ASTMatchersInternal.cpp +++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp @@ -839,6 +839,8 @@ const internal::VariadicDynCastAllOfMatcher<Decl, ObjCIvarDecl> objcIvarDecl; const internal::VariadicDynCastAllOfMatcher<Decl, ObjCPropertyDecl> objcPropertyDecl; +const internal::VariadicDynCastAllOfMatcher<Decl, ObjCTypeParamDecl> + objcTypeParamDecl; const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCAtThrowStmt> objcThrowStmt; const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCAtTryStmt> objcTryStmt; @@ -1049,6 +1051,15 @@ deducedTemplateSpecializationType; const AstTypeMatcher<DependentSizedArrayType> dependentSizedArrayType; const AstTypeMatcher<DependentSizedExtVectorType> dependentSizedExtVectorType; +const AstTypeMatcher<BitIntType> bitIntType; +const AstTypeMatcher<DependentBitIntType> dependentBitIntType; +const AstTypeMatcher<DependentAddressSpaceType> dependentAddressSpaceType; +const AstTypeMatcher<ConstantMatrixType> constantMatrixType; +const AstTypeMatcher<DependentSizedMatrixType> dependentSizedMatrixType; +const AstTypeMatcher<DependentVectorType> dependentVectorType; +const AstTypeMatcher<VectorType> vectorType; +const AstTypeMatcher<PipeType> pipeType; +const AstTypeMatcher<ObjCTypeParamType> objcTypeParamType; const AstTypeMatcher<IncompleteArrayType> incompleteArrayType; const AstTypeMatcher<VariableArrayType> variableArrayType; const AstTypeMatcher<AtomicType> atomicType; Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp =================================================================== --- clang/lib/ASTMatchers/ASTMatchFinder.cpp +++ clang/lib/ASTMatchers/ASTMatchFinder.cpp @@ -504,6 +504,7 @@ bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS); bool TraverseConstructorInitializer(CXXCtorInitializer *CtorInit); bool TraverseTemplateArgumentLoc(TemplateArgumentLoc TAL); + bool TraverseObjCTypeParamDecl(ObjCTypeParamDecl *TPD); bool TraverseAttr(Attr *AttrNode); bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue) { @@ -1521,6 +1522,11 @@ return RecursiveASTVisitor<MatchASTVisitor>::TraverseTemplateArgumentLoc(Loc); } +bool MatchASTVisitor::TraverseObjCTypeParamDecl(ObjCTypeParamDecl *TPD) { + match(*TPD); + return RecursiveASTVisitor<MatchASTVisitor>::TraverseObjCTypeParamDecl(TPD); +} + bool MatchASTVisitor::TraverseAttr(Attr *AttrNode) { match(*AttrNode); return RecursiveASTVisitor<MatchASTVisitor>::TraverseAttr(AttrNode); Index: clang/include/clang/ASTMatchers/ASTMatchers.h =================================================================== --- clang/include/clang/ASTMatchers/ASTMatchers.h +++ clang/include/clang/ASTMatchers/ASTMatchers.h @@ -3968,6 +3968,15 @@ return false; } +/// Matches the type object that represents this TypeDecl. +AST_MATCHER_P(TypeDecl, hasTypeForDecl, internal::Matcher<QualType>, + InnerMatcher) { + QualType QT(Node.getTypeForDecl(), 0); + if (!QT.isNull()) + return InnerMatcher.matches(QT, Finder, Builder); + return false; +} + /// Overloaded to match the declaration of the expression's or value /// declaration's type. /// @@ -7049,6 +7058,124 @@ /// matches "decltype(i + j)" extern const AstTypeMatcher<DecltypeType> decltypeType; +/// Matches _BitInt types. +/// +/// Given +/// \code +/// _BitInt(10) i; +/// \endcode +/// bitIntType() +/// matches "_BitInt(10) i" +extern const AstTypeMatcher<BitIntType> bitIntType; + +/// Matches matrix types of constant size. +/// +/// Given +/// \code +/// typedef int __attribute__((matrix_type(5, 5))) X; +/// \endcode +/// constantMatrixType() +/// matches the type of the typedef declaration "X". +extern const AstTypeMatcher<ConstantMatrixType> constantMatrixType; + +/// Matches an extended address space qualifier where the input address space +/// value is dependent. +/// +/// Given +/// \code +/// template<typename T, int AddrSpace> +/// class AddressSpace { +/// typedef T __attribute__((address_space(AddrSpace))) X; +/// }; +/// \endcode +/// dependentAddressSpaceType() +/// matches the type of the typedef declaration "X". +extern const AstTypeMatcher<DependentAddressSpaceType> + dependentAddressSpaceType; + +/// Matches bitint types where the bitwidth is dependent. +/// +/// Given +/// \code +/// template<int Width> using X = _BitInt(Width); +/// \endcode +/// dependentBitIntType() +/// matches the type of the type alias declaration "X". +extern const AstTypeMatcher<DependentBitIntType> dependentBitIntType; + +/// Matches vector types where either the type or size is dependent. +/// +/// Given +/// \code +/// template<typename T, int Size> +/// class vector { +/// typedef T __attribute__((vector_size(Size))) X; +/// }; +/// typedef int __attribute__((vector_size(12))) Y; +/// \endcode +/// dependentVectorType() +/// matches the type of the typedef declaration "X" but not "Y". +extern const AstTypeMatcher<DependentVectorType> dependentVectorType; + +/// Matches a matrix type where the type and the number of rows and columns +/// is dependent. +/// +/// Given +/// \code +/// template<typename T, int Rows, int Cols> +/// class matrix { +/// typedef T __attribute__((matrix_type(Rows, Cols))) X; +/// }; +/// typedef int __attribute__((matrix_type(3, 3))) Y; +/// \endcode +/// dependentSizedMatrixType() +/// matches the type of the typedef declaration "X" but not "Y". +extern const AstTypeMatcher<DependentSizedMatrixType> dependentSizedMatrixType; + +/// Matches vector types. +/// +/// Given +/// \code +/// typedef int __attribute__((vector_size(12))) X; +/// \endcode +/// vectorType() +/// matches the type of the typedef declaration "X". +extern const AstTypeMatcher<VectorType> vectorType; + +/// Matches Objective-C type parameter types. +/// +/// Given +/// \code +/// @interface Dictionary <FirstParam: id> +/// @end +/// \endcode +/// objcTypeParamType() +/// matches the type of type-parameter "FirstParam". +extern const AstTypeMatcher<ObjCTypeParamType> objcTypeParamType; + +/// Matches the declaration of an Objective-C type parameter. +/// +/// Given +/// \code +/// @interface Dictionary <FirstParam: id> +/// @end +/// \endcode +/// objcTypeParamDecl() +/// matches the type-parameter declaration "FirstParam". +extern const internal::VariadicDynCastAllOfMatcher<Decl, ObjCTypeParamDecl> + objcTypeParamDecl; + +/// Matches OpenCL pipe types. +/// +/// Given +/// \code +/// typedef pipe int X; +/// typedef int Y; +/// \endcode +/// pipeType() +/// matches the type of the typedef declaration \c X but not \c Y. +extern const AstTypeMatcher<PipeType> pipeType; + /// Matches \c AutoType nodes where the deduced type is a specific type. /// /// Note: There is no \c TypeLoc for the deduced type and thus no Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -293,9 +293,20 @@ AST Matchers ------------ +- Add ``bitIntType``. +- Add ``constantMatrixType``. - Add ``convertVectorExpr``. +- Add ``dependentAddressSpaceType``. +- Add ``dependentBitIntType``. - Add ``dependentSizedExtVectorType``. +- Add ``dependentSizedMatrixType``. +- Add ``dependentVectorType``. - Add ``macroQualifiedType``. +- Add ``hasTypeForDecl``. +- Add ``objcTypeParamDecl``. +- Add ``objcTypeParamType``. +- Add ``pipeType``. +- Add ``vectorType``. clang-format ------------ Index: clang/docs/LibASTMatchersReference.html =================================================================== --- clang/docs/LibASTMatchersReference.html +++ clang/docs/LibASTMatchersReference.html @@ -996,6 +996,17 @@ </pre></td></tr> +<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html";>Decl</a>></td><td class="name" onclick="toggle('objcTypeParamDecl0')"><a name="objcTypeParamDecl0Anchor">objcTypeParamDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCTypeParamDecl.html";>ObjCTypeParamDecl</a>>...</td></tr> +<tr><td colspan="4" class="doc" id="objcTypeParamDecl0"><pre>Matches the declaration of an Objective-C type parameter. + +Given + @interface Dictionary <FirstParam: id> + @end +objcTypeParamDecl() + matches the type-parameter declaration "FirstParam". +</pre></td></tr> + + <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html";>Decl</a>></td><td class="name" onclick="toggle('parmVarDecl0')"><a name="parmVarDecl0Anchor">parmVarDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html";>ParmVarDecl</a>>...</td></tr> <tr><td colspan="4" class="doc" id="parmVarDecl0"><pre>Matches parameter variable declarations. @@ -2439,6 +2450,16 @@ </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('bitIntType0')"><a name="bitIntType0Anchor">bitIntType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BitIntType.html";>BitIntType</a>>...</td></tr> +<tr><td colspan="4" class="doc" id="bitIntType0"><pre>Matches _BitInt types. + +Given: + _BitInt(10) i; +bitIntType() + matches "_BitInt(10) i". +</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('blockPointerType0')"><a name="blockPointerType0Anchor">blockPointerType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html";>BlockPointerType</a>>...</td></tr> <tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as "void (^)(int)". @@ -2485,6 +2506,16 @@ </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('constantMatrixType0')"><a name="constantMatrixType0Anchor">constantMatrixType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ConstantMatrixType.html";>ConstantMatrixType</a>>...</td></tr> +<tr><td colspan="4" class="doc" id="constantMatrixType0"><pre>Matches matrix types of constant size. + +Given: + typedef int __attribute__((matrix_type(5, 5))) X; +constantMatrixType() + matches the type of the typedef declaration "X". +</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('decayedType0')"><a name="decayedType0Anchor">decayedType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DecayedType.html";>DecayedType</a>>...</td></tr> <tr><td colspan="4" class="doc" id="decayedType0"><pre>Matches decayed type Example matches i[] in declaration of f. @@ -2523,6 +2554,30 @@ </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('dependentAddressSpaceType0')"><a name="dependentAddressSpaceType0Anchor">dependentAddressSpaceType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DependentAddressSpaceType.html";>DependentAddressSpaceType</a>>...</td></tr> +<tr><td colspan="4" class="doc" id="dependentAddressSpaceType0"><pre>Matches an extended address space qualifier where the +input address space value is dependent. + +Given + template<typename T, int AddrSpace> + class AddressSpace { + typedef T __attribute__((address_space(AddrSpace))) X; + }; +dependentAddressSpaceType() + matches the type of the typedef declaration "X". +</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('dependentBitIntType0')"><a name="dependentBitIntType0Anchor">dependentBitIntType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DependentBitIntType.html";>DependentBitIntType</a>>...</td></tr> +<tr><td colspan="4" class="doc" id="dependentBitIntType0"><pre>Matches _BitInt types where the bit width is dependent. + +Given + template<int Width> using X = _BitInt(Width); +dependentBitIntType() + matches the type of the type alias declaration "X". +</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('dependentSizedArrayType0')"><a name="dependentSizedArrayType0Anchor">dependentSizedArrayType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DependentSizedArrayType.html";>DependentSizedArrayType</a>>...</td></tr> <tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression. @@ -2549,6 +2604,35 @@ </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('dependentSizedMatrixType0')"><a name="dependentSizedMatrixType0Anchor">dependentSizedMatrixType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DependentSizedMatrixType.html";>DependentSizedMatrixType</a>>...</td></tr> +<tr><td colspan="4" class="doc" id="dependentSizedMatrixType0"><pre>Matches a matrix type where the type and the number of rows +and columns is dependent. + +Given + template<typename T, int Rows, int Cols> + class matrix { + typedef T __attribute__((matrix_type(Rows, Cols))) X; + }; + typedef int __attribute__((matrix_type(3, 3))) Y; +dependentSizedMatrixType() + matches the type of the typedef declaration "X" but not "Y". +</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('dependentVectorType0')"><a name="dependentVectorType0Anchor">dependentVectorType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DependentVectorType.html";>DependentVectorType</a>>...</td></tr> +<tr><td colspan="4" class="doc" id="dependentVectorType0"><pre>Matches vector types where either the type or size is dependent. + +Given + template<typename T, int Size> + class vector { + typedef T __attribute__((vector_size(Size))) X; + }; + typedef int __attribute__((vector_size(12))) Y; +dependentVectorType() + matches the type of the typedef declaration "X" but not "Y". +</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. @@ -2680,11 +2764,22 @@ @interface Foo @end Foo *f; -pointerType() +objcObjectPointerType() matches "Foo *f", but does not match "int *a". </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('objcTypeParamType0')"><a name="objcTypeParamType0Anchor">objcTypeParamType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCTypeParamType.html";>ObjCTypeParamType</a>>...</td></tr> +<tr><td colspan="4" class="doc" id="objcTypeParamType0"><pre>Matches Objective-C type parameter types. + +Given + @interface Dictionary <FirstParam: id> + @end +objcTypeParamType() + matches the type of type-parameter "FirstParam". +</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('parenType0')"><a name="parenType0Anchor">parenType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParenType.html";>ParenType</a>>...</td></tr> <tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes. @@ -2697,6 +2792,17 @@ </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('pipeType0')"><a name="pipeType0Anchor">pipeType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1PipeType.html";>PipeType</a>>...</td></tr> +<tr><td colspan="4" class="doc" id="pipeType0"><pre>Matches OpenCL pipe types. + +Given + typedef pipe int X; + typedef int Y; +pipeType() + matches the type of the typedef declaration "X" but not "Y". +</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('pointerType0')"><a name="pointerType0Anchor">pointerType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1PointerType.html";>PointerType</a>>...</td></tr> <tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types, but does not match Objective-C object pointer types. @@ -2866,6 +2972,16 @@ matches "int c[a[0]]" </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('vectorType0')"><a name="vectorType0Anchor">vectorType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VectorType.html";>VectorType</a>>...</td></tr> +<tr><td colspan="4" class="doc" id="vectorType0"><pre>Matches vector types. + +Given + typedef int __attribute__((vector_size(12))) X; +vectorType() + matches the type of the typedef declaration "X". +</pre></td></tr> + <!--END_DECL_MATCHERS --> </table> @@ -9918,6 +10034,11 @@ </pre></td></tr> +<tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeDecl.html";>TypeDecl</a>></td><td class="name" onclick="toggle('hasTypeForDecl0')"><a name="hasTypeForDecl0Anchor">hasTypeForDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html";>QualType</a>> InnerMatcher</td></tr> +<tr><td colspan="4" class="doc" id="hasTypeForDecl0"><pre>Matches the type object that represents this TypeDecl. +</pre></td></tr> + + <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html";>TypedefNameDecl</a>></td><td class="name" onclick="toggle('hasTypeLoc13')"><a name="hasTypeLoc13Anchor">hasTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html";>TypeLoc</a>> Inner</td></tr> <tr><td colspan="4" class="doc" id="hasTypeLoc13"><pre>Matches if the type location of a node matches the inner matcher.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits