Please find a new version of the patch attached. This also fixes the same problem in nested function templates and includes corresponding tests. I am still not sure whether this is just a workaround for an underlying problem: Shouldn't the Decl fulfill isThisDeclarationADefinition()?<div>
<br></div><div>Kind regards,<br>Daniel<br><div><br><div class="gmail_quote">On Thu, Apr 12, 2012 at 10:32 PM, Daniel Jasper <span dir="ltr"><<a href="mailto:djasper@google.com">djasper@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Hi all,</div><div><br></div><div>we have noticed that the RecursiveASTMatcher does not seem to traverse nested template instantiations as in this code segment:</div>
<div><br></div><div>template <typename Rhs> struct Outer {</div>
<div>  template <typename Lhs> struct Inner {</div><div>    void Compare() {</div><div>      Lhs y;</div><div>      y.x();</div><div>    }</div><div>  };</div><div>};</div><div>struct A { void x(); };</div><div>int main() {</div>

<div>  (new Outer<A>::Inner<A>())->Compare();</div><div>}</div><div><br></div><div>Here, the templates Outer and Inner are instantiated with type A, but the Inner-instantiation is not traversed even if the RecursiveASTMatcher's subclass implements shouldVisitTemplateInstantiations() to return true. The reason is, that isThisDeclarationADefinition() does (erroneously?) return false for this instantiation. The attached patch works around this. As far as I can tell, isThisDeclarationADefinition() is checked in order to prevent forward-declared templates to be traversed multiple times. However, if this template is instantiated from a member template, this cannot happen.</div>

<div><br></div><div>Kind regards,</div><div>Daniel</div>
</blockquote></div><br></div></div>