SymbolDatabase: set value type for std::move()

This commit is contained in:
Daniel Marjamäki 2019-10-05 19:57:52 +02:00
parent 4e525e52ec
commit 7294145797
2 changed files with 7 additions and 0 deletions

View File

@ -5056,6 +5056,11 @@ void SymbolDatabase::setValueType(Token *tok, const ValueType &valuetype)
setValueType(parent, vt); setValueType(parent, vt);
return; return;
} }
// std::move
if (vt2 && parent->str() == "(" && Token::simpleMatch(parent->tokAt(-3), "std :: move (")) {
setValueType(parent, valuetype);
return;
}
if (parent->str() == "*" && !parent->astOperand2() && valuetype.pointer > 0U) { if (parent->str() == "*" && !parent->astOperand2() && valuetype.pointer > 0U) {
ValueType vt(valuetype); ValueType vt(valuetype);
vt.pointer -= 1U; vt.pointer -= 1U;

View File

@ -6261,6 +6261,8 @@ private:
ASSERT_EQUALS("signed int", typeOf("auto a(int) -> int; a(5);", "( 5")); ASSERT_EQUALS("signed int", typeOf("auto a(int) -> int; a(5);", "( 5"));
ASSERT_EQUALS("unsigned long", typeOf("sizeof(x);", "(")); ASSERT_EQUALS("unsigned long", typeOf("sizeof(x);", "("));
ASSERT_EQUALS("signed int", typeOf("int (*a)(int); a(5);", "( 5")); ASSERT_EQUALS("signed int", typeOf("int (*a)(int); a(5);", "( 5"));
// Some standard template functions.. TODO library configuration
ASSERT_EQUALS("signed int", typeOf("std::move(5);", "( 5 )"));
// struct member.. // struct member..
ASSERT_EQUALS("signed int", typeOf("struct AB { int a; int b; } ab; x = ab.a;", ".")); ASSERT_EQUALS("signed int", typeOf("struct AB { int a; int b; } ab; x = ab.a;", "."));