This revision was automatically updated to reflect the committed changes. Closed by commit rGec483c29a95c: [clang][ASTMatcher] Add matcher for 'MacroQualifiedType' (authored by dingfei <fd...@feysh.com>).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D157777/new/ https://reviews.llvm.org/D157777 Files: 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
Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp =================================================================== --- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp +++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp @@ -1838,6 +1838,20 @@ namesType(typedefType())))))); } +TEST_P(ASTMatchersTest, MacroQualifiedType) { + EXPECT_TRUE(matches( + R"( + #define CDECL __attribute__((cdecl)) + typedef void (CDECL *X)(); + )", + typedefDecl(hasType(pointerType(pointee(macroQualifiedType())))))); + EXPECT_TRUE(notMatches( + R"( + typedef void (__attribute__((cdecl)) *Y)(); + )", + typedefDecl(hasType(pointerType(pointee(macroQualifiedType())))))); +} + TEST_P(ASTMatchersTest, TemplateSpecializationType) { if (!GetParam().isCXX()) { return; Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp =================================================================== --- clang/lib/ASTMatchers/Dynamic/Registry.cpp +++ clang/lib/ASTMatchers/Dynamic/Registry.cpp @@ -485,6 +485,7 @@ REGISTER_MATCHER(lambdaCapture); REGISTER_MATCHER(lambdaExpr); REGISTER_MATCHER(linkageSpecDecl); + REGISTER_MATCHER(macroQualifiedType); REGISTER_MATCHER(materializeTemporaryExpr); REGISTER_MATCHER(member); REGISTER_MATCHER(memberExpr); Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp =================================================================== --- clang/lib/ASTMatchers/ASTMatchersInternal.cpp +++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp @@ -1058,6 +1058,7 @@ const AstTypeMatcher<FunctionProtoType> functionProtoType; const AstTypeMatcher<ParenType> parenType; const AstTypeMatcher<BlockPointerType> blockPointerType; +const AstTypeMatcher<MacroQualifiedType> macroQualifiedType; const AstTypeMatcher<MemberPointerType> memberPointerType; const AstTypeMatcher<PointerType> pointerType; const AstTypeMatcher<ObjCObjectPointerType> objcObjectPointerType; Index: clang/include/clang/ASTMatchers/ASTMatchers.h =================================================================== --- clang/include/clang/ASTMatchers/ASTMatchers.h +++ clang/include/clang/ASTMatchers/ASTMatchers.h @@ -7258,6 +7258,18 @@ /// matches "typedef int X" extern const AstTypeMatcher<TypedefType> typedefType; +/// Matches qualified types when the qualifier is applied via a macro. +/// +/// Given +/// \code +/// #define CDECL __attribute__((cdecl)) +/// typedef void (CDECL *X)(); +/// typedef void (__attribute__((cdecl)) *Y)(); +/// \endcode +/// macroQualifiedType() +/// matches the type of the typedef declaration of \c X but not \c Y. +extern const AstTypeMatcher<MacroQualifiedType> macroQualifiedType; + /// Matches enum types. /// /// Given Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -252,6 +252,7 @@ ------------ - Add ``convertVectorExpr``. - Add ``dependentSizedExtVectorType``. +- Add ``macroQualifiedType``. clang-format ------------ Index: clang/docs/LibASTMatchersReference.html =================================================================== --- clang/docs/LibASTMatchersReference.html +++ clang/docs/LibASTMatchersReference.html @@ -2648,6 +2648,18 @@ </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('macroQualifiedType0')"><a name="macroQualifiedType0Anchor">macroQualifiedType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MacroQualifiedType.html">MacroQualifiedType</a>>...</td></tr> +<tr><td colspan="4" class="doc" id="macroQualifiedType0"><pre>Matches qualified types when the qualifier is applied via a macro. + +Given + #define CDECL __attribute__((cdecl)) + typedef void (CDECL *X)(); + typedef void (__attribute__((cdecl)) *Y)(); +macroQualifiedType() + matches the type of the typedef declaration of 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('memberPointerType0')"><a name="memberPointerType0Anchor">memberPointerType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>...</td></tr> <tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types. Given
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits