Prevent Tokenizer::simplifyCalculations() from removing parantheses from calls to Functors.
This commit is contained in:
parent
a58ba811a6
commit
9a9302cba1
|
@ -6202,12 +6202,15 @@ bool Tokenizer::simplifyCalculations()
|
|||
// keep parantheses here: dynamic_cast<Fred *>(p);
|
||||
// keep parantheses here: A operator * (int);
|
||||
// keep parantheses here: operator new [] (size_t);
|
||||
// keep parantheses here: Functor()(a ... )
|
||||
if (Token::Match(tok->next(), "( %var% ) [;),+-*/><]]") &&
|
||||
!tok->isName() &&
|
||||
tok->str() != ">" &&
|
||||
tok->str() != "]" &&
|
||||
!Token::simpleMatch(tok->previous(), "operator") &&
|
||||
!Token::simpleMatch(tok->previous(), "* )"))
|
||||
!Token::simpleMatch(tok->previous(), "* )") &&
|
||||
!Token::Match(tok->tokAt(-2), "%type% ( ) ( %var%")
|
||||
)
|
||||
{
|
||||
tok->deleteNext();
|
||||
tok = tok->next();
|
||||
|
|
|
@ -285,6 +285,8 @@ private:
|
|||
|
||||
// remove calling convention __cdecl, __stdcall, ...
|
||||
TEST_CASE(simplifyCallingConvention);
|
||||
|
||||
TEST_CASE(simplifyFunctorCall);
|
||||
}
|
||||
|
||||
std::string tok(const char code[], bool simplify = true)
|
||||
|
@ -5840,6 +5842,11 @@ private:
|
|||
ASSERT_EQUALS("int f ( ) ;", tok("int APIENTRY f();", true));
|
||||
ASSERT_EQUALS("int f ( ) ;", tok("int CALLBACK f();", true));
|
||||
}
|
||||
|
||||
void simplifyFunctorCall()
|
||||
{
|
||||
ASSERT_EQUALS("IncrementFunctor ( ) ( a ) ;", tok("IncrementFunctor()(a);", true));
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestSimplifyTokens)
|
||||
|
|
Loading…
Reference in New Issue