Commit 2720f349 authored by Milian Wolff's avatar Milian Wolff Committed by Friedrich W. H. Kossebau

Don't crash when signatures don't match in AdaptSignatureAssistant

When the old positions overflow the new list of available declarations,
do not crash. This could happen due to parse errors or any other
discrepancy in counts. Should fixes the following assert I just

[KCrash Handler]
#6  0x00007fc6324a3f25 in raise () from /usr/lib/
#7  0x00007fc63248d897 in abort () from /usr/lib/
#8  0x00007fc632a0996c in QMessageLogger::fatal(char const*, ...) const () from /usr/lib/
#9  0x00007fc632a08d52 in qt_assert_x(char const*, char const*, char const*, int) () from /usr/lib/
#10 0x00007fc5f508be69 in QVector<KDevelop::Declaration*>::operator[] (this=0x7ffc9cfb01a0, i=1) at /usr/include/qt/QtCore/qvector.h:463
#11 0x00007fc5f508a4a6 in AdaptSignatureAssistant::getRenameActions (this=0x5621d5cd80e0, newSignature=..., oldPositions=...) at /home/milian/projects/kf5/src/extragear/kdevelop/kdevelop/plugins/clang/codegen/adaptsignatureassistant.cpp:246

(cherry picked from commit a5cf36fe)
parent 42afa5aa
Pipeline #13832 failed with stage
in 60 minutes
......@@ -239,11 +239,14 @@ QList<RenameAction*> AdaptSignatureAssistant::getRenameActions(const Signature &
if (!m_otherSideContext) {
return renameActions;
const auto oldDeclarations = m_otherSideContext->localDeclarations();
for (int i = newSignature.parameters.size() - 1; i >= 0; --i) {
if (oldPositions[i] == -1) {
continue; //new parameter
Declaration *renamedDecl = m_otherSideContext->localDeclarations()[oldPositions[i]];
Declaration *renamedDecl = oldDeclarations.value(oldPositions[i]);
if (!renamedDecl)
if (newSignature.parameters[i].second != m_oldSignature.parameters[oldPositions[i]].second) {
const auto uses = renamedDecl->uses();
if (!uses.isEmpty()) {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment