From 4a2e082d859e0b49bb15e8b4cd39faf18b8eaddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 23 Nov 2020 20:18:06 +0100 Subject: [PATCH] Revert "GUI: restore default tab in ProjectFileDialog" This reverts commit 39564c9e6cc26bc6d29ae569f4141db726f9157c. --- gui/projectfiledialog.ui | 2 +- lib/symboldatabase.cpp | 6 +--- lib/templatesimplifier.cpp | 18 ++++++---- test/testsimplifytemplate.cpp | 68 ----------------------------------- 4 files changed, 14 insertions(+), 80 deletions(-) diff --git a/gui/projectfiledialog.ui b/gui/projectfiledialog.ui index e7d40d3e9..343dab7d9 100644 --- a/gui/projectfiledialog.ui +++ b/gui/projectfiledialog.ui @@ -17,7 +17,7 @@ - 0 + 2 diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 174cd43d6..6a8d48241 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -2102,11 +2102,7 @@ Function::Function(const Tokenizer *mTokenizer, } // class constructor/destructor - else if (((tokenDef->str() == scope->className) || - (tokenDef->str().substr(0, scope->className.size()) == scope->className && - tokenDef->str().size() > scope->className.size() + 1 && - tokenDef->str()[scope->className.size() + 1] == '<')) && - scope->type != Scope::ScopeType::eNamespace) { + else if (tokenDef->str() == scope->className && scope->type != Scope::ScopeType::eNamespace) { // destructor if (tokenDef->previous()->str() == "~") type = Function::eDestructor; diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 05fe300e6..1a19a7ef1 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -673,6 +673,15 @@ bool TemplateSimplifier::removeTemplate(Token *tok) if (tok2->str() == ">") countgt++; + // don't remove constructor + if (tok2->str() == "explicit" || + (countgt == 1 && Token::Match(tok2->previous(), "> %type% (") && + Tokenizer::startOfExecutableScope(tok2->linkAt(1)))) { + eraseTokens(tok, tok2); + deleteToken(tok); + return true; + } + if (tok2->str() == ";") { tok2 = tok2->next(); eraseTokens(tok, tok2); @@ -886,9 +895,8 @@ void TemplateSimplifier::getTemplateInstantiations() // get all declarations with this name for (auto pos = functionNameMap.lower_bound(tok->str()); pos != functionNameMap.upper_bound(tok->str()); ++pos) { - // look for declaration with same qualification or constructor with same qualification - if (pos->second->fullName() == fullName || - (pos->second->scope() == fullName && tok->str() == pos->second->name())) { + // look for declaration with same qualification + if (pos->second->fullName() == fullName) { std::vector templateParams; getTemplateParametersInDeclaration(pos->second->token()->tokAt(2), templateParams); @@ -3030,9 +3038,7 @@ bool TemplateSimplifier::simplifyTemplateInstantiations( if (!Token::Match(instantiation.token(), "%name% <")) continue; - if (!((instantiation.fullName() == templateDeclaration.fullName()) || - (instantiation.name() == templateDeclaration.name() && - instantiation.fullName() == templateDeclaration.scope()))) { + if (instantiation.fullName() != templateDeclaration.fullName()) { // FIXME: fallback to not matching scopes until type deduction works // names must match diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index d84dd6275..c79a040f0 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -252,7 +252,6 @@ private: TEST_CASE(templateTypeDeduction2); TEST_CASE(templateTypeDeduction3); TEST_CASE(templateTypeDeduction4); // #9983 - TEST_CASE(templateTypeDeduction5); TEST_CASE(simplifyTemplateArgs1); TEST_CASE(simplifyTemplateArgs2); @@ -5375,73 +5374,6 @@ private: } } - void templateTypeDeduction5() { - { - const char code[] = "class Fred {\n" - "public:\n" - " template Fred(T t) { }\n" - "};\n" - "Fred fred1 = Fred(0);\n" - "Fred fred2 = Fred(0.0);\n" - "Fred fred3 = Fred(\"zero\");\n" - "Fred fred4 = Fred(false);"; - const char exp[] = "class Fred { " - "public: " - "Fred ( int t ) ; " - "Fred ( double t ) ; " - "Fred ( const char * t ) ; " - "Fred ( bool t ) ; " - "} ; " - "Fred fred1 ; fred1 = Fred ( 0 ) ; " - "Fred fred2 ; fred2 = Fred ( 0.0 ) ; " - "Fred fred3 ; fred3 = Fred ( \"zero\" ) ; " - "Fred fred4 ; fred4 = Fred ( false ) ; " - "Fred :: Fred ( int t ) { } " - "Fred :: Fred ( double t ) { } " - "Fred :: Fred ( const char * t ) { } " - "Fred :: Fred ( bool t ) { }"; - ASSERT_EQUALS(exp, tok(code)); - } - { - const char code[] = "namespace NS {\n" - "class Fred {\n" - "public:\n" - " template Fred(T t) { }\n" - "};\n" - "Fred fred1 = Fred(0);\n" - "Fred fred2 = Fred(0.0);\n" - "Fred fred3 = Fred(\"zero\");\n" - "Fred fred4 = Fred(false);\n" - "}\n" - "NS::Fred fred1 = NS::Fred(0);\n" - "NS::Fred fred2 = NS::Fred(0.0);\n" - "NS::Fred fred3 = NS::Fred(\"zero\");\n" - "NS::Fred fred4 = NS::Fred(false);\n"; - const char exp[] = "namespace NS { " - "class Fred { " - "public: " - "Fred ( int t ) ; " - "Fred ( double t ) ; " - "Fred ( const char * t ) ; " - "Fred ( bool t ) ; " - "} ; " - "Fred fred1 ; fred1 = Fred ( 0 ) ; " - "Fred fred2 ; fred2 = Fred ( 0.0 ) ; " - "Fred fred3 ; fred3 = Fred ( \"zero\" ) ; " - "Fred fred4 ; fred4 = Fred ( false ) ; " - "} " - "NS :: Fred fred1 ; fred1 = NS :: Fred ( 0 ) ; " - "NS :: Fred fred2 ; fred2 = NS :: Fred ( 0.0 ) ; " - "NS :: Fred fred3 ; fred3 = NS :: Fred ( \"zero\" ) ; " - "NS :: Fred fred4 ; fred4 = NS :: Fred ( false ) ; " - "NS :: Fred :: Fred ( int t ) { } " - "NS :: Fred :: Fred ( double t ) { } " - "NS :: Fred :: Fred ( const char * t ) { } " - "NS :: Fred :: Fred ( bool t ) { }"; - ASSERT_EQUALS(exp, tok(code)); - } - } - void simplifyTemplateArgs1() { ASSERT_EQUALS("foo<2> = 2 ; foo<2> ;", tok("template foo = N; foo < ( 2 ) >;")); ASSERT_EQUALS("foo<2> = 2 ; foo<2> ;", tok("template foo = N; foo < 1 + 1 >;"));