Clang import; fixed ValueType::typeSize calls

This commit is contained in:
Daniel Marjamäki 2020-01-18 17:32:59 +01:00
parent cefd7fb33f
commit 36a67c7022
3 changed files with 6 additions and 6 deletions

View File

@ -969,7 +969,7 @@ static void setValues(Tokenizer *tokenizer, SymbolDatabase *symbolDatabase)
mul *= dim.num;
}
if (var.valueType())
typeSize += mul * var.valueType()->typeSize(*settings);
typeSize += mul * var.valueType()->typeSize(*settings, true);
}
scope.definedType->sizeOf = typeSize;
}
@ -977,7 +977,7 @@ static void setValues(Tokenizer *tokenizer, SymbolDatabase *symbolDatabase)
for (Token *tok = const_cast<Token*>(tokenizer->tokens()); tok; tok = tok->next()) {
if (Token::simpleMatch(tok, "sizeof (")) {
ValueType vt = ValueType::parseDecl(tok->tokAt(2), settings);
int sz = vt.typeSize(*settings);
int sz = vt.typeSize(*settings, true);
if (sz <= 0)
continue;
int mul = 1;

View File

@ -6127,10 +6127,10 @@ std::string ValueType::dump() const
return ret.str();
}
MathLib::bigint ValueType::typeSize(const cppcheck::Platform &platform) const
MathLib::bigint ValueType::typeSize(const cppcheck::Platform &platform, bool p) const
{
//if (pointer)
// return platform.sizeof_pointer;
if (p && pointer)
return platform.sizeof_pointer;
if (typeScope && typeScope->definedType && typeScope->definedType->sizeOf)
return typeScope->definedType->sizeOf;

View File

@ -1222,7 +1222,7 @@ public:
return typeScope && typeScope->type == Scope::eEnum;
}
MathLib::bigint typeSize(const cppcheck::Platform &platform) const;
MathLib::bigint typeSize(const cppcheck::Platform &platform, bool p=false) const;
std::string str() const;
std::string dump() const;