Fixed #8272 (setVarIdPass2: Broken parsing of class header)
This commit is contained in:
parent
4740bf116f
commit
31a1cebc5f
|
@ -3044,19 +3044,24 @@ void Tokenizer::setVarIdPass2()
|
||||||
for (std::list<const Token *>::const_iterator it = classnameTokens.begin(); it != classnameTokens.end(); ++it)
|
for (std::list<const Token *>::const_iterator it = classnameTokens.begin(); it != classnameTokens.end(); ++it)
|
||||||
classname += (classname.empty() ? "" : " :: ") + (*it)->str();
|
classname += (classname.empty() ? "" : " :: ") + (*it)->str();
|
||||||
|
|
||||||
std::map<std::string, unsigned int>& thisClassVars = varsByClass[scopeName2 + classname];
|
std::map<std::string, unsigned int> &thisClassVars = varsByClass[scopeName2 + classname];
|
||||||
while (tokStart && tokStart->str() != "{") {
|
while (Token::Match(tokStart, ":|::|,|%name%")) {
|
||||||
if (Token::Match(tokStart, "public|private|protected %name%"))
|
if (Token::Match(tokStart, "%name% <")) {
|
||||||
|
tokStart = tokStart->next()->findClosingBracket();
|
||||||
|
if (tokStart)
|
||||||
tokStart = tokStart->next();
|
tokStart = tokStart->next();
|
||||||
if (tokStart->strAt(1) == "," || tokStart->strAt(1) == "{") {
|
continue;
|
||||||
|
}
|
||||||
|
if (Token::Match(tokStart, "%name% ,|{")) {
|
||||||
const std::map<std::string, unsigned int>& baseClassVars = varsByClass[tokStart->str()];
|
const std::map<std::string, unsigned int>& baseClassVars = varsByClass[tokStart->str()];
|
||||||
thisClassVars.insert(baseClassVars.begin(), baseClassVars.end());
|
thisClassVars.insert(baseClassVars.begin(), baseClassVars.end());
|
||||||
}
|
}
|
||||||
tokStart = tokStart->next();
|
tokStart = tokStart->next();
|
||||||
}
|
}
|
||||||
|
if (!Token::simpleMatch(tokStart, "{"))
|
||||||
|
continue;
|
||||||
|
|
||||||
// What member variables are there in this class?
|
// What member variables are there in this class?
|
||||||
if (tokStart) {
|
|
||||||
for (std::list<const Token *>::const_iterator it = classnameTokens.begin(); it != classnameTokens.end(); ++it)
|
for (std::list<const Token *>::const_iterator it = classnameTokens.begin(); it != classnameTokens.end(); ++it)
|
||||||
scopeInfo.push_back(ScopeInfo2((*it)->str(), tokStart->link()));
|
scopeInfo.push_back(ScopeInfo2((*it)->str(), tokStart->link()));
|
||||||
|
|
||||||
|
@ -3075,7 +3080,6 @@ void Tokenizer::setVarIdPass2()
|
||||||
else if (tok2->varId() > 0)
|
else if (tok2->varId() > 0)
|
||||||
thisClassVars[tok2->str()] = tok2->varId();
|
thisClassVars[tok2->str()] = tok2->varId();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Are there any member variables in this class?
|
// Are there any member variables in this class?
|
||||||
if (thisClassVars.empty())
|
if (thisClassVars.empty())
|
||||||
|
|
Loading…
Reference in New Issue