SymbolDatabase: Better ValueType handling for containers

This commit is contained in:
Daniel Marjamäki 2019-10-23 19:54:59 +02:00
parent 052c02f8ee
commit dedee2b173
2 changed files with 5 additions and 1 deletions

View File

@ -5681,7 +5681,10 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings)
// library type/function
else if (tok->previous()) {
if (tok->astParent() && Token::Match(tok->astOperand1(), "%name%|::")) {
if (const Library::Container *c = mSettings->library.detectContainer(tok->astOperand1())) {
const Token *typeStartToken = tok->astOperand1();
while (typeStartToken && typeStartToken->str() == "::")
typeStartToken = typeStartToken->astOperand1();
if (const Library::Container *c = mSettings->library.detectContainer(typeStartToken)) {
ValueType vt;
vt.pointer = 0;
vt.container = c;

View File

@ -6618,6 +6618,7 @@ private:
string.arrayLike_indexOp = string.stdStringLike = true;
set.library.containers["test::string"] = string;
ASSERT_EQUALS("signed int", typeOf("Vector<int> v; v[0]=3;", "[", "test.cpp", &set));
ASSERT_EQUALS("container(test :: string)", typeOf("return test::string();", "(", "test.cpp", &set));
ASSERT_EQUALS("container(test :: string)", typeOf("void foo(Vector<test::string> v) { for (auto s: v) { x=s+s; } }", "s", "test.cpp", &set));
ASSERT_EQUALS("container(test :: string)", typeOf("void foo(Vector<test::string> v) { for (auto s: v) { x=s+s; } }", "+", "test.cpp", &set));
}