<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="http://git.reviewboard.kde.org/r/101690/">http://git.reviewboard.kde.org/r/101690/</a>
</td>
</tr>
</table>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<p style="margin-top: 0;">On June 26th, 2011, 11:29 a.m., <b>David Nolden</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="http://git.reviewboard.kde.org/r/101690/diff/2/?file=24870#file24870line548" style="color: black; font-weight: bold; text-decoration: underline;">languages/cpp/cppduchain/declarationbuilder.cpp</a>
<span style="font-weight: normal;">
(Diff revision 2)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="2"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<td colspan="2"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">TemplateDeclaration* DeclarationBuilder::findSpecializedFrom(Declaration* templDecl)</pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">548</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="cm">/*</span><span class="cs">TODO</span><span class="cm">: it's possible to specialize a single (non-template-) function or class within a template</span></pre></td>
</tr>
</tbody>
</table>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I think every member of a template-class is itself based on TemplateDeclaration too, so this TODO is obsolete.</pre>
</blockquote>
<p>On June 29th, 2011, 8:27 a.m., <b>Olivier Jean de Gaalon</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">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.</pre>
</blockquote>
<p>On July 4th, 2011, 4:19 p.m., <b>David Nolden</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I will try to check that. </pre>
</blockquote>
<p>On July 13th, 2011, 5:42 p.m., <b>Milian Wolff</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">david, any update?</pre>
</blockquote>
</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Update on importing self as a parent context...
It doesn't actually import itself, but it seems that way. The problem is in the DUContext::Import creation.
At the time the import is created (to be added to the imports of the function declaration's expression context) the internalContext of a function is the parameter context. Later in the ContextBuilder, the internalContext is changed to be the expression context.
For normal functions, when a DUContext::Import is created, the Import keeps a reference to the parameter context as intended.
For specialized functions, when a DUContext::Import is created, the Import keeps a reference to the parameterContext's->owner(). Any later attempt to access the Import will return said owner's->internalContext(), which has actually been changed from the parameter context (which should be imported) to the expression context (self-import).
It seems to work ok if I tell it to keep a direct reference to the context instead of to the owning declaration in the case of function specializations, but that doesn't seem like the correct fix...
Where should this be fixed?</pre>
<br />
<p>- Olivier Jean de</p>
<br />
<p>On June 22nd, 2011, 5:49 a.m., Olivier Jean de Gaalon wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('http://git.reviewboard.kde.org/media/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
<tr>
<td>
<div>Review request for KDevelop and David Nolden.</div>
<div>By Olivier Jean de Gaalon.</div>
<p style="color: grey;"><i>Updated June 22, 2011, 5:49 a.m.</i></p>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">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().</pre>
</td>
</tr>
</table>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>
<a href="http://bugs.kde.org/show_bug.cgi?id=183614">183614</a>
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>languages/cpp/cppduchain/declarationbuilder.h <span style="color: grey">(2242da2)</span></li>
<li>languages/cpp/cppduchain/declarationbuilder.cpp <span style="color: grey">(0423842)</span></li>
<li>languages/cpp/cppduchain/expressionvisitor.cpp <span style="color: grey">(eef33e3)</span></li>
<li>languages/cpp/cppduchain/tests/test_expressionparser.h <span style="color: grey">(385568f)</span></li>
<li>languages/cpp/cppduchain/tests/test_expressionparser.cpp <span style="color: grey">(22e123a)</span></li>
</ul>
<p><a href="http://git.reviewboard.kde.org/r/101690/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>