<table><tr><td style="">mwolff requested changes to this revision.<br />mwolff added a comment.<br />This revision now requires changes to proceed.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D18224">View Revision</a></tr></table><br /><div><div><p>nice, this is getting better! some suggestions on how to improve the code quality, and then some potential issues I can think of - please fix or document why they aren't an issue</p>
<p>cheers</p></div></div><br /><div><strong>INLINE COMMENTS</strong><div><div style="margin: 6px 0 12px 0;"><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D18224#inline-110179">View Inline</a><span style="color: #4b4d51; font-weight: bold;">parsesession.cpp:205</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span class="n">ProblemPointer</span> <span class="n">makeExternalProblem</span><span class="p">(</span><span class="n">CXDiagnostic</span> <span class="n">diagnostic</span><span class="p">,</span> <span class="n">CXTranslationUnit</span> <span class="n">unit</span><span class="p">,</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span style="color: #aa4000">const</span> <span class="n">QString</span><span style="color: #aa2211">&</span> <span class="n">descriptionTemplate</span><span class="p">,</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">make -> create</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D18224#inline-110181">View Inline</a><span style="color: #4b4d51; font-weight: bold;">parsesession.cpp:206</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span class="n">ProblemPointer</span> <span class="n">makeExternalProblem</span><span class="p">(</span><span class="n">CXDiagnostic</span> <span class="n">diagnostic</span><span class="p">,</span> <span class="n">CXTranslationUnit</span> <span class="n">unit</span><span class="p">,</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span style="color: #aa4000">const</span> <span class="n">QString</span><span style="color: #aa2211">&</span> <span class="n">descriptionTemplate</span><span class="p">,</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span style="color: #aa4000">int</span> <span class="n">childProblemFinalLocationIndex</span> <span style="color: #aa2211">=</span> <span style="color: #aa2211">-</span><span style="color: #601200">1</span><span class="p">)</span> <span class="p">{</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">pass a <tt style="background: #ebebeb; font-size: 13px;">KLocalizedString</tt> here</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D18224#inline-110177">View Inline</a><span style="color: #4b4d51; font-weight: bold;">parsesession.cpp:212</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span style="color: #74777d">// child problem to preserve its location.</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">ClangProblem</span><span style="color: #aa2211">*</span> <span class="n">problemCopy</span> <span style="color: #aa2211">=</span> <span style="color: #aa4000">new</span> <span class="n">ClangProblem</span><span class="p">();</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">problemCopy</span><span style="color: #aa2211">-></span><span class="n">setSource</span><span class="p">(</span><span class="n">problem</span><span style="color: #aa2211">-></span><span class="n">source</span><span class="p">());</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">auto</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D18224#inline-110182">View Inline</a><span style="color: #4b4d51; font-weight: bold;">parsesession.cpp:233</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">problem</span><span style="color: #aa2211">-></span><span class="n">setDescription</span><span class="p">(</span><span class="n">descriptionTemplate</span><span class="p">.</span><span class="n">arg</span><span class="p">(</span><span class="n">problem</span><span style="color: #aa2211">-></span><span class="n">description</span><span class="p">()));</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">once using KLS, use <tt style="background: #ebebeb; font-size: 13px;">descriptionTemplate.subs(problem->description()).toString()</tt></p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D18224#inline-110180">View Inline</a><span style="color: #4b4d51; font-weight: bold;">parsesession.cpp:238</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span class="n">QVector</span><span style="color: #aa2211"><</span><span class="n">ProblemPointer</span><span style="color: #aa2211">></span> <span class="n">makeRequestedHereProblems</span><span class="p">(</span><span class="n">CXDiagnostic</span> <span class="n">diagnostic</span><span class="p">,</span> <span class="n">CXTranslationUnit</span> <span class="n">unit</span><span class="p">,</span> <span class="n">CXFile</span> <span class="n">file</span><span class="p">)</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span class="p">{</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">make -> create</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D18224#inline-110183">View Inline</a><span style="color: #4b4d51; font-weight: bold;">parsesession.cpp:256</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span style="color: #74777d">// child problems to find the correct index.</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">results</span> <span style="color: #aa2211"><<</span> <span class="n">makeExternalProblem</span><span class="p">(</span><span class="n">diagnostic</span><span class="p">,</span> <span class="n">unit</span><span class="p">,</span> <span class="n">i18n</span><span class="p">(</span><span style="color: #766510">"Requested here: %1"</span><span class="p">,</span> <span class="n">QLatin1String</span><span class="p">(</span><span style="color: #766510">"%1"</span><span class="p">)),</span> <span class="n">j</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="p">}</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">once using KLS, use <tt style="background: #ebebeb; font-size: 13px;">ki18n("Requested here: %1")</tt> here</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D18224#inline-110184">View Inline</a><span style="color: #4b4d51; font-weight: bold;">parsesession.cpp:505</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; "> <span class="n">problems</span><span class="p">.</span><span class="n">reserve</span><span class="p">(</span><span class="n">numDiagnostics</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">d</span><span style="color: #aa2211">-></span><span class="n">m_diagnosticsCache</span><span class="p">.</span><span class="n">res<span class="bright">iz</span>e</span><span class="p">(</span><span class="n">numDiagnostics</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">d</span><span style="color: #aa2211">-></span><span class="n">m_diagnosticsCache</span><span class="p">.</span><span class="n">res<span class="bright">erv</span>e</span><span class="p">(</span><span class="n">numDiagnostics</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">this isn't correct anymore:</p>
<p style="padding: 0; margin: 8px;">When we run into this code path with, say, 5 problems, we would reserve with 5 and then fill the cache. When we then get back here the next time with 0 problems, we would reserve 0, but the size would still be 5!</p>
<p style="padding: 0; margin: 8px;">the easiest solution I can come up with for now is to resize to output_index at the end... but I kind of dislike that we need that to begin with :( can you come up with something better? otherwise, please at least introduce a lambda helper that wraps the "lookup in cache and reuse or insert new problem"</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D18224#inline-110185">View Inline</a><span style="color: #4b4d51; font-weight: bold;">parsesession.cpp:541</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="p">}</span> <span style="color: #aa4000">else</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">problem</span> <span style="color: #aa2211">=</span> <span class="n">makeExternalProblem</span><span class="p">(</span><span class="n">diagnostic</span><span class="p">,</span> <span class="n">d</span><span style="color: #aa2211">-></span><span class="n">m_unit</span><span class="p">,</span> <span class="n">i18n</span><span class="p">(</span><span style="color: #766510">"In included file: %1"</span><span class="p">,</span> <span class="n">QLatin1String</span><span class="p">(</span><span style="color: #766510">"%1"</span><span class="p">)));</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="p">}</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">use ki18n too</p>
<p style="padding: 0; margin: 8px;">are we sure that this external problem will always have a location within the current <tt style="background: #ebebeb; font-size: 13px;">file</tt>? couldn't it happen that we encounter completely unrelated errors? I would assume that e.g. in the following scenario, we may end up creating unhelpful issues?</p>
<p style="padding: 0; margin: 8px;">A > B > C</p>
<p style="padding: 0; margin: 8px;">if B has an error due to C, then A shouldn't show anything (except when we "show imports")</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D18224#inline-110187">View Inline</a><span style="color: #4b4d51; font-weight: bold;">test_duchain.cpp:1947</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">QString</span> <span class="n">sourceCode</span> <span style="color: #aa2211">=</span> <span style="color: #766510">"#include </span><span style="color: #bb6622">\"</span><span style="color: #766510">"</span> <span style="color: #aa2211">+</span> <span class="n">header</span><span class="p">.</span><span class="n">url</span><span class="p">().</span><span class="n">str</span><span class="p">()</span> <span style="color: #aa2211">+</span> <span style="color: #766510">"</span><span style="color: #bb6622">\"\n</span><span style="color: #766510">"</span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">sourceCode</span> <span style="color: #aa2211">+=</span> <span class="n">QStringLiteral</span><span class="p">(</span><span class="n">R</span><span style="color: #766510">"(</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span style="color: #aa4000">struct</span> <span class="n">A</span> <span class="p">{};</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">QStringLiteral(R"(<br />
#include "%1"<br />
...<br />
").arg(header.url().str());</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D18224#inline-110188">View Inline</a><span style="color: #4b4d51; font-weight: bold;">test_duchain.cpp:1965</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">TopDUContext</span><span style="color: #aa2211">*</span> <span class="n">headerCtx</span> <span style="color: #aa2211">=</span> <span style="color: #aa4000">dynamic_cast</span><span style="color: #aa2211"><</span><span class="n">TopDUContext</span><span style="color: #aa2211">*></span><span class="p">(</span><span class="n">top</span><span style="color: #aa2211">-></span><span class="n">importedParentContexts</span><span class="p">().</span><span class="n">first</span><span class="p">().</span><span class="n">context</span><span class="p">(</span><span class="n">top</span><span class="p">));</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">QVERIFY</span><span class="p">(</span><span class="n">headerCtx</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">auto</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D18224#inline-110189">View Inline</a><span style="color: #4b4d51; font-weight: bold;">test_duchain.cpp:2019</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">QString</span> <span class="n">sourceCode</span> <span style="color: #aa2211">=</span> <span style="color: #766510">"#include </span><span style="color: #bb6622">\"</span><span style="color: #766510">"</span> <span style="color: #aa2211">+</span> <span class="n">header</span><span class="p">.</span><span class="n">url</span><span class="p">().</span><span class="n">str</span><span class="p">()</span> <span style="color: #aa2211">+</span> <span style="color: #766510">"</span><span style="color: #bb6622">\"\n</span><span style="color: #766510">"</span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">sourceCode</span> <span style="color: #aa2211">+=</span> <span class="n">QStringLiteral</span><span class="p">(</span><span class="n">R</span><span style="color: #766510">"(</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">see above</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D18224#inline-110190">View Inline</a><span style="color: #4b4d51; font-weight: bold;">test_duchain.cpp:2044</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">TopDUContext</span><span style="color: #aa2211">*</span> <span class="n">headerCtx</span> <span style="color: #aa2211">=</span> <span style="color: #aa4000">dynamic_cast</span><span style="color: #aa2211"><</span><span class="n">TopDUContext</span><span style="color: #aa2211">*></span><span class="p">(</span><span class="n">top</span><span style="color: #aa2211">-></span><span class="n">importedParentContexts</span><span class="p">().</span><span class="n">first</span><span class="p">().</span><span class="n">context</span><span class="p">(</span><span class="n">top</span><span class="p">));</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="n">QVERIFY</span><span class="p">(</span><span class="n">headerCtx</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">auto</p></div></div></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R32 KDevelop</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D18224">https://phabricator.kde.org/D18224</a></div></div><br /><div><strong>To: </strong>thomassc, KDevelop, mwolff<br /><strong>Cc: </strong>aaronpuchert, pino, mwolff, kdevelop-devel, gennad, glebaccon, domson, antismap, iodelay, alexeymin, geetamc, Pilzschaf, akshaydeo, surgenight, arrowd<br /></div>