ValueType: Better handling of 'new Container'

This commit is contained in:
Daniel Marjamäki 2017-04-05 22:05:29 +02:00
parent f8d8a96aa2
commit fee86b9684
2 changed files with 16 additions and 0 deletions

View File

@ -5031,6 +5031,14 @@ void SymbolDatabase::setValueTypeInTokenList()
const Token *typeTok = tok->next();
if (Token::Match(typeTok, "( std| ::| nothrow )"))
typeTok = typeTok->link()->next();
if (const Library::Container *c = _settings->library.detectContainer(typeTok)) {
ValueType vt;
vt.pointer = 1;
vt.container = c;
vt.type = ValueType::Type::CONTAINER;
setValueType(tok, vt);
continue;
}
std::string typestr;
while (Token::Match(typeTok, "%name% :: %name%")) {
typestr += typeTok->str() + "::";

View File

@ -4431,6 +4431,14 @@ private:
ASSERT_EQUALS(true, vt.fromLibraryType("s32", &settingsUnix32));
ASSERT_EQUALS(ValueType::Type::INT, vt.type);
}
{
// Container
Settings sC;
Library::Container c;
c.startPattern = "C";
sC.library.containers["C"] = c;
ASSERT_EQUALS("container(C) *", typeOf("C*c=new C;","new","test.cpp",&sC));
}
// new
ASSERT_EQUALS("C *", typeOf("class C {}; x = new C();", "new"));