diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 9c0578625..ec7f566b3 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -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() + "::"; diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 96e0ba26a..7fc171a1d 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -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"));