Tokenizer: Use 'podtype' info from library. Partial fix for #5623

This commit is contained in:
Daniel Marjamäki 2014-06-08 13:28:15 +02:00
parent 9e81fa04b2
commit a41f6077e1
2 changed files with 30 additions and 2 deletions

View File

@ -2457,8 +2457,12 @@ static bool isInitList(const Token *tok)
void Tokenizer::setVarId()
{
// Clear all variable ids
for (Token *tok = list.front(); tok; tok = tok->next())
for (Token *tok = list.front(); tok; tok = tok->next()) {
if (tok->isName())
tok->varId(0);
}
setPodTypes();
// Variable declarations can't start with "return" etc.
std::set<std::string> notstart;
@ -10519,3 +10523,24 @@ void Tokenizer::reportError(const std::list<const Token*>& callstack, Severity::
else
Check::reportError(errmsg);
}
void Tokenizer::setPodTypes()
{
if (_settings) {
for (Token *tok = list.front(); tok; tok = tok->next()) {
if (!tok->isName())
continue;
// pod type
const struct Library::PodType *podType = _settings->library.podtype(tok->str());
if (podType) {
const Token *prev = tok->previous();
while (prev && prev->isName())
prev = prev->previous();
if (prev && !Token::Match(prev, ";|{|}|,|("))
continue;
tok->isStandardType(true);
}
}
}
}

View File

@ -798,6 +798,9 @@ private:
return const_cast<Token*>(startOfExecutableScope(const_cast<const Token *>(tok)));
}
/** Set pod types */
void setPodTypes();
/** settings */
const Settings * _settings;