ValueType: Better handling of 'new Container'
This commit is contained in:
parent
f8d8a96aa2
commit
fee86b9684
|
@ -5031,6 +5031,14 @@ void SymbolDatabase::setValueTypeInTokenList()
|
||||||
const Token *typeTok = tok->next();
|
const Token *typeTok = tok->next();
|
||||||
if (Token::Match(typeTok, "( std| ::| nothrow )"))
|
if (Token::Match(typeTok, "( std| ::| nothrow )"))
|
||||||
typeTok = typeTok->link()->next();
|
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;
|
std::string typestr;
|
||||||
while (Token::Match(typeTok, "%name% :: %name%")) {
|
while (Token::Match(typeTok, "%name% :: %name%")) {
|
||||||
typestr += typeTok->str() + "::";
|
typestr += typeTok->str() + "::";
|
||||||
|
|
|
@ -4431,6 +4431,14 @@ private:
|
||||||
ASSERT_EQUALS(true, vt.fromLibraryType("s32", &settingsUnix32));
|
ASSERT_EQUALS(true, vt.fromLibraryType("s32", &settingsUnix32));
|
||||||
ASSERT_EQUALS(ValueType::Type::INT, vt.type);
|
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
|
// new
|
||||||
ASSERT_EQUALS("C *", typeOf("class C {}; x = new C();", "new"));
|
ASSERT_EQUALS("C *", typeOf("class C {}; x = new C();", "new"));
|
||||||
|
|
Loading…
Reference in New Issue