<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="12" style="border: 1px #c9c399 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="https://git.reviewboard.kde.org/r/126154/">https://git.reviewboard.kde.org/r/126154/</a>
     </td>
    </tr>
   </table>
   <br />





<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
 <p style="margin-top: 0;">On November 24th, 2015, 2:23 p.m. UTC, <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;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Can you create a unit test for this issue please?</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Also, couldn't this happen with more indirection in-between as well? I.e. is it safe enough to check the direct parent? Don't we need to check against a stack of parents to prevent recursion in all cases?</p></pre>
 </blockquote>




 <p>On November 25th, 2015, 10:20 a.m. UTC, <b>Maciej Cencora</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;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">I could if you point me on how to do it, because at first I tried to create new test in test_codecompletion.cpp but following code does not trigger the bug
template <typename Head, typename ...Tail>
"struct my_class : Head, my_class<Tail...>
{
    using base ="</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">One need to insert a type, and then change it to reproduce the crash and I don't know how to do it in UTs.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">As for the in-direction, I guess it is possible - I will give it a try. I am not sure how to detect it though, I couldn't find an API in clang for directly accessing the base classes - only through visitation.</p></pre>
 </blockquote>





 <p>On November 27th, 2015, 8:03 p.m. UTC, <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;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Can you first try a simple test:</p>
<ul style="padding: 0;text-rendering: inherit;margin: 0 0 0 1em;line-height: inherit;white-space: normal;">
<li style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">copy the code in the smaller <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">executeCompletionTest</code> into a new test function</li>
<li style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">add a <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">file.setFileContents(...)</code> with the new contents after the <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">parseAndWait</code></li>
<li style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">add another <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">parseAndWait</code></li>
<li style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">call the bigger <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">executeCompletionTest</code> with the correct parameters</li>
</ul>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Does that work? If not, it's going to be a bit involved to write the test, but certainly possible and still really important to have:</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Look at <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">executeMemberAccessReplacerTest()</code>, it shows you how to get your hands on a document and view and how to run code completion.
That could then be used to do all your steps, including marking a word, removing it, and then requesting code completion, potentially
with delays in-between.</p></pre>
 </blockquote>





 <p>On November 27th, 2015, 8:04 p.m. UTC, <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;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Oh and btw: I can reproduce this issue :) So if you have problems with the unit test, tell me.</p></pre>
 </blockquote>





 <p>On December 3rd, 2015, 10:49 a.m. UTC, <b>Maciej Cencora</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;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">In the end I managed to easily reproduce the bug in testClangCodeCompletion with completed class like this (code completion invoked after the '='):</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">template <typename Head, typename ...Tail>
struct my_class : Head, my_class<Tail...>
{
    using base = Head;
};</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">instead of incomplete:</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">template <typename Head, typename ...Tail>
struct my_class : Head, my_class<Tail...>
{
    using base =</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">What should be the expected list of completions? I'd say 'Head' maybe additionally 'my_class<Tail...>' if any at all.
Unfortunately the code completion seems to be broken now and reports "Head", "KDevelopClangGccCompat", "Tail", "<strong style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">m128", "</strong>m128d", "<strong style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">m128i", "</strong>m256", "<strong style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">m256d", "</strong>m256i", "<strong style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">m512", "</strong>m512d", "<strong style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">m512i", "</strong>m64", "<strong style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">mmask16", "</strong>mmask32", "<strong style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">mmask64", "</strong>mmask8", "my_class".</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Also some other completion tests fail because the completion list contains around 1000!! entries like following "<strong style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">builtin_ia32_addpd256_mask", "</strong>builtin_ia32_addpd512_mask", "__builtin_ia32_addps128_mask".</p></pre>
 </blockquote>





 <p>On December 3rd, 2015, 11:10 a.m. UTC, <b>Maciej Cencora</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;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Also, I've checked my fix with indirect class being the same. It works ok (maybe it worked before too).</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">template <typename Head, typename ...Tail>
struct my_class2;</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">template <typename Head, typename ...Tail>
struct my_class1 : Head, my_class2<Tail...>
{
    using base = my_class2<Tail...>;
};</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">template <typename Head, typename ...Tail>
struct my_class2 : Head, my_class1<Tail...>
{
    using base = my_class1<Tail...>;
};</p></pre>
 </blockquote>








</blockquote>

<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Sorry for the long delay. So, did you manage to write a unit test? I'd like to see this patch being integrated, but I'd need a proper unit test first. I'll look into the issue with the <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">__builtin</code>s.</p></pre>
<br />










<p>- Milian</p>


<br />
<p>On November 25th, 2015, 10:16 a.m. UTC, Maciej Cencora wrote:</p>








<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="12" style="border: 1px #888a85 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
 <tr>
  <td>

<div>Review request for KDevelop.</div>
<div>By Maciej Cencora.</div>


<p style="color: grey;"><i>Updated Nov. 25, 2015, 10:16 a.m.</i></p>









<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
kdevelop
</div>


<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;">The crash cannot be reproduced on completion, only when editing such class.
To reproduce:
1) create and save file with following content
template <typename Head, typename ...Tail>
struct my_class : Head, my_class<Tail...>
{
    using base = Head;
};
2) in line with 'using' statement, mark the 'Head' text
3) delete text
4) write something (e.g. press letter 'a')

Not sure whether this is proper fix, but backtrace shows infinite recursion.
#0  clang::operator<< (OS=..., N=...) at /build/llvm-toolchain-3.6-18MJNr/llvm-toolchain-3.6-3.6.2/tools/clang/lib/AST/DeclarationName.cpp:136
#1  0x00007fff7d266e9d in clang::NamedDecl::printName (this=<optimized out>, os=...) at /build/llvm-toolchain-3.6-18MJNr/llvm-toolchain-3.6-3.6.2/tools/clang/tools/libclang/../../include/clang/AST/Decl.h:150
#2  getDeclSpelling (D=0x7fff9403bd00) at /build/llvm-toolchain-3.6-18MJNr/llvm-toolchain-3.6-3.6.2/tools/clang/tools/libclang/CIndex.cpp:3491
#3  0x00007fff7d267686 in clang_getCursorSpelling (C=...) at /build/llvm-toolchain-3.6-18MJNr/llvm-toolchain-3.6-3.6.2/tools/clang/tools/libclang/CIndex.cpp:3625
#4  0x00007fff7deb2e51 in (anonymous namespace)::baseClassVisitor (cursor=..., parent=..., data=0x7fff7c8f5090) at /home/mcencora/tmp/kdevelop/languages/clang/codecompletion/completionhelper.cpp:158
#5  0x00007fff7d259add in clang::cxcursor::CursorVisitor::Visit (this=this@entry=0x7fff7c8f4f10, Cursor=..., CheckedRegionOfInterest=CheckedRegionOfInterest@entry=false)
    at /build/llvm-toolchain-3.6-18MJNr/llvm-toolchain-3.6-3.6.2/tools/clang/tools/libclang/CIndex.cpp:210
#6  0x00007fff7d25bc34 in clang::cxcursor::CursorVisitor::VisitTemplateParameters (this=this@entry=0x7fff7c8f4f10, Params=<optimized out>) at /build/llvm-toolchain-3.6-18MJNr/llvm-toolchain-3.6-3.6.2/tools/clang/tools/libclang/CIndex.cpp:1321
#7  0x00007fff7d259235 in clang::cxcursor::CursorVisitor::VisitClassTemplateDecl (this=0x7fff7c8f4f10, D=0x7fff9403bef0) at /build/llvm-toolchain-3.6-18MJNr/llvm-toolchain-3.6-3.6.2/tools/clang/tools/libclang/CIndex.cpp:903
#8  0x00007fff7d2595db in clang::cxcursor::CursorVisitor::VisitChildren (this=this@entry=0x7fff7c8f4f10, Cursor=...) at /build/llvm-toolchain-3.6-18MJNr/llvm-toolchain-3.6-3.6.2/tools/clang/tools/libclang/CIndex.cpp:500
#9  0x00007fff7d260024 in clang_visitChildren (parent=..., visitor=0x7fff7deb2ddf <(anonymous namespace)::baseClassVisitor(CXCursor, CXCursor, CXClientData)>, client_data=0x7fff7c8f5090)
    at /build/llvm-toolchain-3.6-18MJNr/llvm-toolchain-3.6-3.6.2/tools/clang/tools/libclang/CIndex.cpp:3419
#10 0x00007fff7deb2dac in (anonymous namespace)::processBaseClass (cursor=..., parent=..., functionList=0x7fff74003590) at /home/mcencora/tmp/kdevelop/languages/clang/codecompletion/completionhelper.cpp:148
#11 0x00007fff7deb2f42 in (anonymous namespace)::baseClassVisitor (cursor=..., parent=..., data=0x7fff7c8f5580) at /home/mcencora/tmp/kdevelop/languages/clang/codecompletion/completionhelper.cpp:166
#12 0x00007fff7d259add in clang::cxcursor::CursorVisitor::Visit (this=this@entry=0x7fff7c8f5400, Cursor=..., CheckedRegionOfInterest=CheckedRegionOfInterest@entry=false)
    at /build/llvm-toolchain-3.6-18MJNr/llvm-toolchain-3.6-3.6.2/tools/clang/tools/libclang/CIndex.cpp:210
#13 0x00007fff7d25919a in clang::cxcursor::CursorVisitor::VisitCXXRecordDecl (this=0x7fff7c8f5400, D=0x7fff9403be60) at /build/llvm-toolchain-3.6-18MJNr/llvm-toolchain-3.6-3.6.2/tools/clang/tools/libclang/CIndex.cpp:1672
#14 0x00007fff7d2595db in clang::cxcursor::CursorVisitor::VisitChildren (this=this@entry=0x7fff7c8f5400, Cursor=...) at /build/llvm-toolchain-3.6-18MJNr/llvm-toolchain-3.6-3.6.2/tools/clang/tools/libclang/CIndex.cpp:500
#15 0x00007fff7d260024 in clang_visitChildren (parent=..., visitor=0x7fff7deb2ddf <(anonymous namespace)::baseClassVisitor(CXCursor, CXCursor, CXClientData)>, client_data=0x7fff7c8f5580)
    at /build/llvm-toolchain-3.6-18MJNr/llvm-toolchain-3.6-3.6.2/tools/clang/tools/libclang/CIndex.cpp:3419
#16 0x00007fff7deb2dac in (anonymous namespace)::processBaseClass (cursor=..., parent=..., functionList=0x7fff74003590) at /home/mcencora/tmp/kdevelop/languages/clang/codecompletion/completionhelper.cpp:148
#17 0x00007fff7deb2f42 in (anonymous namespace)::baseClassVisitor (cursor=..., parent=..., data=0x7fff7c8f5a70) at /home/mcencora/tmp/kdevelop/languages/clang/codecompletion/completionhelper.cpp:166
#18 0x00007fff7d259add in clang::cxcursor::CursorVisitor::Visit (this=this@entry=0x7fff7c8f58f0, Cursor=..., CheckedRegionOfInterest=CheckedRegionOfInterest@entry=false)
    at /build/llvm-toolchain-3.6-18MJNr/llvm-toolchain-3.6-3.6.2/tools/clang/tools/libclang/CIndex.cpp:210
#19 0x00007fff7d25919a in clang::cxcursor::CursorVisitor::VisitCXXRecordDecl (this=0x7fff7c8f58f0, D=0x7fff9403be60) at /build/llvm-toolchain-3.6-18MJNr/llvm-toolchain-3.6-3.6.2/tools/clang/tools/libclang/CIndex.cpp:1672
#20 0x00007fff7d2595db in clang::cxcursor::CursorVisitor::VisitChildren (this=this@entry=0x7fff7c8f58f0, Cursor=...) at /build/llvm-toolchain-3.6-18MJNr/llvm-toolchain-3.6-3.6.2/tools/clang/tools/libclang/CIndex.cpp:500
#21 0x00007fff7d260024 in clang_visitChildren (parent=..., visitor=0x7fff7deb2ddf <(anonymous namespace)::baseClassVisitor(CXCursor, CXCursor, CXClientData)>, client_data=0x7fff7c8f5a70)
    at /build/llvm-toolchain-3.6-18MJNr/llvm-toolchain-3.6-3.6.2/tools/clang/tools/libclang/CIndex.cpp:3419
#22 0x00007fff7deb2dac in (anonymous namespace)::processBaseClass (cursor=..., parent=..., functionList=0x7fff74003590) at /home/mcencora/tmp/kdevelop/languages/clang/codecompletion/completionhelper.cpp:148
#23 0x00007fff7deb2f42 in (anonymous namespace)::baseClassVisitor (cursor=..., parent=..., data=0x7fff7c8f5f60) at /home/mcencora/tmp/kdevelop/languages/clang/codecompletion/completionhelper.cpp:166
#24 0x00007fff7d259add in clang::cxcursor::CursorVisitor::Visit (this=this@entry=0x7fff7c8f5de0, Cursor=..., CheckedRegionOfInterest=CheckedRegionOfInterest@entry=false)
    at /build/llvm-toolchain-3.6-18MJNr/llvm-toolchain-3.6-3.6.2/tools/clang/tools/libclang/CIndex.cpp:210
#25 0x00007fff7d25919a in clang::cxcursor::CursorVisitor::VisitCXXRecordDecl (this=0x7fff7c8f5de0, D=0x7fff9403be60) at /build/llvm-toolchain-3.6-18MJNr/llvm-toolchain-3.6-3.6.2/tools/clang/tools/libclang/CIndex.cpp:1672
#26 0x00007fff7d2595db in clang::cxcursor::CursorVisitor::VisitChildren (this=this@entry=0x7fff7c8f5de0, Cursor=...) at /build/llvm-toolchain-3.6-18MJNr/llvm-toolchain-3.6-3.6.2/tools/clang/tools/libclang/CIndex.cpp:500
#27 0x00007fff7d260024 in clang_visitChildren (parent=..., visitor=0x7fff7deb2ddf <(anonymous namespace)::baseClassVisitor(CXCursor, CXCursor, CXClientData)>, client_data=0x7fff7c8f5f60)
    at /build/llvm-toolchain-3.6-18MJNr/llvm-toolchain-3.6-3.6.2/tools/clang/tools/libclang/CIndex.cpp:3419

... and this goes on for 39K frames</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </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;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Manual.</p></pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>languages/clang/codecompletion/completionhelper.cpp <span style="color: grey">(ac307ef)</span></li>

</ul>

<p><a href="https://git.reviewboard.kde.org/r/126154/diff/" style="margin-left: 3em;">View Diff</a></p>






  </td>
 </tr>
</table>







  </div>
 </body>
</html>