Skip to content

Commit 491f69a

Browse files
committed
unqiue varids
1 parent 44c2740 commit 491f69a

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

lib/tokenize.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4712,6 +4712,41 @@ void Tokenizer::setVarIdPass1()
47124712
bool initlist = false;
47134713
bool inlineFunction = false;
47144714
for (Token *tok = list.front(); tok; tok = tok->next()) {
4715+
if (Token::simpleMatch(tok, ") (") && Token::simpleMatch(tok->link(), "( *")) {
4716+
const Token *typeTok = tok->link()->previous();
4717+
while (Token::Match(typeTok, "*|&")) {
4718+
typeTok = tok->previous();
4719+
}
4720+
4721+
if (!Token::Match(typeTok, "%type%"))
4722+
continue;
4723+
4724+
// Add globally unique varids to function pointer arguments
4725+
variableMap.enterScope();
4726+
4727+
tok = tok->next();
4728+
const Token *endTok = tok->link();
4729+
tok = tok->next();
4730+
4731+
for (Token *argTok = tok; argTok != endTok; argTok = argTok->next()) {
4732+
if (Token::simpleMatch(argTok, "("))
4733+
argTok = argTok->link();
4734+
4735+
if (!Token::Match(argTok, "%name%|*|&|&& %name% ,|)"))
4736+
continue;
4737+
4738+
argTok = argTok->next();
4739+
4740+
if (argTok->isStandardType())
4741+
continue;
4742+
4743+
variableMap.addVariable(argTok->str(), false);
4744+
argTok->varId(variableMap.getVarId());
4745+
}
4746+
4747+
variableMap.leaveScope();
4748+
continue;
4749+
}
47154750
if (tok->isOp())
47164751
continue;
47174752
if (cpp && Token::simpleMatch(tok, "template <")) {

0 commit comments

Comments
 (0)