Skip to content

Commit

Permalink
Code duplication, consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jul 24, 2023
1 parent a5773eb commit cfd6f83
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1093,29 +1093,15 @@ static void setTokenValueCast(Token *parent, const ValueType &valueType, const V
static nonneg int getSizeOfType(const Token *typeTok, const Settings *settings)
{
const ValueType &valueType = ValueType::parseDecl(typeTok, *settings, true); // TODO: set isCpp
if (valueType.pointer > 0)
return settings->platform.sizeof_pointer;
if (valueType.type == ValueType::Type::BOOL || valueType.type == ValueType::Type::CHAR)
return 1;
if (valueType.type == ValueType::Type::SHORT)
return settings->platform.sizeof_short;
if (valueType.type == ValueType::Type::INT)
return settings->platform.sizeof_int;
if (valueType.type == ValueType::Type::LONG)
return settings->platform.sizeof_long;
if (valueType.type == ValueType::Type::LONGLONG)
return settings->platform.sizeof_long_long;
if (valueType.type == ValueType::Type::WCHAR_T)
return settings->platform.sizeof_wchar_t;

return 0;

return ValueFlow::getSizeOf(valueType, settings);
}

size_t ValueFlow::getSizeOf(const ValueType &vt, const Settings *settings)
{
if (vt.pointer)
return settings->platform.sizeof_pointer;
if (vt.type == ValueType::Type::CHAR)
if (vt.type == ValueType::Type::BOOL || vt.type == ValueType::Type::CHAR)
return 1;
if (vt.type == ValueType::Type::SHORT)
return settings->platform.sizeof_short;
Expand Down

0 comments on commit cfd6f83

Please sign in to comment.