Index: cfe/trunk/docs/LibASTMatchersReference.html =================================================================== --- cfe/trunk/docs/LibASTMatchersReference.html +++ cfe/trunk/docs/LibASTMatchersReference.html @@ -469,6 +469,15 @@ +
Matches type alias template declarations. + +typeAliasTemplateDecl() matches + template <typename T> + using Y = X<T>; +
Matches typedef declarations. Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h =================================================================== --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h @@ -180,6 +180,16 @@ /// matches "using Y = int", but not "typedef int X" const internal::VariadicDynCastAllOfMatchertypeAliasDecl; +/// \brief Matches type alias template declarations. +/// +/// typeAliasTemplateDecl() matches +/// \code +/// template +/// using Y = X ; +/// \endcode +const internal::VariadicDynCastAllOfMatcher + typeAliasTemplateDecl; + /// \brief Matches AST nodes that were expanded within the main-file. /// /// Example matches X but not Y Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp =================================================================== --- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp +++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp @@ -417,6 +417,7 @@ REGISTER_MATCHER(typedefNameDecl); REGISTER_MATCHER(typedefType); REGISTER_MATCHER(typeAliasDecl); + REGISTER_MATCHER(typeAliasTemplateDecl); REGISTER_MATCHER(typeLoc); REGISTER_MATCHER(unaryExprOrTypeTraitExpr); REGISTER_MATCHER(unaryOperator); Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp =================================================================== --- cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp +++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp @@ -1494,6 +1494,22 @@ typedefNameDecl(hasName("typedefNameDeclTest2")))); } +TEST(TypeAliasTemplateDeclMatcher, Match) { + std::string Code = R"( + template + class X { T t; }; + + template + using typeAliasTemplateDecl = X ; + + using typeAliasDecl = X ; + )"; + 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())));