Review Request: specializeFrom for functions and template identifier free specializations

Olivier Jean de Gaalon olivier.jg at gmail.com
Wed Jun 29 08:27:55 UTC 2011


> On June 26, 2011, 11:29 a.m., David Nolden wrote:
> > The stripPrefixes thing should be checked, because it is slow. Afterwards, ship it.

stripPrefixes is slow or making a qualified id from a localid.toString() is slow?


> On June 26, 2011, 11:29 a.m., David Nolden wrote:
> > languages/cpp/cppduchain/declarationbuilder.cpp, line 511
> > <http://git.reviewboard.kde.org/r/101690/diff/2/?file=24870#file24870line511>
> >
> >     Do you deal with partial specializations here? Those have a non-empty template context.

Yes.


> On June 26, 2011, 11:29 a.m., David Nolden wrote:
> > languages/cpp/cppduchain/declarationbuilder.cpp, line 535
> > <http://git.reviewboard.kde.org/r/101690/diff/2/?file=24870#file24870line535>
> >
> >     Did you try without the stiprPrefixes? I doubt it is even required, because the same thing should be find with or without.

Yes, I tried, it doesn't seem to find any declarations for the function identifier. Perhaps I'm doing it wrong?


> On June 26, 2011, 11:29 a.m., David Nolden wrote:
> > languages/cpp/cppduchain/declarationbuilder.cpp, line 548
> > <http://git.reviewboard.kde.org/r/101690/diff/2/?file=24870#file24870line548>
> >
> >     I think every member of a template-class is itself based on TemplateDeclaration too, so this TODO is obsolete.

Yep, that's true.
-----------------
But before I can push this, I must ask for some assistance.
It seems that when you setSpecializedFrom on a function (or at least a non-template function of a template class), the duchain is unable to properly instantiate it, giving a borked context.
Its imported class context doesn't have any declarations, and it somehow ends up importing itself as a parent context (since it's instantiated this doesn't happen via addImportedParent context, which would catch it).
It will eventually end up in infinite recursion in cppduchain.cpp:getTemplateContext() and crash.

Is there any chance you could take a look at that? I'm not sure at all what is the normal behavior of instantiation so it's hard for me to tell where it goes wrong.

Reproduction:
-----------------

template<class Type>
struct ConstantUnaryExpressionEvaluator {

  void evaluateSpecialTokens( int tokenKind, ConstantIntegralType* left ) {}

};

template<>
void ConstantUnaryExpressionEvaluator<double>::evaluateSpecialTokens( int tokenKind, ConstantIntegralType* left ) {
}

template<>
void ConstantUnaryExpressionEvaluator<float>::evaluateSpecialTokens( int tokenKind, ConstantIntegralType* left ) {
}
------------------

If you hit the reparse button once or twice it'll give you the infinite recursion death.


- Olivier Jean de


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/101690/#review4166
-----------------------------------------------------------


On June 22, 2011, 5:49 a.m., Olivier Jean de Gaalon wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/101690/
> -----------------------------------------------------------
> 
> (Updated June 22, 2011, 5:49 a.m.)
> 
> 
> Review request for KDevelop and David Nolden.
> 
> 
> Summary
> -------
> 
> Set specializedFrom for TemplateDeclarations in more cases then before.
> Make expressionvisitor check specializedFrom to find type of "this".
> 
> Also adds a test that should work (works in normal usage), but in the test environment for some reason the template declarations never have a templateContext().
> 
> 
> This addresses bug 183614.
>     http://bugs.kde.org/show_bug.cgi?id=183614
> 
> 
> Diffs
> -----
> 
>   languages/cpp/cppduchain/declarationbuilder.h 2242da2 
>   languages/cpp/cppduchain/declarationbuilder.cpp 0423842 
>   languages/cpp/cppduchain/expressionvisitor.cpp eef33e3 
>   languages/cpp/cppduchain/tests/test_expressionparser.h 385568f 
>   languages/cpp/cppduchain/tests/test_expressionparser.cpp 22e123a 
> 
> Diff: http://git.reviewboard.kde.org/r/101690/diff
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Olivier Jean de
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20110629/79dd8a57/attachment.html>


More information about the KDevelop-devel mailing list