SymbolDatabase: Better handling of type aliases in ValueType
This commit is contained in:
parent
b62c562a89
commit
10fc070f44
|
@ -5184,6 +5184,8 @@ static const Token * parsedecl(const Token *type, ValueType * const valuetype, V
|
|||
valuetype->pointer++;
|
||||
else if (type->isStandardType())
|
||||
valuetype->fromLibraryType(type->str(), settings);
|
||||
else if (Token::Match(type->previous(), "!!:: %name% !!::"))
|
||||
valuetype->fromLibraryType(type->str(), settings);
|
||||
if (!type->originalName().empty())
|
||||
valuetype->originalTypeName = type->originalName();
|
||||
type = type->next();
|
||||
|
|
|
@ -146,6 +146,9 @@ private:
|
|||
TEST_CASE(isVariableDeclarationRValueRef);
|
||||
TEST_CASE(isVariableStlType);
|
||||
|
||||
TEST_CASE(VariableValueType1);
|
||||
TEST_CASE(VariableValueType2);
|
||||
|
||||
TEST_CASE(findVariableType1);
|
||||
TEST_CASE(findVariableType2);
|
||||
TEST_CASE(findVariableType3);
|
||||
|
@ -789,6 +792,22 @@ private:
|
|||
ASSERT(var.tokens()->tokAt(2)->scope() != 0);
|
||||
}
|
||||
|
||||
void VariableValueType1() {
|
||||
GET_SYMBOL_DB("typedef uint8_t u8;\n"
|
||||
"static u8 x;\n");
|
||||
const Variable* x = db->getVariableFromVarId(1);
|
||||
ASSERT_EQUALS("x", x->name());
|
||||
ASSERT(x->valueType()->isIntegral());
|
||||
}
|
||||
|
||||
void VariableValueType2() {
|
||||
GET_SYMBOL_DB("using u8 = uint8_t;\n"
|
||||
"static u8 x;\n");
|
||||
const Variable* x = db->getVariableFromVarId(1);
|
||||
ASSERT_EQUALS("x", x->name());
|
||||
ASSERT(x->valueType()->isIntegral());
|
||||
}
|
||||
|
||||
void findVariableType1() {
|
||||
GET_SYMBOL_DB("class A {\n"
|
||||
"public:\n"
|
||||
|
|
Loading…
Reference in New Issue