From 9cc4751857a46d97a832baa5ff42b3f9075ecb21 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Wed, 21 Sep 2011 14:39:48 +0200 Subject: [PATCH] C++ function signature: Abort on unexpected function name. Change-Id: Iaaa3907f709ea9ed567f59725399efd9024f3bc0 Reviewed-on: http://codereview.qt-project.org/5319 Reviewed-by: Leandro T. C. Melo --- src/plugins/cppeditor/cppfunctiondecldeflink.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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