This commit is contained in:
orbitcowboy 2019-06-05 10:15:30 +02:00
commit 40e8908558
6 changed files with 29 additions and 11 deletions

View File

@ -101,7 +101,7 @@ public:
static bool sameCID(const ErrorItem &errorItem1, const ErrorItem &errorItem2);
};
Q_DECLARE_METATYPE(ErrorItem);
Q_DECLARE_METATYPE(ErrorItem)
/**
* @brief A class containing error data for one shown error line.

View File

@ -1363,5 +1363,5 @@ void ResultsTree::showInconclusiveColumn(bool show)
void ResultsTree::currentChanged(const QModelIndex &current, const QModelIndex &previous)
{
QTreeView::currentChanged(current, previous);
emit selectionChanged(current);
emit treeSelectionChanged(current);
}

View File

@ -198,7 +198,7 @@ signals:
*
* @param current Model index to specify new selected item.
*/
void selectionChanged(const QModelIndex &current);
void treeSelectionChanged(const QModelIndex &current);
/**
* Selected item(s) has been tagged

View File

@ -51,7 +51,7 @@ ResultsView::ResultsView(QWidget * parent) :
connect(mUI.mTree, &ResultsTree::resultsHidden, this, &ResultsView::resultsHidden);
connect(mUI.mTree, &ResultsTree::checkSelected, this, &ResultsView::checkSelected);
connect(mUI.mTree, &ResultsTree::selectionChanged, this, &ResultsView::updateDetails);
connect(mUI.mTree, &ResultsTree::treeSelectionChanged, this, &ResultsView::updateDetails);
connect(mUI.mTree, &ResultsTree::tagged, this, &ResultsView::tagged);
connect(mUI.mTree, &ResultsTree::suppressIds, this, &ResultsView::suppressIds);
connect(this, &ResultsView::showResults, mUI.mTree, &ResultsTree::showResults);

View File

@ -5441,7 +5441,7 @@ Token *Tokenizer::simplifyAddBracesToCommand(Token *tok)
syntaxError(tok);
}
}
} else if (tok->str()=="if") {
} else if (tok->str()=="if" && !Token::simpleMatch(tok->tokAt(-2), "operator \"\"")) {
tokEnd=simplifyAddBracesPair(tok,true);
if (!tokEnd)
return nullptr;
@ -9118,8 +9118,10 @@ void Tokenizer::findGarbageCode() const
for (const Token *tok = tokens(); tok; tok = tok->next()) {
if (Token::Match(tok, "if|while|for|switch")) { // if|while|for|switch (EXPR) { ... }
if (tok->previous() && !Token::Match(tok->previous(), "%name%|:|;|{|}|(|)|,"))
syntaxError(tok);
if (tok->previous() && !Token::Match(tok->previous(), "%name%|:|;|{|}|(|)|,")) {
if (!Token::simpleMatch(tok->tokAt(-2), "operator \"\" if"))
syntaxError(tok);
}
if (Token::Match(tok->previous(), "[(,]"))
continue;
if (!Token::Match(tok->next(), "( !!)"))
@ -9150,8 +9152,10 @@ void Tokenizer::findGarbageCode() const
const Token *prev = tok;
while (prev && prev->isName())
prev = prev->previous();
if (Token::Match(prev, "%op%|%num%|%str%|%char%"))
syntaxError(tok, prev == tok->previous() ? (prev->str() + " " + tok->str()) : (prev->str() + " .. " + tok->str()));
if (Token::Match(prev, "%op%|%num%|%str%|%char%")) {
if (!Token::simpleMatch(tok->tokAt(-2), "operator \"\" if"))
syntaxError(tok, prev == tok->previous() ? (prev->str() + " " + tok->str()) : (prev->str() + " .. " + tok->str()));
}
}
// case keyword must be inside switch

View File

@ -399,6 +399,7 @@ private:
TEST_CASE(simplifyOperatorName11); // #8889
TEST_CASE(simplifyOperatorName12); // #9110
TEST_CASE(simplifyOperatorName13); // user defined literal
TEST_CASE(simplifyOperatorName14); // std::complex operator "" if
TEST_CASE(simplifyNullArray);
@ -6357,11 +6358,24 @@ private:
}
void simplifyOperatorName13() { // user defined literal
const char code[] = "unsigned long operator""_numch(const char *ch, unsigned long size);";
ASSERT_EQUALS("unsigned long operator""_numch ( const char * ch , unsigned long size ) ;",
const char code[] = "unsigned long operator\"\"_numch(const char *ch, unsigned long size);";
ASSERT_EQUALS("unsigned long operator\"\"_numch ( const char * ch , unsigned long size ) ;",
tokenizeAndStringify(code));
}
void simplifyOperatorName14() { // std::complex operator "" if
{
const char code[] = "constexpr std::complex<float> operator\"\"if(long double __num);";
ASSERT_EQUALS("const std :: complex < float > operator\"\"if ( long double __num ) ;",
tokenizeAndStringify(code));
}
{
const char code[] = "constexpr std::complex<float> operator\"\"if(long double __num) { }";
ASSERT_EQUALS("const std :: complex < float > operator\"\"if ( long double __num ) { }",
tokenizeAndStringify(code));
}
}
void simplifyNullArray() {
ASSERT_EQUALS("* ( foo . bar [ 5 ] ) = x ;", tokenizeAndStringify("0[foo.bar[5]] = x;"));
}