diff --git a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp index 9c5ef817397..6873bbeaddc 100644 --- a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp +++ b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp @@ -510,15 +510,22 @@ Utils::ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targ if (!newFunction) return changes; - LookupContext sourceContext(sourceDocument, snapshot); - LookupContext targetContext(targetFile->cppDocument(), snapshot); - Overview overview; overview.setShowReturnTypes(true); overview.setShowTemplateParameters(true); overview.setShowArgumentNames(true); overview.setShowFunctionSignatures(true); + // abort if the name of the newly parsed function is not the expected one + DeclaratorIdAST *newDeclId = getDeclaratorId(newDef->declarator); + if (!newDeclId || !newDeclId->name || !newDeclId->name->name + || overview(newDeclId->name->name) != nameInitial) { + return changes; + } + + LookupContext sourceContext(sourceDocument, snapshot); + LookupContext targetContext(targetFile->cppDocument(), snapshot); + // sync return type { // set up for rewriting return type