Improved Qt simplification
This commit is contained in:
parent
388b5118df
commit
ec8c733afb
|
@ -10837,7 +10837,7 @@ void Tokenizer::simplifyQtSignalsSlots()
|
||||||
if (Token::Match(tok, "emit|Q_EMIT %name% (") &&
|
if (Token::Match(tok, "emit|Q_EMIT %name% (") &&
|
||||||
Token::simpleMatch(tok->linkAt(2), ") ;")) {
|
Token::simpleMatch(tok->linkAt(2), ") ;")) {
|
||||||
tok->deleteThis();
|
tok->deleteThis();
|
||||||
} else if (!Token::Match(tok, "class %name% :"))
|
} else if (!Token::Match(tok, "class %name% :|::|{"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (tok->previous() && tok->previous()->str() == "enum") {
|
if (tok->previous() && tok->previous()->str() == "enum") {
|
||||||
|
@ -10859,7 +10859,9 @@ void Tokenizer::simplifyQtSignalsSlots()
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
--indentlevel;
|
--indentlevel;
|
||||||
}
|
} else if (tok2->str() == ";" && indentlevel == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
if (tok2->strAt(1) == "Q_OBJECT")
|
if (tok2->strAt(1) == "Q_OBJECT")
|
||||||
tok2->deleteNext();
|
tok2->deleteNext();
|
||||||
|
|
||||||
|
|
|
@ -375,7 +375,8 @@ private:
|
||||||
|
|
||||||
TEST_CASE(borland);
|
TEST_CASE(borland);
|
||||||
|
|
||||||
TEST_CASE(Qt);
|
TEST_CASE(simplifyQtSignalsSlots1);
|
||||||
|
TEST_CASE(simplifyQtSignalsSlots2);
|
||||||
|
|
||||||
TEST_CASE(simplifySQL);
|
TEST_CASE(simplifySQL);
|
||||||
|
|
||||||
|
@ -5802,7 +5803,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void bitfields14() { // #4561 - crash for 'signals:'
|
void bitfields14() { // #4561 - crash for 'signals:'
|
||||||
ASSERT_EQUALS("class x { signals : } ;", tokenizeAndStringify("class x { signals: };\n",false));
|
ASSERT_EQUALS("class x { protected: } ;", tokenizeAndStringify("class x { signals: };\n",false));
|
||||||
}
|
}
|
||||||
|
|
||||||
void bitfields15() { // #7747 - enum Foo {A,B}:4;
|
void bitfields15() { // #7747 - enum Foo {A,B}:4;
|
||||||
|
@ -6018,7 +6019,7 @@ private:
|
||||||
tokenizeAndStringify("class Fred { __property int x = { } };", false, true, Settings::Win32A));
|
tokenizeAndStringify("class Fred { __property int x = { } };", false, true, Settings::Win32A));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Qt() {
|
void simplifyQtSignalsSlots1() {
|
||||||
const char code1[] = "class Counter : public QObject "
|
const char code1[] = "class Counter : public QObject "
|
||||||
"{ "
|
"{ "
|
||||||
" Q_OBJECT "
|
" Q_OBJECT "
|
||||||
|
@ -6134,6 +6135,12 @@ private:
|
||||||
ASSERT_EQUALS(result4, tokenizeAndStringify(code4,false));
|
ASSERT_EQUALS(result4, tokenizeAndStringify(code4,false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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,false));
|
||||||
|
}
|
||||||
|
|
||||||
void simplifySQL() {
|
void simplifySQL() {
|
||||||
// Oracle PRO*C extensions for inline SQL. Just replace the SQL with "asm()" to fix wrong error messages
|
// Oracle PRO*C extensions for inline SQL. Just replace the SQL with "asm()" to fix wrong error messages
|
||||||
// ticket: #1959
|
// ticket: #1959
|
||||||
|
|
Loading…
Reference in New Issue