From 6c1096bf715e624e788a7989fe936d0bdc403cec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 5 Mar 2017 15:40:29 +0100 Subject: [PATCH] ValueType: First change to handle 'for (auto i : container)' --- lib/symboldatabase.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 7d8b28c12..672dccd04 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -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(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); + } + } } }