diff --git a/cfg/qt.cfg b/cfg/qt.cfg
index 3f63d2bb7..aaf0cf135 100644
--- a/cfg/qt.cfg
+++ b/cfg/qt.cfg
@@ -5165,6 +5165,7 @@
+
@@ -5197,7 +5198,10 @@
-
+
+
+
+
diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp
index 470a2f0c5..a0df78666 100644
--- a/lib/tokenize.cpp
+++ b/lib/tokenize.cpp
@@ -4987,9 +4987,6 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
if (Settings::terminated())
return false;
- // Remove Qt signals and slots
- simplifyQtSignalsSlots();
-
// remove Borland stuff..
simplifyBorland();
@@ -9136,65 +9133,6 @@ void Tokenizer::simplifyBorland()
}
}
-// Remove Qt signals and slots
-void Tokenizer::simplifyQtSignalsSlots()
-{
- if (isC())
- return;
- if (std::none_of(mSettings->libraries.cbegin(), mSettings->libraries.cend(), [](const std::string& lib) {
- return lib == "qt";
- }))
- return;
- for (Token *tok = list.front(); tok; tok = tok->next()) {
- // check for emit which can be outside of class
- if (Token::Match(tok, "emit|Q_EMIT %name% (") &&
- Token::simpleMatch(tok->linkAt(2), ") ;")) {
- tok->deleteThis();
- } else if (!Token::Match(tok, "class %name% :|::|{"))
- continue;
-
- if (tok->previous() && tok->previous()->str() == "enum") {
- tok = tok->tokAt(2);
- continue;
- }
-
- // count { and } for tok2
- int indentlevel = 0;
- for (Token *tok2 = tok; tok2; tok2 = tok2->next()) {
- if (tok2->str() == "{") {
- ++indentlevel;
- if (indentlevel == 1)
- tok = tok2;
- else
- tok2 = tok2->link();
- } else if (tok2->str() == "}") {
- if (indentlevel<2)
- break;
- else
- --indentlevel;
- } else if (tok2->str() == ";" && indentlevel == 0)
- break;
-
- if (tok2->strAt(1) == "Q_OBJECT")
- tok2->deleteNext();
-
- if (Token::Match(tok2->next(), "public|protected|private slots|Q_SLOTS :")) {
- tok2 = tok2->next();
- tok2->str(tok2->str() + ":");
- tok2->deleteNext(2);
- tok2 = tok2->previous();
- } else if (Token::Match(tok2->next(), "signals|Q_SIGNALS :")) {
- tok2 = tok2->next();
- tok2->str("protected:");
- tok2->deleteNext();
- } else if (Token::Match(tok2->next(), "emit|Q_EMIT %name% (") &&
- Token::simpleMatch(tok2->linkAt(3), ") ;")) {
- tok2->deleteNext();
- }
- }
- }
-}
-
void Tokenizer::createSymbolDatabase()
{
if (!mSymbolDatabase)
diff --git a/lib/tokenize.h b/lib/tokenize.h
index 0ff6c356c..5d3e235f4 100644
--- a/lib/tokenize.h
+++ b/lib/tokenize.h
@@ -536,11 +536,6 @@ private:
*/
void simplifyBorland();
- /**
- * Remove Qt signals and slots
- */
- void simplifyQtSignalsSlots();
-
/**
* Collapse operator name tokens into single token
* operator = => operator=
diff --git a/test/cfg/qt.cpp b/test/cfg/qt.cpp
index c38b21415..ce9886c2e 100644
--- a/test/cfg/qt.cpp
+++ b/test/cfg/qt.cpp
@@ -494,4 +494,73 @@ namespace {
}
void slot() {};
};
+
+ // findFunction11
+ class Fred : public QObject {
+ Q_OBJECT
+ private slots:
+ void foo();
+ };
+ void Fred::foo() { }
+
+ // bitfields14
+ class X {
+ signals:
+ };
+
+ // simplifyQtSignalsSlots1
+ class Counter1 : public QObject {
+ Q_OBJECT
+ public:
+ Counter1() { m_value = 0; }
+ int value() const { return m_value; }
+ public slots:
+ void setValue(int value);
+ signals:
+ void valueChanged(int newValue);
+ private:
+ int m_value;
+ };
+ void Counter1::setValue(int value) {
+ if (value != m_value) {
+ m_value = value;
+ emit valueChanged(value);
+ }
+ }
+
+ class Counter2 : public QObject {
+ Q_OBJECT
+ public:
+ Counter2() { m_value = 0; }
+ int value() const { return m_value; }
+ public Q_SLOTS:
+ void setValue(int value);
+ Q_SIGNALS:
+ void valueChanged(int newValue);
+ private:
+ int m_value;
+ };
+ void Counter2::setValue(int value) {
+ if (value != m_value) {
+ m_value = value;
+ emit valueChanged(value);
+ }
+ }
+
+ class MyObject1 : public QObject {
+ MyObject1() {}
+ ~MyObject1() {}
+ public slots:
+ signals:
+ void test() {}
+ };
+
+ class MyObject2 : public QObject {
+ Q_OBJECT
+ public slots:
+ };
+
+ // simplifyQtSignalsSlots2
+ namespace Foo { class Bar; }
+ class Foo::Bar : public QObject { private slots: };
}
diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp
index 2d79649a7..6fb6562f9 100644
--- a/test/testsymboldatabase.cpp
+++ b/test/testsymboldatabase.cpp
@@ -407,7 +407,6 @@ private:
TEST_CASE(findFunction8);
TEST_CASE(findFunction9);
TEST_CASE(findFunction10); // #7673
- TEST_CASE(findFunction11);
TEST_CASE(findFunction12);
TEST_CASE(findFunction13);
TEST_CASE(findFunction14);
@@ -6074,21 +6073,6 @@ private:
ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 2);
}
- void findFunction11() {
- settings1.libraries.emplace_back("qt");
- GET_SYMBOL_DB("class Fred : public QObject {\n"
- " Q_OBJECT\n"
- "private slots:\n"
- " void foo();\n"
- "};\n"
- "void Fred::foo() { }");
- settings1.libraries.pop_back();
- ASSERT_EQUALS("", errout.str());
-
- const Token *f = Token::findsimplematch(tokenizer.tokens(), "foo ( ) {");
- ASSERT_EQUALS(true, db && f && f->function() && f->function()->tokenDef->linenr() == 4);
- }
-
void findFunction12() {
GET_SYMBOL_DB("void foo(std::string a) { }\n"
"void foo(long long a) { }\n"
diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp
index dfa0f57e8..d1cc2b33d 100644
--- a/test/testtokenize.cpp
+++ b/test/testtokenize.cpp
@@ -304,7 +304,6 @@ private:
TEST_CASE(bitfields10);
TEST_CASE(bitfields12); // ticket #3485 (segmentation fault)
TEST_CASE(bitfields13); // ticket #3502 (segmentation fault)
- TEST_CASE(bitfields14); // ticket #4561 (segfault for 'class a { signals: };')
TEST_CASE(bitfields15); // ticket #7747 (enum Foo {A,B}:4;)
TEST_CASE(bitfields16); // Save bitfield bit count
@@ -314,10 +313,6 @@ private:
TEST_CASE(microsoftString);
TEST_CASE(borland);
-
- TEST_CASE(simplifyQtSignalsSlots1);
- TEST_CASE(simplifyQtSignalsSlots2);
-
TEST_CASE(simplifySQL);
TEST_CASE(simplifyCAlternativeTokens);
@@ -4475,10 +4470,6 @@ private:
ASSERT_EQUALS("x y ;", tokenizeAndStringify("struct{x y:};\n"));
}
- void bitfields14() { // #4561 - crash for 'signals:'
- ASSERT_EQUALS("class x { protected: } ;", tokenizeAndStringify("class x { signals: };\n"));
- }
-
void bitfields15() { // #7747 - enum Foo {A,B}:4;
ASSERT_EQUALS("struct AB {\n"
"enum Foo { A , B } ; enum Foo Anonymous ;\n"
@@ -4698,128 +4689,6 @@ private:
tokenizeAndStringify("class Fred { __property int x = { } };", true, Settings::Win32A));
}
- void simplifyQtSignalsSlots1() {
- const char code1[] = "class Counter : public QObject "
- "{ "
- " Q_OBJECT "
- "public: "
- " Counter() { m_value = 0; } "
- " int value() const { return m_value; } "
- "public slots: "
- " void setValue(int value); "
- "signals: "
- " void valueChanged(int newValue); "
- "private: "
- " int m_value; "
- "}; "
- "void Counter::setValue(int value) "
- "{ "
- " if (value != m_value) { "
- " m_value = value; "
- " emit valueChanged(value); "
- " } "
- "}";
-
- const char result1[] = "class Counter : public QObject "
- "{ "
- "public: "
- "Counter ( ) { m_value = 0 ; } "
- "int value ( ) const { return m_value ; } "
- "public: "
- "void setValue ( int value ) ; "
- "protected: "
- "void valueChanged ( int newValue ) ; "
- "private: "
- "int m_value ; "
- "} ; "
- "void Counter :: setValue ( int value ) "
- "{ "
- "if ( value != m_value ) { "
- "m_value = value ; "
- "valueChanged ( value ) ; "
- "} "
- "}";
-
- ASSERT_EQUALS(result1, tokenizeAndStringify(code1));
-
- const char code2[] = "class Counter : public QObject "
- "{ "
- " Q_OBJECT "
- "public: "
- " Counter() { m_value = 0; } "
- " int value() const { return m_value; } "
- "public Q_SLOTS: "
- " void setValue(int value); "
- "Q_SIGNALS: "
- " void valueChanged(int newValue); "
- "private: "
- " int m_value; "
- "};"
- "void Counter::setValue(int value) "
- "{ "
- " if (value != m_value) { "
- " m_value = value; "
- " emit valueChanged(value); "
- " } "
- "}";
-
- const char result2[] = "class Counter : public QObject "
- "{ "
- "public: "
- "Counter ( ) { m_value = 0 ; } "
- "int value ( ) const { return m_value ; } "
- "public: "
- "void setValue ( int value ) ; "
- "protected: "
- "void valueChanged ( int newValue ) ; "
- "private: "
- "int m_value ; "
- "} ; "
- "void Counter :: setValue ( int value ) "
- "{ "
- "if ( value != m_value ) { "
- "m_value = value ; "
- "valueChanged ( value ) ; "
- "} "
- "}";
-
- ASSERT_EQUALS(result2, tokenizeAndStringify(code2));
-
- const char code3[] = "class MyObject : public QObject {"
- " MyObject() {}"
- " ~MyObject() {}"
- " public slots:"
- " signals:"
- " void test() {}"
- "};";
- const char result3[] = "class MyObject : public QObject { "
- "MyObject ( ) { } "
- "~ MyObject ( ) { } "
- "public: "
- "protected: "
- "void test ( ) { } "
- "} ;";
-
- ASSERT_EQUALS(result3, tokenizeAndStringify(code3));
- ASSERT_EQUALS("", errout.str());
-
- const char code4[] = "class MyObject : public QObject {"
- " Q_OBJECT "
- "public slots:"
- "};";
- const char result4[] = "class MyObject : public QObject { "
- "public: "
- "} ;";
-
- ASSERT_EQUALS(result4, tokenizeAndStringify(code4));
- }
-
- void simplifyQtSignalsSlots2() {
- const char code1[] = "class Foo::Bar: public QObject { private slots: };";
- const char result1[] = "class Foo :: Bar : public QObject { private: } ;";
- ASSERT_EQUALS(result1, tokenizeAndStringify(code1));
- }
-
void simplifySQL() {
// Oracle PRO*C extensions for inline SQL. Just replace the SQL with "asm()" to fix wrong error messages
// ticket: #1959