Add support for simplifying user defined literal operator. (#1827)
This commit is contained in:
parent
a7478bcb5a
commit
eade2bb2c2
|
@ -10543,6 +10543,11 @@ void Tokenizer::simplifyOperatorName()
|
||||||
op += ")";
|
op += ")";
|
||||||
par = par->next();
|
par = par->next();
|
||||||
done = false;
|
done = false;
|
||||||
|
} else if (Token::Match(par, "\"\" %name% (")) {
|
||||||
|
op += "\"\"";
|
||||||
|
op += par->strAt(1);
|
||||||
|
par = par->tokAt(2);
|
||||||
|
done = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -398,6 +398,7 @@ private:
|
||||||
TEST_CASE(simplifyOperatorName10); // #8746 - using a::operator=
|
TEST_CASE(simplifyOperatorName10); // #8746 - using a::operator=
|
||||||
TEST_CASE(simplifyOperatorName11); // #8889
|
TEST_CASE(simplifyOperatorName11); // #8889
|
||||||
TEST_CASE(simplifyOperatorName12); // #9110
|
TEST_CASE(simplifyOperatorName12); // #9110
|
||||||
|
TEST_CASE(simplifyOperatorName13); // user defined literal
|
||||||
|
|
||||||
TEST_CASE(simplifyNullArray);
|
TEST_CASE(simplifyNullArray);
|
||||||
|
|
||||||
|
@ -6227,6 +6228,12 @@ private:
|
||||||
tokenizeAndStringify(code));
|
tokenizeAndStringify(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 ) ;",
|
||||||
|
tokenizeAndStringify(code));
|
||||||
|
}
|
||||||
|
|
||||||
void simplifyNullArray() {
|
void simplifyNullArray() {
|
||||||
ASSERT_EQUALS("* ( foo . bar [ 5 ] ) = x ;", tokenizeAndStringify("0[foo.bar[5]] = x;"));
|
ASSERT_EQUALS("* ( foo . bar [ 5 ] ) = x ;", tokenizeAndStringify("0[foo.bar[5]] = x;"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue