SymbolDatabase: Better ValueType handling of 'LibraryType(..)'
This commit is contained in:
parent
75e4e70ce4
commit
79356b1883
|
@ -5559,6 +5559,11 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings)
|
||||||
// function style cast
|
// function style cast
|
||||||
else if (tok->previous() && tok->previous()->isStandardType()) {
|
else if (tok->previous() && tok->previous()->isStandardType()) {
|
||||||
ValueType valuetype;
|
ValueType valuetype;
|
||||||
|
if (valuetype.fromLibraryType(tok->astOperand1()->expressionString(), mSettings)) {
|
||||||
|
setValueType(tok, valuetype);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
valuetype.type = ValueType::typeFromString(tok->previous()->str(), tok->previous()->isLong());
|
valuetype.type = ValueType::typeFromString(tok->previous()->str(), tok->previous()->isLong());
|
||||||
if (tok->previous()->isUnsigned())
|
if (tok->previous()->isUnsigned())
|
||||||
valuetype.sign = ValueType::Sign::UNSIGNED;
|
valuetype.sign = ValueType::Sign::UNSIGNED;
|
||||||
|
@ -5575,8 +5580,19 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings)
|
||||||
setValueType(tok, valuetype);
|
setValueType(tok, valuetype);
|
||||||
}
|
}
|
||||||
|
|
||||||
// library function
|
// library type/function
|
||||||
else if (tok->previous()) {
|
else if (tok->previous()) {
|
||||||
|
if (tok->astParent() && Token::Match(tok->astOperand1(), "%name%|::")) {
|
||||||
|
if (const Library::Container *c = mSettings->library.detectContainer(tok->astOperand1())) {
|
||||||
|
ValueType vt;
|
||||||
|
vt.pointer = 0;
|
||||||
|
vt.container = c;
|
||||||
|
vt.type = ValueType::Type::CONTAINER;
|
||||||
|
setValueType(tok, vt);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const std::string& typestr(mSettings->library.returnValueType(tok->previous()));
|
const std::string& typestr(mSettings->library.returnValueType(tok->previous()));
|
||||||
if (!typestr.empty()) {
|
if (!typestr.empty()) {
|
||||||
ValueType valuetype;
|
ValueType valuetype;
|
||||||
|
|
|
@ -6319,6 +6319,7 @@ private:
|
||||||
ASSERT_EQUALS("unsigned int *", typeOf(";void *data = new u32[10];", "new", "test.cpp", &settingsWin64));
|
ASSERT_EQUALS("unsigned int *", typeOf(";void *data = new u32[10];", "new", "test.cpp", &settingsWin64));
|
||||||
ASSERT_EQUALS("unsigned int *", typeOf(";void *data = new xyz::x[10];", "new", "test.cpp", &settingsWin64));
|
ASSERT_EQUALS("unsigned int *", typeOf(";void *data = new xyz::x[10];", "new", "test.cpp", &settingsWin64));
|
||||||
ASSERT_EQUALS("unsigned int", typeOf("; x = (xyz::x)12;", "(", "test.cpp", &settingsWin64));
|
ASSERT_EQUALS("unsigned int", typeOf("; x = (xyz::x)12;", "(", "test.cpp", &settingsWin64));
|
||||||
|
ASSERT_EQUALS("unsigned int", typeOf(";u32(12);", "(", "test.cpp", &settingsWin64));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// PlatformType
|
// PlatformType
|
||||||
|
@ -6351,6 +6352,7 @@ private:
|
||||||
sC.library.containers["C"] = c;
|
sC.library.containers["C"] = c;
|
||||||
ASSERT_EQUALS("container(C) *", typeOf("C*c=new C;","new","test.cpp",&sC));
|
ASSERT_EQUALS("container(C) *", typeOf("C*c=new C;","new","test.cpp",&sC));
|
||||||
ASSERT_EQUALS("container(C) *", typeOf("x=(C*)c;","(","test.cpp",&sC));
|
ASSERT_EQUALS("container(C) *", typeOf("x=(C*)c;","(","test.cpp",&sC));
|
||||||
|
ASSERT_EQUALS("container(C)", typeOf("C c = C();","(","test.cpp",&sC));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Container (vector)
|
// Container (vector)
|
||||||
|
|
Loading…
Reference in New Issue