Moved simplification of operator names before template and parentheses simplifications (#6576)
This commit is contained in:
parent
0d37c4df04
commit
72b4809da0
|
@ -3553,6 +3553,10 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
|||
// Simplify float casts (float)1 => 1.0
|
||||
simplifyFloatCasts();
|
||||
|
||||
// Collapse operator name tokens into single token
|
||||
// operator = => operator=
|
||||
simplifyOperatorName();
|
||||
|
||||
// Remove redundant parentheses
|
||||
simplifyRedundantParentheses();
|
||||
for (Token *tok = list.front(); tok; tok = tok->next())
|
||||
|
@ -3573,10 +3577,6 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
|||
if (!isC())
|
||||
TemplateSimplifier::cleanupAfterSimplify(list.front());
|
||||
|
||||
// Collapse operator name tokens into single token
|
||||
// operator = => operator=
|
||||
simplifyOperatorName();
|
||||
|
||||
// Simplify pointer to standard types (C only)
|
||||
simplifyPointerToStandardType();
|
||||
|
||||
|
|
|
@ -137,6 +137,7 @@ private:
|
|||
TEST_CASE(simplifyAtol)
|
||||
|
||||
TEST_CASE(simplifyOperator1);
|
||||
TEST_CASE(simplifyOperator2);
|
||||
|
||||
TEST_CASE(reverseArraySyntax)
|
||||
TEST_CASE(simplify_numeric_condition)
|
||||
|
@ -2514,6 +2515,31 @@ private:
|
|||
ASSERT_EQUALS(expected, tok(code));
|
||||
}
|
||||
|
||||
void simplifyOperator2() {
|
||||
// #6576
|
||||
ASSERT_EQUALS("class TClass { "
|
||||
"public: "
|
||||
"TClass & operator= ( const TClass & rhs ) ; "
|
||||
"} ; "
|
||||
"TClass :: TClass ( const TClass & other ) "
|
||||
"{ "
|
||||
"operator= ( other ) ; "
|
||||
"} class SharedPtr<Y> { "
|
||||
"SharedPtr<Y> & operator= ( SharedPtr<Y> const & r ) ; "
|
||||
"} ;",
|
||||
tok("template<class T>\n"
|
||||
" class SharedPtr {\n"
|
||||
" SharedPtr& operator=(SharedPtr<Y> const & r);\n"
|
||||
"};\n"
|
||||
"class TClass {\n"
|
||||
"public:\n"
|
||||
" TClass& operator=(const TClass& rhs);\n"
|
||||
"};\n"
|
||||
"TClass::TClass(const TClass &other) {\n"
|
||||
" operator=(other);\n"
|
||||
"}"));
|
||||
}
|
||||
|
||||
void reverseArraySyntax() {
|
||||
ASSERT_EQUALS("a [ 13 ]", tok("13[a]"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue