Fixed #9787 (Better handling of user defined literals)
This commit is contained in:
parent
2700e1e44a
commit
af6e76d623
|
@ -186,7 +186,7 @@ public:
|
|||
|
||||
/** @brief Look for loops that can replaced with std algorithms */
|
||||
void useStlAlgorithm();
|
||||
|
||||
|
||||
void checkMutexes();
|
||||
|
||||
private:
|
||||
|
|
|
@ -11161,6 +11161,22 @@ void Tokenizer::simplifyOperatorName()
|
|||
tok->isOperatorKeyword(true);
|
||||
}
|
||||
|
||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||
if (Token::Match(tok, "%op% %str% %name%")) {
|
||||
std::string name = tok->strAt(2);
|
||||
Token * const str = tok->next();
|
||||
str->deleteNext();
|
||||
tok->insertToken("operator\"\"" + name);
|
||||
tok = tok->next();
|
||||
tok->isOperatorKeyword(true);
|
||||
tok->insertToken("(");
|
||||
str->insertToken(")");
|
||||
Token::createMutualLinks(tok->next(), str->next());
|
||||
str->insertToken(MathLib::toString(Token::getStrLength(str)));
|
||||
str->insertToken(",");
|
||||
}
|
||||
}
|
||||
|
||||
if (mSettings->debugwarnings) {
|
||||
const Token *tok = list.front();
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ private:
|
|||
TEST_CASE(invalidContainer);
|
||||
TEST_CASE(invalidContainerLoop);
|
||||
TEST_CASE(findInsert);
|
||||
|
||||
|
||||
TEST_CASE(checkMutexes);
|
||||
}
|
||||
|
||||
|
|
|
@ -413,6 +413,7 @@ private:
|
|||
TEST_CASE(simplifyOperatorName24);
|
||||
TEST_CASE(simplifyOperatorName25);
|
||||
TEST_CASE(simplifyOperatorName26);
|
||||
TEST_CASE(simplifyOperatorName27);
|
||||
|
||||
TEST_CASE(simplifyNullArray);
|
||||
|
||||
|
@ -6615,6 +6616,14 @@ private:
|
|||
tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
void simplifyOperatorName27() {
|
||||
const char code[] = "int operator \"\" i (const char *, int);\n"
|
||||
"x = \"abc\"i;";
|
||||
ASSERT_EQUALS("int operator\"\"i ( const char * , int ) ;\n"
|
||||
"x = operator\"\"i ( \"abc\" , 3 ) ;",
|
||||
tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
void simplifyNullArray() {
|
||||
ASSERT_EQUALS("* ( foo . bar [ 5 ] ) = x ;", tokenizeAndStringify("0[foo.bar[5]] = x;"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue