Finding uses of functions with a TemplateType argument

Bertjan Broeksema bertjan at kdab.net
Tue Oct 20 09:24:12 UTC 2009


On Monday 19 October 2009 16:35:13 David Nolden wrote:
> Am Montag 19 Oktober 2009 13:03:16 schrieb Bertjan Broeksema:
> > Hi All,
> >
> > Suppose I have:
> >
> > template <class type>
> > class MyClass {
> >   void blah(const type*);
> > };
> >
> > Now I want to build a query which finds all uses of "blah(const type*)"
> >
> > When I arrive at the function declaration the argument does not seem to
> >  have any hint that it actually is an template type. However, when I
>
> The argument-type should be a "KDevelop::DelayedType", which is used only
> for template-dependent not-yet-resolved types, or for unresolved types.

I think this is the problem indeed. The parameter of the ArgumentType from the 
declaration is an delayed type and the ArgumentType that comes out of the 
evaluation parser is an CppTemplateParameterType type, which inherits from 
Identified type. Thats why the comparison goes wrong. I wonder what the best 
approach to make this work would be. Because to be able to iterate over all 
instantiations I still need to find the right method first.

> >  evaluate the expression: "const type *" at that context it does seem to
> >  have an hint about the fact that it is an template type. I.e. I do:
> >
> > argType->toString()         => "const type* d" // From function
> > declaration expectedType->toString() => "const <template> type*" // from
> > query description
> >
> > I expected to have the one comming from the function declaration also
> >  having a hint about being a template type. Moreover, I expect:
> >
> > argType.indexedType() == expectedType.indexedType()
>
> Not sure why it is not marked properly in that case, maybe it is falsely
> marked as "unresolved" instead of "template"? (Both through
> KDevelop::DelayedType)

See  my comment above, the ArgumentType of the declaration is a delayed type 
but the result of the expression parser is the actual CppTemplateParameterType 
(which seems correct to me, though I maybe expected this CppTemplateParameter 
also in the function Declaration).

> > This might be a false assumption of me and another possibility might be
> > to iterator over all instantiations of the particular function and find
> > *their* uses.
>
> That should work.

Yeah, but as said before, only when you've first found the right function 
declarations to look up the instantiations for.

Cheers,

Bertjan





More information about the KDevelop-devel mailing list