Fixed #1691 (False positive: Function parameter 'x' is passed by value. It could be passed by reference instead.)
This commit is contained in:
parent
1539c0b3d2
commit
41c43c1790
|
@ -1064,11 +1064,14 @@ void Tokenizer::simplifyTypedef()
|
|||
}
|
||||
}
|
||||
|
||||
while (!pointers.empty())
|
||||
if (!pointers.empty())
|
||||
{
|
||||
tok2->insertToken(pointers.front().c_str());
|
||||
pointers.pop_front();
|
||||
tok2 = tok2->next();
|
||||
std::list<std::string>::const_iterator iter;
|
||||
for (iter = pointers.begin(); iter != pointers.end(); ++iter)
|
||||
{
|
||||
tok2->insertToken(*iter);
|
||||
tok2 = tok2->next();
|
||||
}
|
||||
}
|
||||
|
||||
if (functionPtr || functionRef || function)
|
||||
|
@ -1198,6 +1201,7 @@ void Tokenizer::simplifyTypedef()
|
|||
arrayStart = 0;
|
||||
arrayEnd = 0;
|
||||
offset = 1;
|
||||
pointers.clear();
|
||||
|
||||
while (tok->tokAt(offset) && Token::Match(tok->tokAt(offset), "*|&"))
|
||||
pointers.push_back(tok->tokAt(offset++)->str());
|
||||
|
|
|
@ -191,6 +191,7 @@ private:
|
|||
TEST_CASE(simplifyTypedef46); // ticket #1615
|
||||
TEST_CASE(simplifyTypedef47);
|
||||
TEST_CASE(simplifyTypedef48); // ticket #1673
|
||||
TEST_CASE(simplifyTypedef49); // ticket #1691
|
||||
|
||||
TEST_CASE(simplifyTypedefFunction1);
|
||||
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
|
||||
|
@ -3989,6 +3990,23 @@ private:
|
|||
ASSERT_EQUALS(expected, sizeof_(code));
|
||||
}
|
||||
|
||||
void simplifyTypedef49() // ticket #1691
|
||||
{
|
||||
const char code[] = "class Class2 {\n"
|
||||
"typedef const Class & Const_Reference;\n"
|
||||
"void some_method (Const_Reference x) const {}\n"
|
||||
"void another_method (Const_Reference x) const {}\n"
|
||||
"}";
|
||||
|
||||
// The expected result..
|
||||
const std::string expected("class Class2 { "
|
||||
"; "
|
||||
"void some_method ( const Class & x ) const { } "
|
||||
"void another_method ( const Class & x ) const { } "
|
||||
"}");
|
||||
ASSERT_EQUALS(expected, sizeof_(code));
|
||||
}
|
||||
|
||||
void simplifyTypedefFunction1()
|
||||
{
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue