ValueType: Better handling of wide strings
This commit is contained in:
parent
37d9a95ef1
commit
cf179f82b6
|
@ -3820,9 +3820,14 @@ void SymbolDatabase::setValueTypeInTokenList(Token *tokens)
|
||||||
::setValueType(tok, ValueType(ValueType::Sign::UNKNOWN_SIGN, ValueType::Type::BOOL, 0U));
|
::setValueType(tok, ValueType(ValueType::Sign::UNKNOWN_SIGN, ValueType::Type::BOOL, 0U));
|
||||||
else if (tok->tokType() == Token::eChar)
|
else if (tok->tokType() == Token::eChar)
|
||||||
::setValueType(tok, ValueType(ValueType::Sign::UNKNOWN_SIGN, ValueType::Type::CHAR, 0U));
|
::setValueType(tok, ValueType(ValueType::Sign::UNKNOWN_SIGN, ValueType::Type::CHAR, 0U));
|
||||||
else if (tok->tokType() == Token::eString)
|
else if (tok->tokType() == Token::eString) {
|
||||||
::setValueType(tok, ValueType(ValueType::Sign::UNKNOWN_SIGN, ValueType::Type::CHAR, 1U, 1U));
|
ValueType valuetype(ValueType::Sign::UNKNOWN_SIGN, ValueType::Type::CHAR, 1U, 1U);
|
||||||
else if (tok->str() == "(") {
|
if (tok->isLong()) {
|
||||||
|
valuetype.originalTypeName = "wchar_t";
|
||||||
|
valuetype.type = ValueType::Type::SHORT;
|
||||||
|
}
|
||||||
|
::setValueType(tok, valuetype);
|
||||||
|
} else if (tok->str() == "(") {
|
||||||
// cast
|
// cast
|
||||||
if (!tok->astOperand2() && Token::Match(tok, "( %name%")) {
|
if (!tok->astOperand2() && Token::Match(tok, "( %name%")) {
|
||||||
ValueType valuetype;
|
ValueType valuetype;
|
||||||
|
|
|
@ -2976,6 +2976,7 @@ private:
|
||||||
ASSERT_EQUALS("const char *", typeOf("\"hello\" + 1", "+"));
|
ASSERT_EQUALS("const char *", typeOf("\"hello\" + 1", "+"));
|
||||||
ASSERT_EQUALS("char", typeOf("\"hello\"[1]", "["));
|
ASSERT_EQUALS("char", typeOf("\"hello\"[1]", "["));
|
||||||
ASSERT_EQUALS("char", typeOf("*\"hello\"", "*"));
|
ASSERT_EQUALS("char", typeOf("*\"hello\"", "*"));
|
||||||
|
ASSERT_EQUALS("const short *", typeOf("L\"hello\" + 1", "+"));
|
||||||
|
|
||||||
// Variable calculations
|
// Variable calculations
|
||||||
ASSERT_EQUALS("int", typeOf("int x; a = x + 1;", "+"));
|
ASSERT_EQUALS("int", typeOf("int x; a = x + 1;", "+"));
|
||||||
|
|
Loading…
Reference in New Issue