diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2016-07-31 22:29:39 +0300 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2016-08-19 14:41:17 +0000 |
commit | 2890966ec30fabe09e7ddb325bdc09320bbb17bd (patch) | |
tree | 305acb3874a0c8cbcd6a0e216e67538d64e83d00 /src/plugins/cppeditor/cppquickfixes.cpp | |
parent | 65dc6d0fc20e0faca1d6e000c03e6ff53cbd60ff (diff) | |
download | qt-creator-2890966ec30fabe09e7ddb325bdc09320bbb17bd.tar.gz |
CppEditor: Prevent "Add Declaration" for existing template functions
class Foo
{
template<class T>
void func();
};
template<class T>
void Foo::func() {} // Add Declaration should not be triggered at all
Change-Id: Ifff733d8381177300dae017ae419200cfdf5c425
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Diffstat (limited to 'src/plugins/cppeditor/cppquickfixes.cpp')
-rw-r--r-- | src/plugins/cppeditor/cppquickfixes.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index f65f1b6a57..371ec66f8e 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -2465,7 +2465,17 @@ void InsertDeclFromDef::match(const CppQuickFixInterface &interface, QuickFixOpe Function *fun = funDef->symbol; if (Class *matchingClass = isMemberFunction(interface.context(), fun)) { const QualifiedNameId *qName = fun->name()->asQualifiedNameId(); - for (Symbol *s = matchingClass->find(qName->identifier()); s; s = s->next()) { + for (Symbol *symbol = matchingClass->find(qName->identifier()); + symbol; symbol = symbol->next()) { + Symbol *s = symbol; + if (fun->enclosingScope()->isTemplate()) { + if (const Template *templ = s->type()->asTemplateType()) { + if (Symbol *decl = templ->declaration()) { + if (decl->type()->isFunctionType()) + s = decl; + } + } + } if (!s->name() || !qName->identifier()->match(s->identifier()) || !s->type()->isFunctionType()) |