Detecting whether a Declarator is a function template

I have a ParsingDeclarator object during parsing, and I want to find out if it is a function template before a Decl* is generated for the declarator. As a first step, I used D.isDeclarationOfFunction() to make sure that the declarator is a function. Then I make sure that TemplateInfo.TemplateParams is not null. But these two checks does not catch the following case :

struct foo {
void bar(int);

The above two conditions are true for the ‘bar’ declarator. Even though bar appears within a class template, bar itself is not a function template. How do I detect this case? I suspect that the getDepth() function in TemplateParameterList should be useful, but I am not able to figure out the exact check I need to do. Any hints will be helpful.