<div dir="ltr">Oops, I only saw this after landing the patch. I'll send another one to update the doc. Sorry about that!</div><br><div class="gmail_quote"><div dir="ltr">On Wed, Feb 21, 2018 at 2:54 PM Aaron Ballman <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, Feb 21, 2018 at 8:51 AM, Eric Liu via cfe-commits<br>
<<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<br>
> Author: ioeric<br>
> Date: Wed Feb 21 05:51:27 2018<br>
> New Revision: 325678<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=325678&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=325678&view=rev</a><br>
> Log:<br>
> [ASTMatchers] isTemplateInstantiation: also match explicit instantiation declaration.<br>
><br>
> Summary:<br>
> Example:<br>
> template <typename T> class X {}; class A {};<br>
> // Explicit instantiation declaration.<br>
> extern template class X<A>;<br>
><br>
> Reviewers: bkramer<br>
><br>
> Subscribers: klimek, cfe-commits<br>
><br>
> Differential Revision: <a href="https://reviews.llvm.org/D43567" rel="noreferrer" target="_blank">https://reviews.llvm.org/D43567</a><br>
><br>
> Modified:<br>
>     cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h<br>
>     cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp<br>
<br>
Please regenerate the AST matcher documentation as well.<br>
<br>
~Aaron<br>
<br>
><br>
> Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=325678&r1=325677&r2=325678&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=325678&r1=325677&r2=325678&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)<br>
> +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Wed Feb 21 05:51:27 2018<br>
> @@ -4649,6 +4649,10 @@ AST_MATCHER_P(UsingShadowDecl, hasTarget<br>
>  /// \code<br>
>  ///   template <typename T> class X {}; class A {}; template class X<A>;<br>
>  /// \endcode<br>
> +/// or<br>
> +/// \code<br>
> +///   template <typename T> class X {}; class A {}; extern template class X<A>;<br>
> +/// \endcode<br>
>  /// cxxRecordDecl(hasName("::X"), isTemplateInstantiation())<br>
>  ///   matches the template instantiation of X<A>.<br>
>  ///<br>
> @@ -4666,7 +4670,9 @@ AST_POLYMORPHIC_MATCHER(isTemplateInstan<br>
>                                                          CXXRecordDecl)) {<br>
>    return (Node.getTemplateSpecializationKind() == TSK_ImplicitInstantiation ||<br>
>            Node.getTemplateSpecializationKind() ==<br>
> -          TSK_ExplicitInstantiationDefinition);<br>
> +              TSK_ExplicitInstantiationDefinition ||<br>
> +          Node.getTemplateSpecializationKind() ==<br>
> +              TSK_ExplicitInstantiationDeclaration);<br>
>  }<br>
><br>
>  /// \brief Matches declarations that are template instantiations or are inside<br>
><br>
> Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp?rev=325678&r1=325677&r2=325678&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp?rev=325678&r1=325677&r2=325678&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp (original)<br>
> +++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp Wed Feb 21 05:51:27 2018<br>
> @@ -1623,6 +1623,14 @@ TEST(IsTemplateInstantiation, MatchesExp<br>
>        "template class X<A>;",<br>
>      cxxRecordDecl(isTemplateInstantiation(), hasDescendant(<br>
>        fieldDecl(hasType(recordDecl(hasName("A"))))))));<br>
> +<br>
> +  // Make sure that we match the instantiation instead of the template<br>
> +  // definition by checking whether the member function is present.<br>
> +  EXPECT_TRUE(<br>
> +      matches("template <typename T> class X { void f() { T t; } };"<br>
> +              "extern template class X<int>;",<br>
> +              cxxRecordDecl(isTemplateInstantiation(),<br>
> +                            unless(hasDescendant(varDecl(hasName("t")))))));<br>
>  }<br>
><br>
>  TEST(IsTemplateInstantiation,<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>