Skip to content

Commit 4558701

Browse files
committed
varid: don't generate varid and symboldatabase variable for function call parameter
1 parent 17aaecb commit 4558701

4 files changed

Lines changed: 9 additions & 3 deletions

File tree

lib/symboldatabase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3249,7 +3249,7 @@ static const Token* skipScopeIdentifiers(const Token* tok)
32493249

32503250
static const Token* skipPointers(const Token* tok)
32513251
{
3252-
while (Token::Match(tok, "*|&|&&") || (tok && tok->str() == "(" && Token::Match(tok->link()->next(), "(|["))) {
3252+
while (Token::Match(tok, "*|&|&&") || (Token::Match(tok, "( [*&]") && Token::Match(tok->link()->next(), "(|["))) {
32533253
tok = tok->next();
32543254
if (tok->strAt(-1) == "(" && Token::Match(tok, "%type% ::"))
32553255
tok = tok->tokAt(2);

lib/tokenize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2320,7 +2320,7 @@ static bool setVarIdParseDeclaration(const Token **tok, const std::map<std::stri
23202320
singleNameCount = 1;
23212321
} else if (Token::Match(tok2, "&|&&")) {
23222322
ref = !bracket;
2323-
} else if (singleNameCount == 1 && tok2->str() == "(" && Token::Match(tok2->link()->next(), "(|[")) {
2323+
} else if (singleNameCount == 1 && Token::Match(tok2, "( [*&]") && Token::Match(tok2->link()->next(), "(|[")) {
23242324
bracket = true; // Skip: Seems to be valid pointer to array or function pointer
23252325
} else if (tok2->str() == "::") {
23262326
singleNameCount = 0;

test/testsymboldatabase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ class TestSymbolDatabase: public TestFixture {
11441144
"void(*p2)(char); \n" // pointer to function (char) returning void
11451145
"int(*(*p3)(char))[10];\n" // pointer to function (char) returning pointer to array 10 of int
11461146
"float(*(*p4)(char))(long); \n" // pointer to function (char) returning pointer to function (long) returning float
1147-
"short(*(*(p5) (char))(long))(double); \n" // pointer to function (char) returning pointer to function (long) returning pointer to function (double) returning short
1147+
"short(*(*(*p5) (char))(long))(double);\n" // pointer to function (char) returning pointer to function (long) returning pointer to function (double) returning short
11481148
"int(*a1[10])(void); \n" // array 10 of pointer to function (void) returning int
11491149
"float(*(*a2[10])(char))(long);\n" // array 10 of pointer to func (char) returning pointer to func (long) returning float
11501150
"short(*(*(*a3[10])(char))(long))(double);\n" // array 10 of pointer to function (char) returning pointer to function (long) returning pointer to function (double) returning short

test/testvarid.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class TestVarID : public TestFixture {
9191
TEST_CASE(varidFunctionCall2);
9292
TEST_CASE(varidFunctionCall3);
9393
TEST_CASE(varidFunctionCall4); // ticket #3280
94+
TEST_CASE(varidFunctionCall5);
9495
TEST_CASE(varidStl);
9596
TEST_CASE(varid_newauto); // not declaration: new const auto(0);
9697
TEST_CASE(varid_delete);
@@ -1111,6 +1112,11 @@ class TestVarID : public TestFixture {
11111112
tokenize(code2, false, "test.c"));
11121113
}
11131114

1115+
void varidFunctionCall5() {
1116+
const char code[] = "void foo() { (f(x[2]))(x[2]); }";
1117+
ASSERT_EQUALS("1: void foo ( ) { f ( x [ 2 ] ) ( x [ 2 ] ) ; }\n",
1118+
tokenize(code, false, "test.c"));
1119+
}
11141120

11151121
void varidStl() {
11161122
const std::string actual = tokenize(

0 commit comments

Comments
 (0)