ioeric created this revision. ioeric added a reviewer: hokein. ioeric added a subscriber: cfe-commits. Herald added a subscriber: klimek.
https://reviews.llvm.org/D28671 Files: include/clang/ASTMatchers/ASTMatchers.h unittests/ASTMatchers/ASTMatchersNodeTest.cpp Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp =================================================================== --- unittests/ASTMatchers/ASTMatchersNodeTest.cpp +++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp @@ -1494,6 +1494,22 @@ typedefNameDecl(hasName("typedefNameDeclTest2")))); } +TEST(TypeAliasTemplateDeclMatcher, Match) { + std::string Code = R"( + template <typename T> + class X { T t; }; + + template <typename T> + using typeAliasTemplateDecl = X<T>; + + using typeAliasDecl = X<int>; + )"; + EXPECT_TRUE( + matches(Code, typeAliasTemplateDecl(hasName("typeAliasTemplateDecl")))); + EXPECT_TRUE( + notMatches(Code, typeAliasTemplateDecl(hasName("typeAliasDecl")))); +} + TEST(ObjCMessageExprMatcher, SimpleExprs) { // don't find ObjCMessageExpr where none are present EXPECT_TRUE(notMatchesObjC("", objcMessageExpr(anything()))); Index: include/clang/ASTMatchers/ASTMatchers.h =================================================================== --- include/clang/ASTMatchers/ASTMatchers.h +++ include/clang/ASTMatchers/ASTMatchers.h @@ -180,6 +180,16 @@ /// matches "using Y = int", but not "typedef int X" const internal::VariadicDynCastAllOfMatcher<Decl, TypeAliasDecl> typeAliasDecl; +/// \brief Matches type alias template declarations. +/// +/// typeAliasTemplateDecl() matches +/// \code +/// template <typename T> +/// using Y = X<T>; +/// \endcode +const internal::VariadicDynCastAllOfMatcher<Decl, TypeAliasTemplateDecl> + typeAliasTemplateDecl; + /// \brief Matches AST nodes that were expanded within the main-file. /// /// Example matches X but not Y
Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp =================================================================== --- unittests/ASTMatchers/ASTMatchersNodeTest.cpp +++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp @@ -1494,6 +1494,22 @@ typedefNameDecl(hasName("typedefNameDeclTest2")))); } +TEST(TypeAliasTemplateDeclMatcher, Match) { + std::string Code = R"( + template <typename T> + class X { T t; }; + + template <typename T> + using typeAliasTemplateDecl = X<T>; + + using typeAliasDecl = X<int>; + )"; + EXPECT_TRUE( + matches(Code, typeAliasTemplateDecl(hasName("typeAliasTemplateDecl")))); + EXPECT_TRUE( + notMatches(Code, typeAliasTemplateDecl(hasName("typeAliasDecl")))); +} + TEST(ObjCMessageExprMatcher, SimpleExprs) { // don't find ObjCMessageExpr where none are present EXPECT_TRUE(notMatchesObjC("", objcMessageExpr(anything()))); Index: include/clang/ASTMatchers/ASTMatchers.h =================================================================== --- include/clang/ASTMatchers/ASTMatchers.h +++ include/clang/ASTMatchers/ASTMatchers.h @@ -180,6 +180,16 @@ /// matches "using Y = int", but not "typedef int X" const internal::VariadicDynCastAllOfMatcher<Decl, TypeAliasDecl> typeAliasDecl; +/// \brief Matches type alias template declarations. +/// +/// typeAliasTemplateDecl() matches +/// \code +/// template <typename T> +/// using Y = X<T>; +/// \endcode +const internal::VariadicDynCastAllOfMatcher<Decl, TypeAliasTemplateDecl> + typeAliasTemplateDecl; + /// \brief Matches AST nodes that were expanded within the main-file. /// /// Example matches X but not Y
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits