ValueType: First change to handle 'for (auto i : container)'

This commit is contained in:
Daniel Marjamäki 2017-03-05 15:40:29 +01:00
parent ab7cf5d215
commit 6c1096bf71
1 changed files with 20 additions and 0 deletions

View File

@ -4534,6 +4534,26 @@ static void setValueType(Token *tok, const ValueType &valuetype, bool cpp, Value
setAutoTokenProperties(autoToken);
setValueType(parent->previous(), vt, cpp, defaultSignedness, settings);
const_cast<Variable *>(parent->previous()->variable())->setFlags(vt);
} else if (vt2->container) {
// TODO: Determine exact type of RHS
const Token *typeStart = parent->astOperand2();
while (typeStart) {
if (typeStart->variable())
typeStart = typeStart->variable()->typeStartToken();
else if (typeStart->str() == "(" && typeStart->previous() && typeStart->previous()->function())
typeStart = typeStart->previous()->function()->retDef;
else
break;
}
// TODO: Get type better
if (Token::Match(typeStart, "std :: %type% < %type% *| *| >")) {
ValueType vt;
if (parsedecl(typeStart->tokAt(4), &vt, defaultSignedness, settings)) {
setValueType(autoToken, vt, cpp, defaultSignedness, settings);
setAutoTokenProperties(autoToken);
setValueType(parent->previous(), vt, cpp, defaultSignedness, settings);
}
}
}
}