SymbolDatabase: Set valuetype for this
This commit is contained in:
parent
15d3e510e1
commit
8fb8e06003
|
@ -7033,6 +7033,18 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
|
|||
parsedecl(fscope->function->retDef, &vt, mDefaultSignedness, mSettings, mIsCpp);
|
||||
setValueType(tok, vt);
|
||||
}
|
||||
} else if (tok->isKeyword() && tok->str() == "this" && tok->scope()->isExecutable()) {
|
||||
const Scope* fscope = tok->scope();
|
||||
while (fscope && !fscope->function)
|
||||
fscope = fscope->nestedIn;
|
||||
const Scope* defScope = fscope && fscope->function->tokenDef ? fscope->function->tokenDef->scope() : nullptr;
|
||||
if (defScope && defScope->isClassOrStruct()) {
|
||||
ValueType vt(ValueType::Sign::UNKNOWN_SIGN, ValueType::Type::RECORD, 1);
|
||||
vt.typeScope = defScope;
|
||||
if (fscope->function->isConst())
|
||||
vt.constness = 1;
|
||||
setValueType(tok, vt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -473,6 +473,7 @@ private:
|
|||
|
||||
TEST_CASE(valueType1);
|
||||
TEST_CASE(valueType2);
|
||||
TEST_CASE(valueTypeThis);
|
||||
|
||||
TEST_CASE(variadic1); // #7453
|
||||
TEST_CASE(variadic2); // #7649
|
||||
|
@ -7923,6 +7924,11 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void valueTypeThis() {
|
||||
ASSERT_EQUALS("C *", typeOf("class C { C() { *this = 0; } };", "this"));
|
||||
ASSERT_EQUALS("const C *", typeOf("class C { void foo() const; }; void C::foo() const { *this = 0; }", "this"));
|
||||
}
|
||||
|
||||
void variadic1() { // #7453
|
||||
{
|
||||
GET_SYMBOL_DB("CBase* create(const char *c1, ...);\n"
|
||||
|
|
Loading…
Reference in New Issue